Jump to content
  • Advertisement
Sign in to follow this  
ManaStone

Need help understanding animation structures in a MS3D file.

This topic is 4976 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

First thing, I read this article and tried to build a program that would just transform every vertex according to the final key frame of each joint(as opposed to having it interpolate between frames). At the moment, it’s not working too well. It would help greatly if someone could answer the following questions: 1) I’m using the 1.7.2 file format for the MS3D files. Is there a big difference between the format version from the article and the one I’m using? 2) What exactly is the local rotation for a joint and why do I need to use it? Isn’t the only thing I really need to know is the pivot point of the joint and be able do keyframe rotations around it? I made a simple program where I defined the vertices of the mesh manually and rotated a section with just a pivot point and it seemed to work fine. 3) In the keyframe structure, what exactly is the translation? I made simple mesh with MilkShape3D and animated it with just rotations and absolutely no translations, yet when I parsed the file I still got translation data in the translation keyframes. 4) When we transform a vertex, is it Vertex * Matrix or Matrix * Vertex?

Share this post


Link to post
Share on other sites
Advertisement
I had trouble in this area too. The ms3d forums were helpful: Clicky but I'm sure you know about them.

1) No.

2 & 3) To build your skeleton the way it is in ms3d, you go through this;

for each bone {
build a rotation/translation matrix from rot/trans info
this bones final matrix = local rot/trans * parents matrix
}

Try modelling a static 3d axis and render it at each bone position.

4) Consider the vector as a [1][4] matrix. Then vec * mat is legal because the src_columns must match the dest_rows.

mat[1][4] * mat[4][4] = mat[1][4]
mat[4][4] * mat[1][4] = illegal

but depending on your api, as long as you can umltiply a vector and a matrix and return a vector, your on track.


The trouble I had with this method is that each vertex is defined (of course!) in model space. Now when you build your skeleton (matrix stack) each bone is a product of it's parent so transforming each vertex by it's indexed bone doesn't work. But as a load-time operation I build the skeleton then transform each vertex by it's inverse bone matrix; essentially converting the vertices to bone space. From then on the vertex transformations work as they should.

I also found that just getting each bone tied to it's parent was a convoluted process, but maybe that's just me :)

- Matt

Share this post


Link to post
Share on other sites
Quote:
Original post by matibee

2 & 3) To build your skeleton the way it is in ms3d, you go through this;

for each bone {
build a rotation/translation matrix from rot/trans info
this bones final matrix = local rot/trans * parents matrix
}

- Matt

Thanks for the reply. So the final matrix = local * parants? I thought it was final =Parents * local. I sure though that is one of the many things that can be wrong. I've searched the internet for ways to transforming euler angles into a matrix, and there appears to be more than one way of doing it. Which method does Milkshape use. Currently I am using the method:

B
[ cos(yaw) sin(yaw) 0 ]
[ -sin(yaw) cos(yaw) 0 ]
[ 0 0 1 ]

C
[ 1 0 0 ]
[ 0 cos(pitch) sin(pitch) ]
[ 0 -sin(pitch) cos(pitch) ]

D
[ cos(roll) sin(roll) 0 ]
[ -sin(roll) cos(roll) 0 ]
[ 0 0 1 ]

BCD

This is my function to convert euler angles to a quaternion:
void cQuaternion::EulerToQuaternion(float ax,float ay,float az)
{

ax/=2;
ay/=2;
az/=2;


float cax= cos(ax);
float sax= sin(ax);
float cay= cos(ay);
float say= sin(ay);
float caz= cos(az);
float saz= sin(az);

w=cax*cay*caz-sax*say*saz;
x=sax*cay*caz+cax*say*saz;
y=cax*say*caz-sax*cay*saz;
z=cax*cay*saz+sax*say*caz;


}

Share this post


Link to post
Share on other sites
Try using 4x4 matrices that hold translation info too.

I use d3d and the d3dxmatrix structure =
[ xaxis.x, xaxis.y, xaxis.z, 0 ]
[ yaxis.x, yaxis.y, yaxis.z, 0 ]
[ zaxis.x, zaxis.y, zaxis.z, 0 ]
[ postn.x, postn.y, postn.z, 1 ]

Using 3 seperate 3x3 matrices and combining them is wasteful. I build a combined roation matrix according to this in the matriq and quaternion faq (tweaked to suit d3d matrices) then plug in the positions;

mat[4][1] = xpos
mat[4][2] = ypos
mat[4][3] = zpos

I've not had to use quaternions at all. I did use them in the original test code but I gained nothing over my current method.

There's a lot of things you need to get right before the model will render even remotely correct. For now I would concentrate on getting your bone positions right, then work on transforming vertices.

- Matt

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!