got the hands turning the shoulders, needs error checking

This commit is contained in:
Angus Antley 2018-08-24 11:04:36 +01:00
parent 44a6c7df5f
commit 25610c7587
3 changed files with 19 additions and 3 deletions

View file

@ -3349,6 +3349,21 @@ glm::mat4 MyAvatar::deriveBodyFromHMDSensor() const {
return createMatFromQuatAndPos(headOrientationYawOnly, bodyPos);
}
glm::mat4 MyAvatar::getSpine2RotationRigSpace() const {
static const glm::quat RIG_CHANGE_OF_BASIS = Quaternions::Y_180;
glm::vec3 hipToHandRigSpace = RIG_CHANGE_OF_BASIS * glm::vec3(_hipToHandController.x, 0.0f, _hipToHandController.y);
//to do: check for zero before normalizing.
glm::vec3 u, v, w;
generateBasisVectors(glm::vec3(0.0f,1.0f,0.0f), hipToHandRigSpace, u, v, w);
glm::mat4 spine2RigSpace(glm::vec4(w, 0.0f), glm::vec4(u, 0.0f), glm::vec4(v, 0.0f), glm::vec4(glm::vec3(0.0f, 0.0f, 0.0f), 1.0f));
//glm::quat spine2RigSpace = glm::quat_cast(glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::normalize(hipToHandRigSpace), glm::vec3(0.0f, 1.0f, 0.0f)));
return spine2RigSpace;
}
// ease in function for dampening cg movement
static float slope(float num) {
const float CURVE_CONSTANT = 1.0f;

View file

@ -1050,6 +1050,8 @@ public:
// results are in sensor frame (-z forward)
glm::mat4 deriveBodyFromHMDSensor() const;
glm::mat4 getSpine2RotationRigSpace() const;
glm::vec3 computeCounterBalance();
// derive avatar body position and orientation from using the current HMD Sensor location in relation to the previous

View file

@ -240,9 +240,8 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
// spine 2 hack to be improved.
AnimPose newSpinePose;
bool fred = _rig.getAbsoluteJointPoseInRigFrame(_rig.indexOfJoint("Spine2"), newSpinePose);
newSpinePose.rot() = glm::quat(0.7071f, 0.0f, 0.0f, 0.7071f)*newSpinePose.rot();
AnimPose newSpinePose(myAvatar->getSpine2RotationRigSpace());
//newSpinePose.rot() = myAvatar->getSpine2RotationRigSpace();// *newSpinePose.rot();
params.primaryControllerPoses[Rig::PrimaryControllerType_Spine2] = newSpinePose;
params.primaryControllerFlags[Rig::PrimaryControllerType_Spine2] = (uint8_t)Rig::ControllerFlags::Enabled | (uint8_t)Rig::ControllerFlags::Estimated;