I have bought the Warriors & Commoners model pack from Frogames and the pack contains (among other formats) two animated models and several non-animated objects (axe, shield, pilosities, etc.) in MilkShape3D format.

I looked at the official "MilkShape 3D Viewer v2.0" (msViewer2.zip at http://www.chumba.ch/chumbalum-soft/ms3d/download.html) source code and implemented loading the model, calculating the joint matrices and everything looks fine.

In the model there are several joints that are designated as the "mount points" for the static objects like axe and shield. I now want to "put" the axe into the hand of the animated model, and I couldn't quite figure out how. I put the animated vertices in a VBO that gets updated every frame (I know I should do this with a shader, but I didn't have time to do this yet). I put the static vertices in another VBO that I want to keep static and not updated every frame.

I now tried to render the animated vertices first, then use the joint matrix for the "mount joint" to calculate the location of the static object. I tried many things, and what about seems to be right is to transpose the joint matrix, then use glMatrixMult() to transform the modelview matrix. For some objects like the axe this is working, but not for others, e.g. the pilosities.

Now my question: How is this generally implemented when using bone/joint models, and especially with MilkShape3D models? Am I on the right track?


1 Answer 1


You are on the right track, but "doesn't work" isn't a particularly helpful error description.

Anchoring a prop onto a skeleton joint is done by simply using the joint transform as the model matrix. That'll put the origin and orientation of the prop model at the joint. This is the chain of transforms you need:

Projection * View * Model * Joint

Now if you're using fixed function OpenGL, you'll have the Projection in GL_PROJECTION and will need to make sure that the GL_MODELVIEW is View * Model * Joint. You had View * Model set already to render the character model, so you should be able to just concatenate the anchor joint transform.

Keep in mind that there are usually a lot of different coordinate spaces involved during skeletal animation, and you must use the correct one. The "Joint" transform I talk about is the model-relative transform of the joint in its animated pose. It is not the parent-relative transform, it's not the inverse bind pose, nor is it the concatenation of the model-relative transform with the inverse bind pose that you use to deform the vertices.

In the msViewer2 sample code it looks like the transform you want is joint->matGlobal.

  • \$\begingroup\$ I'm sorry, "doesn't work" is not helpful indeed. First I used the transposed joint->matGlobal matrix for glMultMatrixd; that placed the model at the correct position, but for some objects the orientation was wrong. When I used the non-transposed joint->matGlobal, the object is placed at the origin, with some stretched extents... \$\endgroup\$
    – vividos
    Nov 20, 2012 at 22:51
  • \$\begingroup\$ It seems I calculated the "Joint" matrix of the static object the wrong way, only calculating the local matrix, not the global matrix. Now the static objects are oriented correctly. Thanks for clearly describing the whole matrix stuff! \$\endgroup\$
    – vividos
    Nov 21, 2012 at 6:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .