Using Models and Scenes with jME3
To use 3D models in a jME3 application:
-
Export the 3D model in Ogre XML or Wavefront OBJ format. Export Scenes as Ogre DotScene format.
-
Save the files into a subdirectory of your jME3 project’s
assets
directory. -
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 aplication 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.
Tip: 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:
-
Open the menu File > Export > OgreXML Exporter to open the exporter dialog.
-
In the Export Materials field: Give the material the same name as the model. For example, the model
something.mesh.xml
goes withsomething.material
, plus (optionally)something.skeleton.xml
, and some JPG files. -
In the Export Meshes field: Select a target subdirectory of your
assets/Models/
directory. E.g.assets/Models/something/
. -
Activate the following exporter settings:
-
Copy Textures: YES
-
Rendering Materials: YES
-
Flip Axis: YES
-
Require Materials: YES
-
Skeleton name follows mesh: YES
-
-
Click export.
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.