SMD Animation

Hey,

I am working on an importer for SMD files. Right now I am getting some very odd transformations…

Specifically, in SMD files the vertices are stored in worldspace, therefore each vertex needs to be multiplied by the inverse of the initial bone position to put the vertices into bone space. Does jME expect the vertices to be stored in bone space or world space?

Also, in SMD files each frame of the animation sequence gives the starting bone position in worldspace (not as an incremental transform from the starting skeletal position). So, how is the localRefMatrix of a jointController used in setting the transforms for the model?

Please let me know if my questions are too garbled to follow!

Thanks
Todd

cep21 is the importer specialist for jme ;), but i don’t know if he reads this backup forum.
So if this is not answered in time i suggest waiting for the official forums to be back up and repost it there.

SMD files? What link are you using to find out about the format?

jME expects vertices to be stored in local space, and so does JointController. The localRefMatrix again expects transforms to be relative to the joint parent.

Hey guys, thanks for the help with this.

First, the file format is laid out in the appendix of the tutorial in the SDK for Half-life. Also, I misspoke in my first post…the vertices are stored in local (model) space, not world space.

So, to make sure I understand…The vertices are stored in local space, so animation takes the following steps:

  1. multiply the vertices by the inverse of the localRefMatrix to put them into bone space

  2. multiple each vertex by the relative transform matrix of its joint

Thanks
Todd

That sounds right. The JointController was made with the milkshape format in mind, so there may be a bit of tweaking to do. With that said, it should still be workable for any Joint system that doesn’t use multiple bones per vertex (which I don’t believe halflife does). if you run into any problems let me know.

Here is the function in jointController that is throwing me… Specifically, the bold line below where the jointmovements are set to the localRefMatrix? Why is that necessary? Are the animations supposed to be have joint positions relative to the localRefMatrix or just relative to their parent?

Thanks again, this is really helpful.

private void createJointTransforms(float changeAmnt) {
PointInTime now = (PointInTime) movementInfo.get(curTimePoint);
PointInTime then = (PointInTime) movementInfo.get(curTimePoint - 1);
for (int index = 0; index < numJoints; index++) {
int theParentIndex = parentIndex[index];

             unSyncbeginAngle.set(then.jointRotation[index]);
             unSyncbeginPos.set(then.jointTranslation[index]);

             unSyncbeginAngle.slerp(now.jointRotation[index], changeAmnt);
             unSyncbeginPos.interpolate(now.jointTranslation[index], changeAmnt);

             tempUnSyncd.set(unSyncbeginAngle, unSyncbeginPos);
             [b]jointMovements[index].set(localRefMatrix[index]);[/b]
             jointMovements[index].multLocal(tempUnSyncd, unSyncbeginPos);
             if (theParentIndex != -1) {
                   tempUnSyncd.set(jointMovements[index]);
                   jointMovements[index].set(jointMovements[theParentIndex]);
                   jointMovements[index].multLocal(tempUnSyncd, unSyncbeginPos);
             }
         }

}

I think I found the answer to this…

The description of the Milkshape format indicates:

“…the key matrices animate the reference matrices, so you have to multiply them, to get the final local joint matrix…”

So, if the engine was built with this format in mind, I need to adjust the SMD key positions by the local ref matrix.

Thanks again, cep21 that was some invaluable insight.

Todd