Mesh Animation

Started by
1 comment, last by Steve5050 15 years, 10 months ago
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
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 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(...));


Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Thanks Buckeye
That did the trick.

This topic is closed to new replies.

Advertisement