(Solved) Skinning MD5mesh/anims in D3D with standard indexed vertex blending

Started by
3 comments, last by BeastX 17 years, 9 months ago
I have a generic skinning and animation system that I hope can support a few formats. Currently, I'm adding support for MD5. It was easy enough to get MD5 meshes, skeletons, and animations loading and playing. My skeleton proxy renders and animates correctly but my mesh has a few anomolies. Because it's a generic system, I can't follow the standard MD5 soft-skinning approach. I tried using the highest priority weights to compute untransformed, weighted vertex positions for a base mesh. This actually kind of worked but it's not as perfect as the usual, soft-skinning approach because I'm limiting the number of weights. Has anyone else encountered this or does anyone have suggestions? [Edited by - BeastX on July 13, 2006 11:49:26 AM]
Advertisement
How many weights are you using? I limited the number to four, and for each vert I did something like:
while (numWeights > 4){    find the lowest weight    find the highest weight    remove the lowest weight, and add its weight to the highest}

Making sure to keep the combined weight of all the weights at 1.0 will keep the model from becoming messed up as it animates. It obviously won't look IDENTICAL to the soft-skinned version, but it'll likely look just fine.
I'll try that. I'd tried trimming the smaller weights and normalizing the remaining four as if they were a vector. That failed :)

Do you still average in the position of the ignored weights?
Everything works fine now regarding bone count. However, the md5 format requires me to have a custom mesh class. I'd like to convert the md5 mesh and anim to work with my normal mesh class, which uses D3D indexed vertex blending.

I've attempted to create the bind pose mesh (the default pose from the md5mesh file), invert each bone's local transform, and plug that into my animation system. What I get is an animated skin that somewhat resembles a roadkill version of my model.

I know this conversion/combination is possible since others have written md5 importers. Can someone who's successfully done this offer assistance, please?
After I got OGRE XML working, I went back to MD5 to attempt to convert it to a useable format (my normal mesh format) for standard skinning.

1) The first problem was caused by not resettingg my model's/skin's transform after scaling it down in MAX. That really only affected Ogre XML because the MD5 exporter ignored scale altogether.

2) After the data was correct, I made sure the MD5 still worked using the MD5 format's assumed method of rendering. That requires building the acttual mesh for the current frame on the CPU and passing it to the normal, static mesh rendering pipeline. Some people managed to do it GPU side but it wouldn't leave room for other effects.

The advantages of building an intermediate mesh are that it doesn't have to be skinned per draw call, your bone count per vertex is limitless, and it can be used for other things like triangle soup collision. It's essentially the same as vertex tweening with less data.

Normal GPU and CPU skinning are much cheaper, don't require custom code, and don't require dealing with so much data. GPU skinning is cheapest in all cases, whether by API or shader. That's good enough reason to convert.

3) Build the base mesh as normal, transforming and combining weights by they're joints to make the meshes vertices.

4) The joints for the MD5Mesh base skeleton (bind pose) are already transformed by their parents. They need to be concatenated with the inverse of their parent joint to match the rest of the data. This is if your system builds the inverse bind matrices instead of taking them directly.

5) Create the inverse bind matrices per bone from the step above. Only transform by these when providing matrices to the renderer.

6) Normalizing the weight values was the correct solution to chopping off too many weights per vertex.

7) There was a minor vertex twitch in one spot after removing some weights. So, limiting the bone count per vertex to 4 in MAX on the skin modifier worked best.

Then it was all henshin a gogo baby.

This topic is closed to new replies.

Advertisement