New (better?) .md2 loader written and other stuff

The XML loader/saver for jME supports both joint animations and keyframe animations. I wrote my own version of VertexKeyframeController (in KeyframeController). I also have conversion utilities to convert .ms3d and .md2 to XML format.






are the test classes.

After converting to XML format, my new .md2 loader animates Dr. Freak about 20-30 FPS faster than the current one, and I added a few tricks so it uses less than half the memory. It also loads about 1100 ms faster than the current one.

Here are the numbers I got when I tested the old md2 loader and the new one I wrote for XML loading (I collected the average FPS for every 1000 frames)

For old loader:
Load time: 4246
FPS: 381.7512
FPS: 428.86276
FPS: 478.78525
FPS: 479.9176
FPS: 476.76544
FPS: 478.65497
FPS: 482.09097
FPS: 480.20566
FPS: 480.8201

For new loader:
Total load time: 3104 (this loadtime does not include converting .md2 to XML which a user would only have to do once in a model's lifetime)
FPS: 397.99054
FPS: 450.28546
FPS: 489.75085
FPS: 491.8328
FPS: 489.68756
FPS: 488.69788
FPS: 490.11353
FPS: 492.1093

Here are a few things I changed. Lemme know if I created something that won't work

The current keyframe controller (VertexKeyframeController) only animates static keyframes. You put in a bunch of TriMesh's and it interpolates between them. KeyframeController (the name of the new class I wrote) animates between times associated with keyframes and they are added one by one whenever convienent. For example, with KeyframeController I say "Look like A at 3 sec, Look like B at 5 sec, Look like C at 125.32 sec", much more difficult with the old controller. Users can also animate at times that aren't keyframe. For example, in the above case you can choose to have a mintime of 4 and a maxtime of 8. Users can even insert keyframes during animation. It also uses Controller's default minTime/maxTime/repeatType/Speed functions. Also, by using interpolation functions for Vector and ColorRGBA KeyframeController is about 100 lines less code (including javadoc).

With my .md2 loading, I created a EmptyTryMesh extends TriMesh class that doens't create floatBuffers whenever arrays are set. This way, I can save on memory because KeyframeController only needs their arrays. I also looked over Md2Model.convertDataStructures() and removed a bunch of calls to new including a whole unused array. I didn't make any of the changes to Md2Model (in fear I'ld mess something up) but they are there in Md2ToXML.

My future plans are to create a VectorPool class for non-changing Vector3f arrays to pull vectors from as a memory saver. What features do users want the most in a generic file format loader/saver? IE what are used the most? Kind of a priority list because all will have to have their own custom loading.

Wow, sounds great Cep21. I haven’t had a chance to check it out, but it sounds very nice. If you can write up a test that converts Dr. Freak to the XML model and runs it, so we can compare. That would be great. It sounds like the XML model loader is turning into a fantastic format. I look forward to playing iwth it.

Oh, looking at the updated code, it appears that you have already made the test. Great, I’ll try to run it.

I just ran it on my slow system here and it ran just as good as the other MD2 loader (might have been better, but this system is too flaky to know for sure). The fact that you are really loading the custom format and not MD2, really makes me feel warm inside.