Hi Aitor,
Usually when I encounter something like this, the best way to analyze is
to use the axes model delivered with the openscenegraph data.
This way you can find out which axis is pointing which way.
Usually you then come up with something like:
x_org = -y
y_org = x
z_org = -z
Mathematically speaking this represents a matrix which transforms one
coordinate system into another like this:
Mat_trans =
0 -1 0
1 0 0
0 0 -1
Given such a matrix you will have to apply it to the accumulated
transform you get out of the library.
I had these problems with various libraries, as most seem to use DIrectX
coordinates or something totally different.
Hope that helps
Sebastian
Hi,
I am testing the Microsoft SDK for kinect. But this does not give us the
orientation of the bones directly and I am testing to get it out.
On this site, posted an example in xna and I'm looking at the code.
http://social.msdn.microsoft.com/Forums/en-US/kinectsdknuiapi/thread/9afb0fcf-40bd-405c-b423-a0d1eab9bd85
I attached the more relevant code file and model...
In my case I try to do the same...
Code:
osg::Matrix
KinectOSGMainLogic::getBoneMatrixFromKinectNuiControl(NUI_CONTROL_SKELETON_POSITION_INDEX
id)
{
float rotArray[3] =
{nuiControl->skeletonOrientations[nuiControl->activeSkeletonIDs[0]][id]->_array[0],
nuiControl->skeletonOrientations[nuiControl->activeSkeletonIDs[0]][id]->_array[1],
nuiControl->skeletonOrientations[nuiControl->activeSkeletonIDs[0]][id]->_array[2]};
//rotArray is the rest of Shoulder Elbow
osg::Vec3 orientVec(rotArray[1],-rotArray[0],rotArray[2]);
float dp = 0.0;
osg::Vec3 vecRight(osg::Vec3(1.0,0.0,0.0));
for (int i=0;i<3;i++)
dp += orientVec[i] * vecRight[i];
float angle = acos(dp);
orientVec.operator ^(vecRight);
orientVec.normalize();
osg::Matrix mat(osg::Matrix::rotate(osg::Quat(angle,orientVec)));
//printf("getBoneMatrixFromKinectNuiControl =
%f,%f,%f\n",rotArray[0],rotArray[1],rotArray[2]);
return mat;
}
...
if(!sceneM->getAnimatedModel()[0]->boneMatrices[j]->getName().compare("shoulderRight")){
sceneM->getAnimatedModel()[0]->boneMatrices[j]->setMatrix(
getBoneMatrixFromKinectNuiControl(NUI_CONTROL_SKELETON_POSITION_SHOULDER_RIGHT));
}
...
void AnimatedModel::update()
{
for(int i = 0; i<m_bones.size();i++)
{
while(pBoneUpdate.at(i)->getStackedTransforms().size()>6){
pBoneUpdate.at(i)->getStackedTransforms().pop_back();
}
if(!m_bones.at(i)->getName().compare("Waist")){
pBoneUpdate.at(i)->getStackedTransforms().push_back(new
osgAnimation::StackedTranslateElement(
"trans",modelTranslate));
}
pBoneUpdate.at(i)->getStackedTransforms().push_back(new
osgAnimation::StackedQuaternionElement(
"rotate",boneMatrices[i]->getMatrix().getRotate()));
debugAxesMatrices.at(i)->setMatrix(m_bones.at(i)->getMatrixInSkeletonSpace());
}
}
I'm confused ... not sure if xna and osg use the same axes (xyz or xzy).
getBoneMatrixFromKinectNuiControl give me a local rotation matrix, but do I
need to change these to global?
I know that in "pBoneUpdate.at (i) -> getStackedTransforms (). Push_back (new
osgAnimation: StackedQuaternionElement (
"rotate" boneMatrices [i] -> getMatrix (). getRotate ()));" I have to apply a
local array... but I guess I missed something, because the rotations are no goods in the model.
Thank you!
Cheers,
Aitor
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41192#41192
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org