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 sub-directory of your jME3
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 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:
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 aModelName.material
, plus (optionally)ModelName.skeleton.xml
, and some JPG files.Open the menu
to open the exporter dialog.
In the
File Path
field: Select a target sub-directory of yourProject Assets/Textures/
directory. E.g.Project Assets/Textures/ModelName/
. See Best Practices.In the panel at the bottom left of the export window toggle the following export settings:
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
Open the
UV Image Editor
,Material Tab
orTexture Tab
.Select the Browse button located next to the material, texture or UV Image name to load the item to be cleared.
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.Save your file.
From the
Info
header select, 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
In the
Dope Sheet Editor
, change the context toAction Editor
.Click the
Action to be linked
button and select the action you want cleared.Deselect the F button to prevent it from saving.
Change the editor type from
Dope Sheet
toNLA Editor
. You will see the action listed.Click the Double Down Arrow button next to the action to push it into the stack.
Click the small start next to the track name.
With the mouse inside the
NLA Track List
, press X to delete both the track and strip.Save your file.
From the
Info
header, select.
Save your file again.
From the
Info
header, selectagain.
Change back to the
Dope Sheet Editor
.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.
Save your file.