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 sub-directory of your jME3 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" );

(For the release build:) Use the jMonkeyEngine SDK to convert models to .j3o format. You don’t need this step as long you still develop and test the application within the jMonkeyEngine SDK.

Creating Models and Scenes

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

Learn how to create UV textures for more complex models, it looks more professional.

3D model 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. jMonkeyEngine requires a material file to be named the same name as the model so prior to opening the export dialog make it so. The model will export files named ModelName.mesh.xml with a ModelName.material, plus (optionally) ModelName.skeleton.xml, and some JPG files.

  2. Open the menu File ▸ Export ▸ Ogre3D to open the exporter dialog.

  3. In the File Path field: Select a target sub-directory of your Project Assets/Textures/ directory. E.g. Project Assets/Textures/ModelName/. See Best Practices.

  4. In the panel at the bottom left of the export window toggle the following export settings:

    • Swap Axis: xz-y

    • Separate materials

    • Only Deformable Bones [1]

    • Export Scene [2]

    • Export Selected Only [3]

    • Export Meshes

    • Export Meshes Overwrite [4]

    • Armature Animation [5]

    • Trim Weights [6]

    • Export Materials

  5. Click Export Ogre.

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

Blender Buffer Clearing

Before exporting your Blender models, its is recommended that you clean the buffers of any unneeded Action, Material, Texture or UV Image. This is a straight forward process that only takes a few minutes. Failure to do so can lead you into a morass of problems, like having more than one AnimControl, duplicate materials and textures, wasted space from worthless images, just to mention a few potential troubles.

Clearing Blender Material, Texture, UV Image Buffers
  1. Open the UV Image Editor, Material Tab or Texture Tab.

  2. Select the Browse button located next to the material, texture or UV Image name to load the item to be cleared.

  3. While holding Shift down, click the X button, also known as the Unlink datablock button, located next to the loaded item. An item that is unlinked will show a 0 before it when viewed by selecting the Browse button and will not be saved if you exit Blender.

  4. Save your file.

  5. From the Info header select File ▸ Open Recent ▸ Your Saved File, to close and re-open your file.

The exception to this rule is the Linked Action buffer, for animations, located in the Dope Sheet Editor.

Clearing The Linked Action Buffer
  1. In the Dope Sheet Editor, change the context to Action Editor.

  2. Click the Action to be linked button and select the action you want cleared.

  3. Deselect the F button to prevent it from saving.

  4. Change the editor type from Dope Sheet to NLA Editor. You will see the action listed.

  5. Click the Double Down Arrow button next to the action to push it into the stack.

  6. Click the small start next to the track name.

  7. With the mouse inside the NLA Track List,  press X to delete both the track and strip.

  8. Save your file.

  9. From the Info header, select File ▸ Open Recent ▸ Your Saved File.

  10. Save your file again.

  11. From the Info header, select File ▸ Open Recent ▸ Your Saved File again.

  12. Change back to the Dope Sheet Editor.

  13. Click the Browse Action to be linked button and you will see only the baked action remains and the buffer is now clear of unwanted actions. Select your action.

  14. Save your file.

1. Optional: If selected, and you have an Armature with the model, only the deform bones are exported.
2. Toggle this to export your model in DotScene format
3. Optional: If selected, you manually choose each object you want exported prior to opening the export dialog.
4. Optional: If selected, it will overwrite the existing files in the target directory
5. Optional: Only used if the model contains an armature.
6. Occasionally when exporting you may get a warning complaining about vertices weighted to too many bones. You are then asked to try increasing the trim weights option. Slightly increase this spinner and try exporting again. Repeat the process until the warning goes away.