Monday, 30 May 2011

3D Plotting in Java (Ubuntu with JOGL and jzy3d)

A quick google search and StackOverflow check revealed two appropriate Java packages for displaying surface plots.  One uses OpenGL, and the other does not.  Since I want maximal functionality for verifying the data visually, I'm going with the OpenGL implementation.

Originally, I tried building the library myself, but the resulting jars didn't seem to contain the correct class information (or they were broken, though the build was successful).  Some links related to this method are found below.

In ubuntu, open synaptic and install this package (as instucted in http://ubuntuforums.org/showthread.php?t=1670765):
libjogl-java
This will add two libraries to your /usr/share/java directory, namely jogl.jar and gluegen-rt.jar.  In eclipse, add these libraries to your build path, then associate the native libraries (which were also automatically installed with libjogl-java) with those jars.  I found out (from http://forum.worldwindcentral.com/archive/index.php?t-21608.html) that these libraries are stored in /usr/lib/jni.  Specify that path as the native library path in Eclipse.

Then you can add the jzy3d jar to your class and you can start drawing with the tutorials found here:


You'll also need the syntax for drawing the Chart objects from jzy3d in AWT/Swing containers:

http://code.google.com/p/jzy3d/wiki/EmbeddingChartInAnExistingApplication





"Conventional Setup"?  Didn't Work

Ultimately I ended up with a NoClassDefFound so it doesn't seem to contain the classes necessary (wrong version?)

Following these instructions:
http://jogamp.org/jogl/doc/HowToBuild.html

http://code.google.com/p/jzy3d

https://launchpad.net/ubuntu/maverick/i386/ant/1.8.0-4
https://launchpad.net/ubuntu/maverick/i386/ant-optional/1.8.0-4

https://github.com/sgothel/gluegen
https://github.com/sgothel/jogl

git clone https://github.com/sgothel/gluegen.git gluegen
git clone https://github.com/sgothel/jogl.git jogl

cd jogl/make
ant



2 comments:

  1. Thank you very much : )

    ReplyDelete
  2. I'm glad this was helpful! This solution will probably be version-specific: I was using Ubuntu 10.04 at the time.

    ReplyDelete