Back to Joe's Java Index Back to 3D Graphics Index.


Virtual Sphere Example

 

I have written a small Java program that demonstrates how to use a "Virtual Sphere" for intuitive 3D rotation using a 2D input device (the mouse in this case). The virtual sphere is an imaginary sphere located in your model space that you rotate using your mouse. The amount of rotation is not a linear function of mouse motion, but rather, the mouse points are mapped onto a sphere and the rotation angles are determined from that. Some people call this a "virtual track ball" or "cue ball" interface.

I have modified an existing OpenGL demo program called "gears" for the purpose of illustrating the virtual sphere. I replaced the simple user interface implementation in gears with a virtual track ball implementation. Here is an image that illustrates what I am talking about. It shows me rotating the gears model using my mouse. The virtual sphere's screen feedback is shown by the gray circle and cross-hairs. You rotate the model by just "grabbing" the virtual sphere and rotating it.

Virtual Sphere at work

This demo program uses JOGL in order to directly access OpenGL. This gives the Java program fairly respectable rendering performance. You will need to download and install the JOGL libraries in order to compile the program on your machine (the MacOS X program has the JOGL libraries built in).

This program is available as an executable for MacOS X. You can also download the source code to the program and compile it for your platform.

MacOS Application (1.1MB)

November 28, 2004

Java application, as a compressed disk image, that will run under MacOS X 10.3 or later. Includes the full source code.

Source Code (20k)

November 28, 2004

The full source code for this program. Requires Java 1.4.2 or later.  You will need to download the JOGL jar file and native JNI library yourself from:  https://jogl.dev.java.net/

Change history.

 Need help?


Created: February 20, 2001
Modified: November 28, 2004