Advertisement

Animation Pseudocode for Milkshape bones?

Started by April 02, 2005 05:47 AM
3 comments, last by riekhof 19 years, 7 months ago
Below is a really simple milkshape model: 2 joints, 2 triangles, and a 16 frame animation. I thought it would be a good place to start in trying to get an animation to render. I've loaded all the info from a Milkshape ascii export file into my JOGL program. I've also rendered all the vertices, triangles, and materials in my OpenGL world. Now I'd like to render a simple Milkshape bone animation. But I'm lost... What are the steps (matrix and other operations) to get from the bone info at at the bottom of the milkshape export to an animated scene in my OpenGL window? I have the spec for the export file, so I understand all the data, I just don't understand how to use it. Darrel How do u get src to show up in scroll boxes? -------------------------------- // MilkShape 3D ASCII Frames: 16 Frame: 1 Meshes: 1 "Triangles" 0 -1 6 0 0.000000 0.000000 -1.000000 0.000000 0.000000 0 0 -1.000000 0.000000 1.000000 0.000000 0.000000 0 0 1.000000 0.000000 1.000000 0.000000 0.000000 0 0 -5.034483 0.000000 1.000000 0.000000 0.000000 1 0 -3.000000 0.000000 1.000000 0.000000 0.000000 1 0 -4.000000 0.000000 -1.000000 0.000000 0.000000 1 1 0.000000 1.000000 0.000000 2 0 0 1 2 0 0 0 1 0 3 4 5 0 0 0 1 Materials: 0 Bones: 2 "joint1" "" 21 2.022987 0.000000 -0.007663 3.141590 1.568910 0.000000 3 1.000000 0.000000 0.000000 -0.000000 9.000000 0.000000 -0.000000 -0.000000 16.000000 0.000000 -0.000000 -0.000000 3 1.000000 0.000000 0.000000 0.000000 9.000000 -0.000003 1.570794 0.000000 16.000000 0.000000 0.000000 0.000000 "joint2" "joint1" 20 0.000000 0.000000 4.057477 0.000000 0.000000 0.000000 3 1.000000 0.000000 0.000000 0.000000 9.000000 0.000000 -0.000000 0.000082 16.000000 0.000000 -0.000000 0.000082 3 1.000000 0.000000 0.000000 0.000000 9.000000 -0.000003 -1.570777 0.000000 16.000000 -0.000000 -0.000020 -0.000000 GroupComments: 0 MaterialComments: 0 BoneComments: 0 ModelComment: 0
1) For each vertice you read in, find out what boneID it uses.
2) Transform the vertex by the correct joint's matrix ( joint_list[boneID] )
3) Then transform the vertex by the joint's parent's matrix

Basically each joint should have its own matrix along with the concatenation of its parent's matrix with each if its parent matrices.

The Milkshape site has an ascii loader you can look at the code for animation.
Author Freeworld3Dhttp://www.freeworld3d.org
Advertisement
i am a bit confusing about this kind of drawing using milkshape
oconnelseanm,

Thanks for help, that will get me started. I'm not clear on what you meant by by Milkshape ascii loader having code for animation. Can you give me more details on that.

These are the best things on the net I've found so far on the topic.

http://rsn.gamedev.net/tutorials/ms3danim.asp

The pig and bert examples:
http://www.john.findlay1.btinternet.co.uk/opengl/opengl.htm

Darrel
I'm o so close, I just need a little more hand holding on the matrix math.

I've computed the rotation matrix for all the joints. When I just rotate the root, I can make it work. However, if I try to rotate another joint at the same time, bad things happen. oconnelseanm gave me the following algorithm:

for each vertex

1) determine its owner joint. (I'm clear on this step)

2) transform the vertex by the correct joint's matrix.

I assume that means multiply the vertex vector by the owner joints rotation matrix. I'm a bit confused on how keyframes would affect this operation. If I'm not on the intial keyframe, do I need to do some additional matrix operations to get it into position?

3)transfrom the vertex by the joint's parent matrix.

Again, I assume this means multiply by all the ancestor joint rotation matrices. Do I pre or post multiply? And how would not being on initial keyframe affect this?

Tx for any help on this.

This topic is closed to new replies.

Advertisement