Motorola maxx V6 Draft Subject to Change 106/201, Interrogating and interacting with Objects

Models: maxx V6

1 201
Download 201 pages 31.32 Kb
Page 106
Image 106

Java ME Developer Guide

Chapter 13 - JSR-184 - Mobile 3D Graphics API

{

myG3D.render(myWorld);

}

finally

{

myG3D.releaseTarget();

}

}

}

Code Sample 5 Using the Graphics3D object

The final block makes sure that the target is released and the Graphics3D can be re- used. The bindTarget call must be outside the try block, as it can throw exceptions that will cause releaseTarget to be called when a target has not been bound, and re- leaseTarget throwing an exception.

13.4.5Interrogating and interacting with

objects

The World object is a container that sits at the top of the hierarchy of objects that form the scene graph. You can find particular objects within the scene very simply by calling find() with an ID. find() returns a reference to the object which has been as- signed that ID in the authoring tool (or manually assigned from code). This is im- portant because it largely makes the application logic independent of the detailed structure of the scene.

final int PERSON_OBJECT_ID = 339929883;

Node personNode = (Node)theWorld.find(PERSON_OBJECT_ID);

Code Sample 6 Finding objects by ID.

If you need to find many objects, or you don't have a fixed ID, then you can follow the hierarchy explicitly using the Object3D.getReferences() or Group.getChild() methods.

DRAFT - Subject to Change [106/201]

Page 106
Image 106
Motorola maxx V6 manual Draft Subject to Change 106/201, Interrogating and interacting with Objects