3D Libraries

I was hoping to not have to write this post.  I did a fair shake of research on which 3D library I wanted to use, I purchased books, I subsequently read some of those books and parts of other ones, I cleaned my office and found an old book I had sitting around…  And that’s where everything kind of went to crap.

My initial research brought me to the doorstep of JavaFX 8.  There were lots of reasons for this, but the one that I found the most compelling was actually that it was simply “built in” to Java 8.  No extra .jar files, no extra licenses to worry about, just 3D as brought to you by the makers of Java.  It honestly seemed perfect.  This is where I bought books on it and started reading them.

The book that I found buried in my office and that I’m now reading my way through is a book all about the math behind 3D.  A wonderful book on everything from vectors and matrix math to triangle meshes and occlusion.  The side effect of all this delicious learning is that I started to ask questions about how things worked in JavaFX and that’s unfortunately when the cracks started to show.  Each time I read about some other 3D math thing, I learned that it was only partially present in JavaFX.  What I mean by this is that I’m sure it was there and being used under the covers, but it was totally hidden from me.  What I was discovering rather quickly was that JavaFX is likely simply too high level for what I needed.

After a bit more reading, lots of coding that was well below the level of getting pretty 3D things on the screen, and conversations with friends, I started to worry a little that I was heading down the wrong path.  Fortunately, at this point in the project that path was very fixable.  All I’d manage to get on the screen with JavaFX was a single textured block.  Sure, it was a rather pretty block, but it was only one block of the roughly 236,118,324,143,482,260,684,800,000 I was expecting each world to possibly contain.  (If you were running on a server with unlimited storage anyway.)

qk_geometry_practice001

This in turn led me to ask Google “Java 3D Libraries” and to find repeatedly that if you want to code with full access to the 3D power available in a machine, you pretty much use LWJGL (“Lightweight Java Game Library”).  This change comes with a couple of interesting problems for me.  First and foremost it means I have to learn a LOT more about working with 3D libraries.  JavaFX is a very high level scene graph style 3D engine.  Everything is well hidden from you, so you just tell it where things go in the scene and cross your fingers.  In LWJGL, if you want it to happen, you have to tell it how to do it.  There aren’t magical high level concepts available to help you out.  Part of me sees this as a challenge, and the other part is genuinely afraid that this could be what stops this project in its tracks.

At this point, the next step is to download LWJGL and start trying to figure out how to use it.  To that end, my goal is to get essentially the same picture you see above to happen using LWJGL instead of JavaFX as shown there.  Wish me luck.