Specifications
Developers guidelines | 3D graphics with Java ME
32 June 2010
// Associate the action table with this object
figure.setPosture ( action, 0, 1 );
The arguments to the setPosture() method associate the action table action with
figure. The animation starts with the first frame of the model and the first action
command from the table.
Set up the camera
By positioning the viewing camera, the point of view of the scene has been set up. To
set up the camera viewing angle vectors:
Vector3D position = new Vector3D( 0, 100, 256 );
Vector3D look = new Vector3D( 0, -2048, -4096 );
Vector3D up = new Vector3D( 0, 4096, 0 );
AffineTrans trans = new AffineTrans();
trans.lookAt( position, look, up );
These operations create vectors, then feed them to a special AffineTrans method,
lookat(). This method applies the supplied vectors to matrix transformations and
generates the scene geometry from the specified point of view.
Besides specifying the viewing angle, other attributes need to be associated with the
3D object. The FigureLayout class acts as a container for certain figure attributes,
such as the Figure point of view (POV) transform, plus scaling, position data, and
perspective type. The FigureLayout instance is initialised as follows:
FigureLayout layout; // Make an instance
// Set the distance between the 3D model and the camera.
layout.setPerspective( 1, 4096, 512 );
// Set where the camera's center is positioned in the display.
layout.setCenter( 128, 128 );
// Set the camera angle using the supplied parameters.
layout.setAffineTrans( trans );
With the layout set up, the scene lighting is adjusted.
Set up light and any effects
A Micro3D Ver.3 scene has two lights: a spotlight and an ambient light. Both are white,
so no color descriptions are possible. The following code sets up a direction vector for
the spotlight, and configures the intensity of the two lights:
Vector3D lightDirVec = new Vector3D( -146, 293 439 );
int lightDir = 3730;
int lightAmbient = 1626;
// Make instance of Light from the prepared parameters
Light light = new Light( lightDirVec, lightDir, lightAmbient );
These light characteristics are added to an instance of Effect3D: