[.net] Transformations in object hierarchies - newbie question

Started by
2 comments, last by mbelew 18 years, 7 months ago
I store the position of my models as variables, then render that model using that stored position:
class Model
{
   private Vector3 position;

   ...
   
   void Render()
   {
      device.Transform.World = Matrix.Translation(position);
   }
}

That works just fine, until I start having model hierarchies. For example, I have a 2 models: arm and hand. Arm is the parent, hand is the child. Whenever arm moves, the hand should move along with it. MY QUESTION IS: if I rotate my arm, how do I find out where the hand's position is?
------Tech, life, family, faith: Give me a visit.
Advertisement
apply same transformations to all sub-models from the "key" model.

if arm is rotating up or down, obviously hand will not rotate up or down.

you will have to use trigonometry equations to transform the hand based on the arm's movement
Care to elaborate? I've been told the MatrixStack class is what I need, and it indeed seems to do the appropriate transformations, but I don't know how to get the model's position after the transformation.

After arm is rotated, how do I get the position of the hand?
------Tech, life, family, faith: Give me a visit.
Quote:Original post by Swamii
Care to elaborate? I've been told the MatrixStack class is what I need, and it indeed seems to do the appropriate transformations, but I don't know how to get the model's position after the transformation.

After arm is rotated, how do I get the position of the hand?


The position is in the result matrix components M41, M42, and M43.

(x, y, z) = (result.M41, result.M42, result.M43).

It might be helpful for you to find a graphics book that covers affine transformations.

This topic is closed to new replies.

Advertisement