First you should look at the source to DZoneConverter (you can get it in the same download area as OpenZone). It does a proper job of loading many (though not all) mob models.
Rendering mob models always starts with an 0x14 fragment. You can follow that to a 0x10 fragment which contains the skeletal structure of the model. That will eventually link to 0x12 and 0x36 fragments. The 0x36 fragment contains the raw vertex and poly information but before rendering you have to use the information in the 0x12 fragments to figure out how each skeletal piece is oriented.
You see, the 0x10 fragment contains a list of references to 0x13 fragmens, where each 0x13 fragment corresponds to exactly one piece of the skeleton. Each 0x13 fragment refers to exactly one 0x12 fragment. In the 0x10 fragment, each of the entries in its list points to one or more entries, such that the skeleton is actually a hierarchical tree. It generally starts with the central torso and branches out recursively until it ends at the extremities. DZoneConverter renders them by recursively following the skeleton piece references in the 0x10 fragment.
For each piece you go from the 0x10 list entry to the corresponding 0x13 and then to the 0x12 fragment. Each 0x12 fragment describes how that skeletal piece (e.g. a forearm) is positioned and oriented relative to its parent piece (e.g. a forearm's parent would be the bicep -- the bicep's parent would be the chest). Positional and orientational information is *cumulative* (so if you move or rotate the bicep, all skeletal pieces that descend from it, like the forearm and hand, move and rotate as well). In the end, the information in the 0x12 fragments amount to three-dimensional transformations that have to be applied to the raw vertex data in the 0x36 fragment before rendering the model.
There are a number of ways to do the actual render. One way, for instance, is to copy all the raw vertices and then walk the skeleton, adjusting all vertices in each skeletal piece as you encounter it. Then, once you've gone through the entire skeleton, render the model with the new vertex data instead of the raw data in the 0x36 fragment. That's only one way to do it and is just a simple example. I don't remember how DZoneConverter does it off the top of my head but you should give it a look.
WC
|