So after the successful test of HyperUtils and the decision to slow development on it, I went on to begin my statistical analysis toolkit. I knew that I wanted to separate the view from the data model, more than just by modules, but actually using what I felt was the best tool for the job. I ended up deciding to use java backed by JOGL as a visualization platform. The first step was to set up the JOGL testing harness. This seemed easy enough, although my OpenGL was a little rusty I was able to quickly get back into the feel of the API. JOGL uses such a minimalist approach in wrapping OpenGL that it feels just like talking to the C++ API. I quickly implemented an extremely basic scene graph and began working on a camera for traversing the visualizations. Unfortunately, I was having an issue where every graph node that I rendered was translated correctly relative to its parent, but the scene root was always stuck to the camera! My code was so simple that I spent two days trying to figure out what the problem was. I checked and rechecked my matrix math, my hierarchy flattening code, and verified I was using the right matrix format (column vs row major). All of this turned up no errors! Disheartened, I scoured the internet and found that JOGL has practically no documentation. I downloaded and looked at example code, but nobody else was setting transforms directly (glLoadMatrixf) or if they were, they were not using any sort of a hierarchy. I was at my wits end when I found a link that pointed to a book my bosses wrote,
Practical Java Game Programming. This link reminded me that I had a copy of the book on my shelf, so I began flipping through the chapters. Lo and behold, there it was, a chapter on JOGL! With a few pages I found the magic fact that I had been missing (p.388):
The glPushMatrix function duplicates the current matrix and then pushes that matrix onto the stack.
That was it! I had been assuming that the matrix stack was "flattened" intrinsically. Because of this faulty assumption, I was overwriting my camera transform with each rendered object's world matrix. After learning that I was quickly able to fix the issue!
The next goal is to build the first piece of the statistical analysis toolkit using (as portable as possible) C++ code and using the
Java Native Interface (JNI) to link it with my visualization framework.
--Dahlgren
2 comments:
Damn you are smart.
Hardly! I wouldn't have been hung up by such a silly assumption... hahaha
Post a Comment