3D Cube Engine - Java

java

This is a recent project of mine for building 3D puzzle games, (like Rubik's Cubes).

While the code could be optimized quite a bit, this is mainly for those who wish to better understand concepts of 3D programming. For example, one way to create, store, and manipulate a 3D polygon, whether it be a Cube, or an ellipsoid. This project contains code and algorithm's to rotate 3D polygons, around the origin, and themselves. Ability to draw 3D objects in order of increasing Z-values. Draw wireframe or solid color polygons. Keyboard and Mouse controls to move and alter the Polygons. It is a work in progress and not intended for use in graphic intensive games.

Note: later I will add rotateAroundVector() for more general rotation Note: Ellipse3D is still very primitive but demonstrates one method creating an ellipsoid Note: Not all Jar files contain the same versions of code. Each Jar file contains code specific to what it is supposed to do.

All source code can be found in the JAR files Downloadable Jars (simple to complex):

  1. RenderWiredCubes3D-demo.jar: this code rotates 4 rotating cubes about the origin.
  2. RenderPolygons3D-demo.jar: this code demonstrates various ellipsoids and cubes rotating around unique axises.
  3. Cubes3D-demo.jar: this code demonstrates more of the functionality of the 3D Cube engine by creating a Rubik's cube like look and feel. Controls
  • Mouse: click and drag the cube
  • A - reset
  • S - toggle between solid and non-solid mode. (i.e. the inside is filled with cubes or not)
  • D - randomly select an internally defined color scheme
  • F - toggle between random rotate mode. Just try it :)
  • Q - Decrease space between pieces
  • W - Increase space between pieces
  • E - Decrease size of cubes
  • R - Increase size of cubes
  • T - Decrease dimensions. i.e. 4x4x4 -> 3x3x3
  • Y - Increase dimensions. i.e. 4x4x4 -> 5x5x5 (not that if solid mode is true, then it will render slower
  • Arrows - Translate the cubes across the screen

If you're only interested in the Transformation algorithms, check the below link: Graph4D - demonstrates methods and actual source code for rotating a 4D vector. Graph3D - demonstrates methods and actual source code for rotating a 3D vector.