
JOGL-ES Chapter 1. Rotating Boxes

From:
  Pro Java 6 3D Game Development 

  Dr. Andrew Davison
  Dept. of Computer Engineering
  Prince of Songkla University
  Hat Yai, Songkhla 90112, Thailand
  E-mail: ad@fivedots.coe.psu.ac.th

  Web Site for the book: http://fivedots.coe.psu.ac.th/~ad/jg2/


If you use this code, please mention my name, and include a link
to the book's Web site.

**NOTE**: this example is NOT in the hardcopy book printed by Apress.

Thanks,
  Andrew


============================
RotBoxES

A simple JOGL-ES example showing two rotating boxes moving over a
floor. The user can navigate through the scene by moving and
rotating the camera.


RotBoxES requires the Java Bindings for OpenGL ES (JSR 239) API which
is available in version 2.5. of the Java ME Wirelss Toolkit (WTK 2.5).
It can be downloaded from 
http://java.sun.com/products/sjwtoolkit/

------
Files in the Download

RotBoxES consists of 6 Java files in the src\ subdirectory:
  RotBoxES.java, RotBoxGameCanvas.java,
  KeyCamera.java, Camera.java,               
  Floor.java, TexCube.java

9 image files in the res\ directory
  bigGrid.png, brick.png, brick2.png,
  cloth.png, floor.png, grass.png, metal.png,
  rock.png, wood.png

Only three of them are used in the code:
  * bigGrid.png  (for the floor)
  * brick2.png and wood.png  (for the cubes)

The others can be tried out by modifying the filenames used
in createScenery() in RotBoxGameCanvas


------
Compilation and Execution (using WTK 2.5)

Create a new project called RotBoxES, with the MIDlet
class name RotBoxES.

In the "API Selection" window, select the radio box
for "Java Bindings for OpenGL ES (JSR 239)" which is
located in the "Additional APIs" section

Copy the Java files in src\ to WTK25\apps\RotBoxES\src\ 

Copy the PNG files in res\ to WTK25\apps\RotBoxES\res\

Build and run.

-----------
Using the Camera

The camera position is moved by pressing the arrow keys. The
camera can be switched between three modes (move, rotate, 
and glide/float) by pressing the game-A key. The camera's
position and orientation is rest by pressing the select/enter
key.

---------
Updates: 27th April 2007

Mostly code reorganization, and more error checking.

RotBoxGameCanvas.java:
  - made isRunning volatile
  - changed PERIOD (200 --> 220)
  - changed initGraphics() to test JOGL-ES functions
    and return a boolean
  - initGraphics(): changed depth size in config attributes to 16 (was 32);
                    addedsurface type attribute
  - createScenery(): added backface culling; 
                     removed texture enabling
  - call to setView() uses near/far plane values 0.1/50 (was 1/100)

TexCube.java:
  - moved client enabling to drawCube() from constructor
  - drawCube(): enables and disables the client state;
                enables/disables txeturing

Floor.java:
  - moved client enabling to draw() from constructor
  - draw(): enables and disables the client state;
            enables/disables txeturing

---------
Last updated: 27th April 2007
