Jump to content
  • Advertisement
Sign in to follow this  
Steve5050

Mesh Animation

This topic is 3658 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Using vb.net 2003 with Dx 9.0c I have a male mesh that I made. I'm trying to move the meshes leg as though it was walking. I can use: Leg.Matrix = Matrix.RotationX(DXUtil.DegreeToRadian(60) * CSng(Math.Cos((CDbl(Tick) / 500.0F)))) To move the leg back and forth as though it was walking but the leg moves to the center of the mesh. If I use: Leg.Matrix = Matrix.Multiply(Leg.Matrix,Matrix.RotationX(DXUtil.DegreeToRadian(60) * CSng(Math.Cos((CDbl(Tick) / 500.0F)))) The leg stays where it is supposed to but swings all the way around,not back and forth. Anybody know how I can solve this problem. Thanks Steve

Share this post


Link to post
Share on other sites
Advertisement
In the first instance, you don't have an offset (translation) for the leg matrix. I suspect Leg.Matrix was originally set up with a translation to its proper position. Then "Leg.Matrix = Matrix.RotationX()" overwrites it and the translation is gone.

In the second instance, you continually add a rotation to the existing matrix.
That is:

Leg.Matrix = Leg.Matrix * Matrix.Rotation;

Next time through the loop, you add a rotation to the previous rotation.

You probably want something like:

// when the leg is initialized
originalMatrix = Leg.Matrix; // save a copy of the original matrix

and then

// in your loop or OnUpdate or whereever you get Tick
Leg.Matrix = Matrix.Multiply(Matrix.RotationX(...),originalMatrix);

In the Matrix.Multiply() call, I'm pretty sure you will want to rotate the leg, then translate it. If it rotates about the wrong point, go back to

MatrixMultiply(originalMatrix,Matrix.Rotation(...));


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!