mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
more work on hand tracking
This commit is contained in:
parent
fdf9dc432d
commit
d51b408c12
2 changed files with 19 additions and 9 deletions
|
@ -7,6 +7,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
find_package(KINECT)
|
||||||
if (KINECT_FOUND)
|
if (KINECT_FOUND)
|
||||||
set(TARGET_NAME hifiKinect)
|
set(TARGET_NAME hifiKinect)
|
||||||
setup_hifi_plugin(Script Qml Widgets)
|
setup_hifi_plugin(Script Qml Widgets)
|
||||||
|
|
|
@ -438,7 +438,7 @@ void KinectPlugin::ProcessBody(INT64 time, int bodyCount, IBody** bodies) {
|
||||||
|
|
||||||
glm::vec3 jointPosition { joints[j].Position.X,
|
glm::vec3 jointPosition { joints[j].Position.X,
|
||||||
joints[j].Position.Y,
|
joints[j].Position.Y,
|
||||||
-joints[j].Position.Z };
|
joints[j].Position.Z };
|
||||||
|
|
||||||
// Kinect Documentation is unclear on what these orientations are, are they absolute?
|
// Kinect Documentation is unclear on what these orientations are, are they absolute?
|
||||||
// or are the relative to the parent bones. It appears as if it has changed between the
|
// or are the relative to the parent bones. It appears as if it has changed between the
|
||||||
|
@ -451,7 +451,7 @@ void KinectPlugin::ProcessBody(INT64 time, int bodyCount, IBody** bodies) {
|
||||||
// filling in the _joints data...
|
// filling in the _joints data...
|
||||||
if (joints[j].TrackingState != TrackingState_NotTracked) {
|
if (joints[j].TrackingState != TrackingState_NotTracked) {
|
||||||
_joints[j].position = jointPosition;
|
_joints[j].position = jointPosition;
|
||||||
_joints[j].orientation = jointOrientation;
|
//_joints[j].orientation = jointOrientation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -552,30 +552,39 @@ QString KinectPlugin::InputDevice::getDefaultMappingConfig() const {
|
||||||
|
|
||||||
void KinectPlugin::InputDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData,
|
void KinectPlugin::InputDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData,
|
||||||
const std::vector<KinectPlugin::KinectJoint>& joints, const std::vector<KinectPlugin::KinectJoint>& prevJoints) {
|
const std::vector<KinectPlugin::KinectJoint>& joints, const std::vector<KinectPlugin::KinectJoint>& prevJoints) {
|
||||||
|
|
||||||
|
glm::mat4 controllerToAvatar = glm::inverse(inputCalibrationData.avatarMat) * inputCalibrationData.sensorToWorldMat;
|
||||||
|
glm::quat controllerToAvatarRotation = glmExtractRotation(controllerToAvatar);
|
||||||
|
|
||||||
|
vec3 kinectHipPos;
|
||||||
|
if (joints.size() > JointType_SpineBase) {
|
||||||
|
kinectHipPos = joints[JointType_SpineBase].position;
|
||||||
|
}
|
||||||
|
auto hipOffset = -1.0f * kinectHipPos;
|
||||||
|
|
||||||
for (size_t i = 0; i < joints.size(); i++) {
|
for (size_t i = 0; i < joints.size(); i++) {
|
||||||
int poseIndex = KinectJointIndexToPoseIndex((KinectJointIndex)i);
|
int poseIndex = KinectJointIndexToPoseIndex((KinectJointIndex)i);
|
||||||
glm::vec3 linearVel, angularVel;
|
glm::vec3 linearVel, angularVel;
|
||||||
const glm::vec3& pos = joints[i].position;
|
|
||||||
|
// Adjust the position to be hip (avatar) relative, and rotated to match the avatar rotation
|
||||||
|
const glm::vec3& pos = controllerToAvatarRotation * (joints[i].position + hipOffset);
|
||||||
|
|
||||||
if (Vectors::ZERO == pos) {
|
if (Vectors::ZERO == pos) {
|
||||||
_poseStateMap[poseIndex] = controller::Pose();
|
_poseStateMap[poseIndex] = controller::Pose();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME - determine the correct orientation transform
|
||||||
// FIXME - left over from neuron, needs to be turned into orientations from kinect SDK
|
|
||||||
glm::quat rot = joints[i].orientation;
|
glm::quat rot = joints[i].orientation;
|
||||||
|
|
||||||
if (i < prevJoints.size()) {
|
if (i < prevJoints.size()) {
|
||||||
linearVel = (pos - (prevJoints[i].position * METERS_PER_CENTIMETER)) / deltaTime; // m/s
|
linearVel = (pos - (prevJoints[i].position * METERS_PER_CENTIMETER)) / deltaTime; // m/s
|
||||||
// quat log imaginary part points along the axis of rotation, with length of one half the angle of rotation.
|
// quat log imaginary part points along the axis of rotation, with length of one half the angle of rotation.
|
||||||
glm::quat d = glm::log(rot * glm::inverse(prevJoints[i].orientation));
|
glm::quat d = glm::log(rot * glm::inverse(prevJoints[i].orientation));
|
||||||
angularVel = glm::vec3(d.x, d.y, d.z) / (0.5f * deltaTime); // radians/s
|
angularVel = glm::vec3(d.x, d.y, d.z) / (0.5f * deltaTime); // radians/s
|
||||||
}
|
}
|
||||||
|
|
||||||
_poseStateMap[poseIndex] = controller::Pose(pos, rot, linearVel, angularVel);
|
_poseStateMap[poseIndex] = controller::Pose(pos, rot, linearVel, angularVel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME - left over from neuron
|
|
||||||
_poseStateMap[controller::RIGHT_HAND_THUMB1] = controller::Pose(rightHandThumb1DefaultAbsTranslation, glm::quat(), glm::vec3(), glm::vec3());
|
|
||||||
_poseStateMap[controller::LEFT_HAND_THUMB1] = controller::Pose(leftHandThumb1DefaultAbsTranslation, glm::quat(), glm::vec3(), glm::vec3());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue