3D Game Engine

Screenshot of TreasureHunt with a MilkShape 3D model loaded

(click to zoom)

FutureEngine is a flexible, scene graph based 3D game engine. The current implementation is written in Java with support for OpenGL rendering. The game engine supports a scene graph, view frustum culling, and renders MilkShape 3D models. To test the game engine, I built a simple “treasure hunt” type game. The objective is to fly around the game world picking up treasures that spawn in random locations. The screenshot shows several “treasures” and two sample MilkShape 3D models.

Source Code: GitHub

Technologies Used: Java, OpenGL, JOGL, Swing

Tools Used: Eclipse IDE, MilkShape 3D, Terragen, freesound.org

Features:

  • Full screen or windowed mode (windowed mode shown)
  • 3D camera with strafe, yaw, and pitch operations
  • Support for multiple types of renderers
  • Built-in implementation of a JOGL renderer
  • Rectangular SkyBox with six textures
  • Hierarchical scene graph with Group and Leaf objects
  • Support for multiple types of bounding volumes
  • View frustum culling via bounding spheres
  • Support for any type of game update/rendering loop (i.e. fixed frame rate, dynamic)
  • Built-in implementation of a fixed frame rate rendering loop
  • Multiple rendering queues for the scene graph (orthographic, opaque, and transparent)
  • Loading and rendering of MilkShape 3D models (.ms3d files)
  • Controllers can be attached to a scene node to alter behavior
  • Built-in controllers for y-axis rotation and z-axis oscillation

Code Snippet:

[java]private void getFrustumPlanes(GL gl)
{
DoubleBuffer proj = DoubleBuffer.allocate(16);
gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, proj);
DoubleBuffer modelView = DoubleBuffer.allocate(16);
gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, modelView);
Matrix3D p = new Matrix3D(proj.array());
Matrix3D mv = new Matrix3D(modelView.array());
p.concatenate(mv);
double[] pm = p.getValues();
Plane[] planes = new Plane[6];
planes[0] = new Plane(pm[3] + pm[0], pm[7] + pm[4], pm[11] + pm[8], pm[15] + pm[12]);
planes[1] = new Plane(pm[3] – pm[0], pm[7] – pm[4], pm[11] – pm[8], pm[15] – pm[12]);
planes[2] = new Plane(pm[3] + pm[1], pm[7] + pm[5], pm[11] + pm[9], pm[15] + pm[13]);
planes[3] = new Plane(pm[3] – pm[1], pm[7] – pm[5], pm[11] – pm[9], pm[15] – pm[13]);
planes[4] = new Plane(pm[3] + pm[2], pm[7] + pm[6], pm[11] + pm[10], pm[15] + pm[14]);
planes[5] = new Plane(pm[3] – pm[2], pm[7] – pm[6], pm[11] – pm[10], pm[15] – pm[14]);
myCamera.setFrustrumPlanes(planes);
}[/java]