Models and Scenes

Like Shapes, 3D models are also made up of Meshes, but models are more complex than Shapes. While Shapes are built into jME3, you typically create models in external 3D Mesh Editors.

Using Models and Scenes with jME3

To use 3D models in a jME3 application:

  1. Export the 3D model in Ogre XML or Wavefront OBJ format. Export Scenes as Ogre DotScene format.
  2. Save the files into a subdirectory of your jME3 project's assets directory.
  3. In your code, you use the Asset Manager to load models as Spatials into a jME application.
    Spatial model = assetManager.loadModel(
        "Models/MonkeyHead/MonkeyHead.mesh.xml" );
  4. (For the release build:) Use the jMonkeyPlatform to convert models to .j3o format. You don't need this step as long you still develop and test the aplication within the jMonkeyPlatform.

Creating Models and Scenes

To create 3D models and scenes, you need a 3D Mesh Editor such as Blender, with an OgreXML Exporter plugin.

Tip: Consider creating UV textures for more complex models, it looks more professional.

3D mesh editors are third-party products, so please consult their documentation for instructions how to use them. Here is an example workflow for Blender users:

To export your models as Ogre XML meshes with materials:

  1. Open the menu File > Export > OgreXML Exporter to open the exporter dialog.
  2. In the Export Materials field: Give the material the same name as the model. For example, the model something.mesh.xml goes with something.material, plus (optionally) something.skeleton.xml, and some JPG files.
  3. In the Export Meshes field: Select a target subdirectory of your assets/Models/ directory. E.g. assets/Models/something/.
  4. Activate the following exporter settings:
    • Copy Textures: YES
    • Rendering Materials: YES
    • Flip Axis: YES
    • Require Materials: YES
    • Skeleton name follows mesh: YES
  5. Click export.

You can now use the jMonkeyPlatform to load and view models. You can create scenes from them and write cde that loads them into your application.

view online version