History

hand information is in correct coordinate space, cleanup

SamGondelman committed 11 years ago

Commit d88e4841 parent 01c740f2 files · +12 −17Browse files

Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all

Unified · Split

interface/src/Application.cpp+11−16
@@ -2881,10 +2881,15 @@ void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, float · 2880 unmodified lines
2881 2881
2882 palm->setActive(pose.isValid());2882 palm->setActive(pose.isValid());
2883 2883
2884 glm::vec3 position = pose.getTranslation();2884 // transform from sensor space, to world space, to avatar model space.
2885 glm::quat rotation = pose.getRotation();2885 glm::mat4 poseMat = createMatFromQuatAndPos(pose.getRotation(), pose.getTranslation());
2886 glm::mat4 sensorToWorldMat = _myAvatar->getSensorToWorldMatrix();
2887 glm::mat4 modelMat = createMatFromQuatAndPos(_myAvatar->getOrientation(), _myAvatar->getPosition());
2888 glm::mat4 objectPose = glm::inverse(modelMat) * sensorToWorldMat * poseMat;
2889
2890 glm::vec3 position = extractTranslation(objectPose);
2891 glm::quat rotation = glm::quat_cast(objectPose);
2886 2892
2887 // TODO: velocity and tip position information should be converted to model space
2888 // Compute current velocity from position change2893 // Compute current velocity from position change
2889 glm::vec3 rawVelocity;2894 glm::vec3 rawVelocity;
2890 if (deltaTime > 0.0f) {2895 if (deltaTime > 0.0f) {
@@ -2913,6 +2918,8 @@ void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, float · 22 unmodified lines
2913 position = palm->getRawPosition() * velocityFilter + position * (1.0f - velocityFilter);2918 position = palm->getRawPosition() * velocityFilter + position * (1.0f - velocityFilter);
2914 rotation = safeMix(palm->getRawRotation(), rotation, 1.0f - velocityFilter);2919 rotation = safeMix(palm->getRawRotation(), rotation, 1.0f - velocityFilter);
2915 }2920 }
2921 palm->setRawPosition(position);
2922 palm->setRawRotation(rotation);
2916 2923
2917 // Store the one fingertip in the palm structure so we can track velocity2924 // Store the one fingertip in the palm structure so we can track velocity
2918 const float FINGER_LENGTH = 0.3f; // meters2925 const float FINGER_LENGTH = 0.3f; // meters
@@ -2925,15 +2932,6 @@ void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, float · 6 unmodified lines
2925 palm->setTipVelocity(glm::vec3(0.0f));2932 palm->setTipVelocity(glm::vec3(0.0f));
2926 }2933 }
2927 palm->setTipPosition(newTipPosition);2934 palm->setTipPosition(newTipPosition);
2928
2929 // transform from sensor space, to world space, to avatar model space.
2930 glm::mat4 poseMat = createMatFromQuatAndPos(rotation, position);
2931 glm::mat4 sensorToWorldMat = _myAvatar->getSensorToWorldMatrix();
2932 glm::mat4 modelMat = createMatFromQuatAndPos(_myAvatar->getOrientation(), _myAvatar->getPosition());
2933 glm::mat4 objectPose = glm::inverse(modelMat) * sensorToWorldMat * poseMat;
2934
2935 palm->setRawPosition(extractTranslation(objectPose));
2936 palm->setRawRotation(glm::quat_cast(objectPose));
2937}2935}
2938 2936
2939void Application::emulateMouse(Hand* hand, float click, float shift, int index) {2937void Application::emulateMouse(Hand* hand, float click, float shift, int index) {
@@ -2947,7 +2945,6 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index) · 7 unmodified lines
2947 break;2945 break;
2948 }2946 }
2949 }2947 }
2950 //qDebug() << "emulateMouse" << !foundHand << !palm->isActive();
2951 if (!foundHand || !palm->isActive()) {2948 if (!foundHand || !palm->isActive()) {
2952 return;2949 return;
2953 }2950 }
@@ -2975,9 +2972,7 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index) · 21 unmodified lines
2975 pos.setY(canvasSize.y / 2.0f + cursorRange * yAngle);2972 pos.setY(canvasSize.y / 2.0f + cursorRange * yAngle);
2976 2973
2977 }2974 }
2978 2975
2979 //qDebug() << index << " " << click << " " << shift << " " << pos;
2980
2981 //If we are off screen then we should stop processing, and if a trigger or bumper is pressed,2976 //If we are off screen then we should stop processing, and if a trigger or bumper is pressed,
2982 //we should unpress them.2977 //we should unpress them.
2983 if (pos.x() == INT_MAX) {2978 if (pos.x() == INT_MAX) {