Initializing the world
The Loader class is used to initialize the world. It has two static methods: one takes in a
byte array, while the other takes a named resource, such as a URI or an individual file in
the JAR package.
load
The
The following example calls Loader.load() and passes it an M3G file from the JAR file
using a property in the JAD file. Alternatively, you could specify a URI, for example:
Object3D[] roots =
Loader.load(http://www.example.com/m3g/simple.m3g)[0]);
The example assumes that there is only one root node in the scene, which will be the
world object. If the M3G file has multiple root nodes the code must be changed to reflect
this, but generally most M3G files have a single root node.
public void startApp() throws MIDletStateChangeException
{
myDisplay.setCurrent(myCanvas);
try
{
// Load a file.
Figure 5 Typical MIDlet Structure
methods return an array of Object3Ds that are the root level objects in the file.
65