Mesh Animation

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

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 on other sites
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 initializedoriginalMatrix = Leg.Matrix; // save a copy of the original matrix

and then
// in your loop or OnUpdate or whereever you get TickLeg.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 on other sites
Thanks Buckeye
That did the trick.

1. 1
2. 2
3. 3
Rutin
12
4. 4
5. 5

• 26
• 10
• 9
• 9
• 11
• Forum Statistics

• Total Topics
633696
• Total Posts
3013387
×