Specifications
Developers guidelines | 3D graphics with Java ME
33 June 2010
Effect3D effect;
effect.setLight( light );
Note that other attributes could be added to the instance of effect, such as shading
types and whether color transparency is enabled or not.
Initialise the graphics environment, render the model, and
display it
With the Figure and many of its attributes prepared, it should be rendered and
displayed. The Graphics3D class is used for this, since it contains all of the rendering
methods. However, first the output of this class must be “bound” to a LCDUI
Graphics object so that the final results appear on screen. Then the scene is drawn,
and finally the Graphics3D instance is released. The following code shows how this is
done:
Graphics3D g3d = new Graphics3D();
Graphics g;
// Bind the 3D graphics context to the MIDP Graphics object.
g3d.bind(g);
try {
g3d.renderFigure( figure, 80, 100, layout, effect );
g3d.flush(); // Draw the rendered figure on-screen
} catch( Exception e ) {}
// Release the MIDP Graphics object.
g3d.release( g );
Note how the renderFigure() method allows a model (figure) to be supplied
along with its layout information (layout), and any special effects (effect). These
attributes are applied to the Figure during the rendering process. The flush()
method pushes the generated pixels onto the screen.