Rotation doesn't work with JointOrientation from kinect in Unity3D 5
A weird thing happen to my code, I don't know why I worked like this, but it did.
My code is like this:
             // Getting joint orientation data from kinect 
             // and construct it with Unity Quaternion
             Kinect.Vector4 targetRotaV4 = body.JointOrientations[jt].Orientation;
             Quaternion targetRotaQ = new Quaternion(targetRotaV4.X, targetRotaV4.Y, targetRotaV4.Z, targetRotaV4.W);
             Debug.Log("target rotation: " + targetRotaQ); // it did print something
 
             // Rotate the gameobject from its local rotation 
             // to the rotation I got from kinect
             jointObj.localRotation = Quaternion.RotateTowards(jointObj.localRotation, targetRotaQ, 45.0f);
             Debug.Log("Joint Object rotation: " + jointObj.localRotation); 
             // It did print value, too, not just (0, 0, 0, 0), 
             // but in the game, the gameobject didn't rotate, and the rotation didn't change in properties which kept 0
 
             // But!! When I ran the following code, it rotated! Everything looked good.
             /*
             Quaternion testRote = new Quaternion(0.1f, 0.1f, 0.1f, 0.1f);
             jointObj.localRotation = Quaternion.RotateTowards(jointObj.localRotation, testRote, 15);
             Debug.Log("Joint local rotation" + jointObj.localRotation);
             */
So my question is, why! Why the rotation couldn't work with my JointOrientation data from kinect which I did get the data because I print the value and it was not null or 0.
Plz help me out!
Answer by totovr92 · Nov 22, 2018 at 01:15 PM
Because the Kinect quaternions seem to assume that any bone points to the sky before rotating,
I turned the bones of my model to the sky before applying the quaternions.
I think you observed your model was jerky and unstable because the quaternions rotated wrongly oriented objects.
Suppose a quaternion rotates objects around y-axis and consider rotating the following two objects by it.
leftArm.transform.rotation = ElbowLeft * Quaternion.AngleAxis(90, new Vector3(0, 1, 0)) * Quaternion.AngleAxis(-90, new Vector3(0, 0, 1));
Your answer
 
 
             Follow this Question
Related Questions
Why is this code in the script not stopping the rotation of the Gameobject? 0 Answers
Many objects with decimal place in the millionths, can this cause any performance issues? 0 Answers
Quaternion * Vector does not work (and its not about the order) 0 Answers
3D Look at Mouse relative to Camera direction 0 Answers
How to send Kinect skeleton data through Unity networks (multiplayer) 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                