Hello again!  

Me with my similar line of problems!  

Ok so to summarize again: I have a fbx hand model with bones and everything.  
Ive managed to set up the "wrists" and other joints with callback classes.  

These NodeCallback classes have access to an api that gets sensor data from the 
leap motion.  We have a processing application that exposes positional data in 
an easy way to acccess and interpret.  

Each time the NodeCallback class is called I get the frame data:

(pseudocode)  Frame frame = OurAPI.frame()->getframe();

Now we have positional data.   

Ok now I want to move the fingers of my model to mirror my own fingers over top 
of a LEAP MOTION sensor.  

So provided the node we have is a bone:


Code:

osg::ref_ptr(osgAnimation::Bone) bone = dynamic_cast(osgAnimation::Bone*)(node);




(side note,  <> hides code in code brackets???)

I want to rotate it on an axis relative to the position and rotation of the 
hand.  

The first thing I do is create a QUAT with the frame data using a vector 3 from 
each "joint" in teh hand.  

pseudocode:

  current = frame.finger.joints[currentjoint];
  parent  = frame.finger.joint[parentjoint];
  child     = frame.finger.joint[child];

  Quat quat;
  quat.makerotat(current - parent, child - current);

This way we calculate the rotation needed for angle at which the join should be 
rotated in relation to its parent and child joint.  Correct?

Then I need some Matrices.  

   Matrixd  ComputedRotation = ComputedRotation(quat)
   Matrixd  rotationOfParent    = makeRotate(parent bone rotation);
   Matrixd  translationOfParent = makeTranslate (parent bone translation);

Then I set the bone in skeletonspace

bone->setMatrixInSkeletonSpace(ComputedRotation x  RotationOfParent x 
translationOfParent x parent in skeletonspace);

This way we move the matrix to the parent joint, then translate it back to 
where it should be relative to its parent, then rotate it to the same rotation 
of the parent and finally rotate it to how the frame data says it should.  

That gives quite a wild effect. The finger is bowed backwards and off to the 
side.  I think it might be backwards because the axis are not correctly setup 
to match the osg axis but it shouldn't be so skewed.

So if I remove the computedRotation then I would expect the finger to be placed 
back in its starting position (Aka how the hand model looked before I started 
moving it).  But the finger is slightly off.  I can't figure out for the life 
of me why.    

If I understand it correctly, the approach I am trying to take is forward 
kinematics.  I have a rough grasp of it, but am getting very weird behaviours.  

Why is my finger always offset?  How do I just get a joint to retain its 
relative position and affect only its rotation with a given angle?

Thanks!

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





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

Reply via email to