Hello !
For a project using Objective-C and OpenGL, I need to modelize and animate a hand.
First step : hand position and orientation
For the position, I put the hand.palmPosition values in a glTranslatef() function :
glTranslatef(hand.palmPosition.x, hand.palmPosition.y, hand.palmPosition.z);
Then, for the orientation, I create a quaternion from the pitch and yaw values of the hand.direction
and the roll value of the hand.palmNormal. And I create the associated rotation matrix.
[quat setWithPitchY: hand.direction.yaw rollX hand.direction.pitch yawZ: hand.palmNormal.roll];
Matrix *mat = [[Matrix alloc] initWithQuaternion: quat];
nota : my quaternion equation are not with the same axis than the Leap Controller axis, that’s why I put the yaw in the pitch, the pitch in the roll, etc…
Then I multiply my matrix to the current matrix with the glMultMatrixf() function :
glMultMatrixf([mat floatMatrix]);
Finally, I draw a cube and two vectors representing the direction and the normal.
It works perfectly !
Second step : proximal bone position and orientation
I choose an arbitrary position for the proximal bone base joint :
glTranslatef(-0.5, 0, -0.5);
From here I don’t know what to do. The SDK don’t give access to the pitch ans yaw of the bone in the local axis (ie relative to the hand axis). The only data is the bone.direction vector represented in the leap motion Controler axis, not in the local axis of the hand.
Does somebody have an idea ?
Thanks in advance.