MD2 for the win

I had a talk about MD2 vertex interpolation with Robert Green from Battery Powered Games a week back. He implemented the interpolation as a JNI method for maximum performance. I knew that Dalvik is not the fastest VM on the planet and wanted to see how fast a pure Java MD2 renderer gets on Android.

That’s 15 instances of a single MD2 Model, for each instance i interpolate a seperate vertex array each frame. There’s a total of 365 vertices in the mesh, and 634 indexed triangles. That’s 356 * 15 * 3 = 16020 Flops per frame. On my Milestone i achieve a steady 30fps while rendering the scene above which is pretty good in my opinion. The interpolation code alone takes 9ms for the 15 instances. I use floats throughout my code as fixed point math doesn’t seem to be a lot faster and thus not worth the trouble and pain maintaining it. Here’s the code for interpolating the vertices:

The MD2 format uses indexed triangle lists. The animation is encoded as keyframes, much like you’d do when drawing an animated cartoon. The keyframes are set apart by some time span. To get smooth animation we have to interpolate between two keyframes to arrive at the current vertex list. The above code does just that.

I have yet to try it on my Hero, but i suspect it just doesn’t have the horsepower. Neither the CPU nor the GPU will be able to handle this “massive” set of vertices/triangles. Just drop me a line if you want the full code.

One thought on “MD2 for the win

  1. Dear BadLogic Games,

    Does this render utilize the GPU’s parallel processing power
    when fixed point performance is measured? Would I be able to see the full code for this blog “md2 for the win 03feb10”?

    I’m an Engineering student at University of Manitoba. I’m working on a side-hobby project that might need to measure the Flops performance of a mobile device (particually the performance of the GPU of the mobile device when does some parallel computing work). I think it’s something very similar to what you’re working on here.

    I’m a complete noob at this performance benchmarking field for mobile though. It’s something that I’ve recently wanted to look at as a hobby but never got around to it until now. Your codes would greatly help me understand better, and I’d truly appreciate your help very much.

    Thanks so much in advance!

Leave a Reply

Your email address will not be published.