Remember my last post about deciding whether to use Direct3D or OpenGL? I have spent a lot of time this week researching the APIs, reading analyses by game developers, and listening to the little voices inside my head. I have since reached several conclusions:
I retract my previous statement which implied there was anything redeeming whatsoever about Direct3D. Retained mode is for wusses -- I wrote a partial Lightwave LWO renderer in two days and it wasn't hard at all. And software rendering??? Does that even work anymore? So please (sob) forgive my impudence. Viva la OpenGL!
The Mighty Quaternion
One thing that is certain when you're making a physics-heavy 3D game: lots of math. That third dimension really adds lots of evil to your code. Things like tensors, quaternions, skew-symmetric matrices plague your sleep. This week I have been struggling with an evil four-dimensional beast named The Mighty Quaternion.
For those who aren't yet part of the 4-D jetset, quaternions are ways of representing the orientation (rotation) of an object in 3D space. They are robust (they don't suffer from singularities), versatile (they perform lots of different functions with computational ease) and are commonly used in spacecraft attitude control systems, so I figure they're good enough for a game.
One bad thing about quaternions is that it's sometimes hard to find information that helps you apply them to games. So for your safety and convenience, I have put up a page of links related to quaternions and dynamics here. I'll also be adding more over the coming months. Share and enjoy.
The Java development is going well. I am quite comfy using FreeBSD and JDK 1.2 for editing and compiling (good old javac) and my Win98 box to run programs. My Win98 box crashes 3-4 times per day, and I would like to "sidegrade" to Win2000, but I hear it doesn't support OpenGL for the TNT2 yet. Sigh. I am considering getting a Linux box and using Mesa, but I'd really rather use a commercial OpenGL implementation to develop under.
I'm surprised at how fast it goes! I'm doing neato-skeeto things with dynamic LOD tesselation and it usually maintains 10-30 FPS. And the code is disgustingly UN-optimized -- I'm using double precision floats everywhere. But using display lists helps even out Java's performance disadvantage a lot. Shoot, I could probably release the final game in Java, if it wasn't such a memory pig.
I also found a public-domain version of the Java3D vecmath classes. Java3D sucks, but it has a very nice collection of vector, matrix, and quaternion routines. Reuse rocks! Having these classes, and Java's hashtables, lists, and sets make development a lot easier. I will probably write my own versions of these classes in C++ when I go to port, because I despise STL.
Well, I'd better get back to coding. I hope to have a screenshot at some point, but I want to wait until I really get cooking on graphics and have something impressive. For now I'm trying to do just enough graphics to see what my physics is up to. You know, you really can't easily debug physics routines by println()'ing a bunch of vectors! ;-)