JOGL Sandbox Environment Tutorial Series
Introduction
This tutorial mini-series aims to cover a range of related 3D graphics topics, from 3D model loading, camera control and scene navigation to GLSL shader management.
Hopefully this sandbox environment will give you a basic project setup for you to tweak and test your own ideas quickly in JOGL, as well as help you understand the various bits of code needed to get a basic 3D environment running.
It is safe to say that the material herein is more complicated than the previous introductory tutorials, so be aware of this when viewing the code.
Class Structure
I recommend downloading the Eclipse Project Folder, as it contains all the source code, and loading it into Eclipse. Remember to link your JOGL 2 user library, as shown in the Setting Up JOGL 2 Tutorial.
Camera
The camera class implements a full 6 degrees of freedom camera for viewing the scene. It uses Quaternions to represent various rotations.
Engine
This is the primary class, it contains the logic for the sandbox, as well as the main rendering aspects, including scene initialization.
OBJModel
This class handles the loading and parsing of the Wavefront .obj models and also deals with rendering the model data. The current implementation supports normals, however requires that the .obj models be triangulated (so no quad support currently).
Player
The player class represents the player in the scene, and has an associated OBJModel which is rendered according to the players position.
Quaternion
The camera implemented in this sandbox allows for 6 degrees of freedom, and thus needs to use Quaternions to get around gimble-lock.
ShaderControl
This class takes care of the loading, compiling and linking of the GLSL shaders, and provides a useful way of activating and deactivating various shaders by simply calling the 'useShader' and 'dontUseShader' methods.
TrackBall
This is a TrackBall object which allows us to view an object from any angle, and rotate around the object using only the mouse. It also uses Quaternions and combined with the camera class it allows us a great degree of freedom when viewing our player models.
Drawable
This is just a stub class at the moment, in the hopes that in future implementations we may have more than just 'players' which could all inherit a single Drawable super class.
As the mini-series progresses, I will add links to the source files here, along with more detailed explanations of each class and various improvements to be made. We will also be using this sandbox environment to test some GLSL shaders, which will likely be covered in separate tutorials.