Time for action – loading a model (just testing)

The 3D model is ready for its journey into the 3D game world. Switch over to your BasicGame project in the jMonkeyEngine SDK again.

  1. Make a copy of Main.java and name the class LoadModel.java. Remember to also refactor the first line of the main() method to:
    LoadModel app = new LoadModel ();
  2. Replace the simpleInitApp() method with the following code snippet:
    public void simpleInitApp() {
      Spatial mymodel = assetManager.loadModel(
          "Textures/MyModel/mymodel.mesh.xml"); 
      rootNode.attachChild(mymodel);
      DirectionalLight sun = new DirectionalLight();
      sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)));
      sun.setColor(ColorRGBA.White);
      rootNode.addLight(sun); 
    }

Since the load() method returns both nodes and geometries, ...

Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.