Java Reference
In-Depth Information
blueGreenMaterial.setColor(Material.DIFFUSE, 0xFF876A56);
blueGreenMaterial.setColor(Material.SPECULAR, 0x0000a0a0);
// initialize
trOrbitingPlanetoid = new Transform();
trBigRemoteBlueGreen = new Transform();
trOrbitingPlanetoid.postTranslate(-40.0f, 0.0f, -10.0f);
float bigScale = 100.0f;
trBigRemoteBlueGreen.postTranslate(100.0f, 200.0f, -800.0f);
Once everything is loaded and initialized, it is time to draw. The M3G
model is analogous to that of the SVG model. Firstly we bind our standard
MIDP Graphics context to the static instance of the Graphics3D class
from JSR-184. Since we are in immediate mode we need to set up our
camera each time we draw, execute a series of graphics commands and
then release our graphics context.
private void draw3D(Graphics g) {
try g3d = Graphics3D.getInstance();
g3d.bindTarget(g, true, Graphics3D.ANTIALIAS |
Graphics3D.TRUE_COLOR |
g3d.setCamera(camera, gameEngine.getPlayerLocation());
} catch(Exception e) {
} finally {
The Graphics3D class has a number of render() method overloads,
the most useful being the one that takes a Node and a Transform as
parameters. This allows us to use the technique outlined above simply
by changing the mesh material and supplying a different transform to the
render() method.
private void drawUniverse() {
// move the small orbiting planetoid
trOrbitingPlanetoid.postTranslate(-1.0f, 0.0f, 0.0f);
trOrbitingPlanetoid.postRotate(-1.0f, 0.0f, 1.0f, -0.6f);
// draw the planetoid
Search WWH ::

Custom Search