Hi,
I'm writing a simple program which uses Kinect to move a puppet made
with OpenSG.
>From Kinect's API I get a Matrix for each Joint which looks like this:
0.999527 0.0301296 0.00610329
-0.0286029 0.984236 -0.174532
-0.0112657 0.174275 0.984633
The determinat of the matrix is 1, the length of each column vector is also 1.
The dot products of the column vectors are close to 0 (around 1 * 10 ^-5).
So I figured it's a rotation matrix.
I found a way to apply this to a Component Transform, and it works,
but I'm not sure it's the best way to do it.
This is the code:
//turn Kinect Matrix into OpenSG Matrix
osg::Matrix makeOsgMatrix(float* kinectMatrix){
osg::Matrix matrix = osg::Matrix(kinectMatrix[0], kinectMatrix[1],
kinectMatrix[2], 0.0f,
kinectMatrix[3], kinectMatrix[4],
kinectMatrix[5], 0.0f,
kinectMatrix[6], kinectMatrix[7],
kinectMatrix[8], 0.0f,
0.0f, 0.0f,
0.0f, 1.0f);
return matrix;
}
//rotMat is the Kinect Matrix
void Puppet::setRightUpperArmRot(osg::Matrix rotMat){
Vec3f from, to;
//the arm is supposed to be initially horizontal, but i can only
make vertical cones, so I rotate it first.
from = Vec3f(0.0, -1.0, 0.0);
to = Vec3f(1.0, 0.0, 0.0);
Quaternion quatA(from, to);
//turn the kinect matrix into a quaternion and multiply with
initial quaternion
Quaternion quatB(rotMat);
quatA.multLeft(quatB);
//apply final quaternion to ComponentTransform
beginEditCP(rightUpperArmTransCore);
rightUpperArmTransCore->setRotation( quatA );
endEditCP(rightUpperArmTransCore);
}
Is there a faster way to do this? Or do I have to turn the kinect
matrix into a quaternion before applying it to the ComponentTransform?
I have to do it for all the joints 30 times a second, so I want it to be fast.
I would appreciate any comments on this question!
Daniel.
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users