Mesh Animation
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
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:
and then
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(...));
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(...));
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement