Ok so we were approaching this problem in too complex of a way. 

I was able to get the hands to move properly by creating a new matrix based off 
of 

a.  The coordinate system we were getting from the API
b.  The coordinate system of OSG
c.  The local coordinate space of the hands. 

So were now able to move the hands around using 3 steps.  

1.  Get the bone matrix of the current bone and its parent matrix.
2.  Depending on whether it is the left or the right hand calculate the bones 
normal, direction and position.
3.  Update the matrix.  Make the y axis negative as OSG has a z up and y into 
the scene coordinate space.


Code:

xVector = normal ^ direction;
yVector = -normal;
zVector = direction;

xVector.normalize();
yVector.normalize();
zVector.normalize();

osgSpace.set(           xVector.x(),                    -xVector.y(),           
                xVector.z(),                                            0, // X 
AXIS
                                                yVector.x(),                    
-yVector.y(),                           yVector.z(),                            
                0, // Y AXIS
                                                zVector.x(),                    
-zVector.y(),                           zVector.z(),                            
                0, // Z AXIS
                                                position.x()/X_SCALEFAC + 
X_Offset,             0,                              position.z() / Y_SCALEFAC 
+ Y_OFFSET,           1  // Position
                                );




Lastly and very important set your translations and multiply the matrices in 
the right order


Code:

parentTransMat.makeTranslate(parent->getMatrixInSkeletonSpace().getTrans());
                        bone->setMatrix(osgSpace);
                        


                        // Apply transformation.
                        if (parent)
                                
bone->setMatrixInSkeletonSpace(bone->getMatrixInBoneSpace() * parentTransMat);




------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=61587#61587





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to