Q1. If you know the ID of the Mesh
(MESH_ID
), then:
try {
Object3D[] roots = Loader.load( "http://www.example.com/scene.m3g" );
World world = roots[0];
Mesh mesh = world.find( MESH_ID );
}
catch( Exception e ) {
// Handle it
}
Q2. Load a basic World
:
public class MyCanvas extends Canvas
Graphics3D g3d;
World world;
int currentTime = 0;
public MyCanvas() {
g3d = Graphics3D.create();
Object root[] = Loader.load("world.m3g");
world = root[0];
}
protected void paint(Graphics g) {
g3d.bindTarget(g);
world.animate(currentTime);
currentTime += 50;
g3d.render(world);
g3d.releaseTarget();
}
}
Then use the API to create and add more objects into the world The API documentation covers this in depth:
Q3. Assign them in Blender, then use the find
method to get the exact instance of Object3D
you need.
Q4. If you plan on reusing meshes (for different applications), organize them into separate files, load them separately during initialization of an application, and then insert them into the world.