Motorola E680 - Smartphone - GSM Developer's Manual page 35

Micro edition (j2me) applications
Hide thumbs Also See for E680 - Smartphone - GSM:
Table of Contents

Advertisement

9
JSR 184
}
The finally block makes sure that the target is released and the Graphics3D can be
reused. 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
releaseTarget throwing an exception.
Interrogating 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 assigned that ID in the
authoring tool (or manually assigned from code). This is important 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);
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.
static void traverseDescendants(Object3D obj)
{
int numReferences = obj.getReferences(null);
if (numReferences > 0)
{
Object3D[] objArray = new Object3D[numReferences];
obj.getReferences(objArray);
for (int i = 0; i < numReferences; i++)
}
}
Once you have an object, most of the properties on it can be modified using the M3G API.
For example, you can change the position, size, orientation, color, brightness, or whatever
other attribute of the object is important. You can also create and delete objects and insert
them into the world, or link parts of other M3G files into the scene graph.
35
traverseDescendants(objArray[i]);

Advertisement

Table of Contents
loading

Table of Contents