jMonkeyPlatform: Importing and Viewing Models

JMonkeyPlatform imports models from your project and stores them in the assets folder. The imported models are converted to a jME3 compatible binary format called .j3o. Double-click .j3o files in the jMonkeyPlatform to display them in the SceneViewer, or load them in-game using the AssetManager.

Presently, Blender 3D is the preferred modelling tool for jME3 as it is also Open-Source Software and an exporter for OgreXML files exists. Note that the OgreXML exporter is not yet compatible with Blender 2.5alpha!

Also, see this demo video on importing models.

Installing the OgreXML Exporter in Blender

jMonkeyPlatform includes a tool to install the correct exporter tools in Blender to export OgreXML files. To install the exporter, do the following:

  1. Select "Tools"→"OgreXML"→"Install Blender OgreXML" in the jMonkeyPlatform Menu
  2. If you are presented a filechooser, select the folder where your blender scripts reside
  3. Press "Install" in the window that opens

Importing and Viewing a Model

Using the Model Importer Tool

jMonkeyPlatform includes a model importer tool that allows you to preview and import supported models into your jMonkeyEngine3 project.

jmonkeyplatform003-300x117.jpg jmonkeyplatform002-300x218.jpg

  1. Select the project you want to import your model to
  2. Click the "Import Model" button in the toolbar
  3. Click "open model.." and select the main model file
  4. Check the preview and file list and press "Next"
  5. Check and change the import path if necessary
  6. If you want to copy the original model files as well, check the checkbox
  7. Press "finish"

The model is converted to j3o and all necessary files are copied to the project assets folder. If you have specified the corresponding option, all original model files will also be copied to your assets folder.

Using the model files directly

  1. Create a separate folder for each model in the assets folder of your project.
  2. Export the model from Blender as OgreXML into its subfolder in the asset folder of your project,
  3. Make sure that the OgreXML material file has the same name as the exported mesh or scene file!
  4. In the Projects Explorer Assets node, select the model that you want to import.
  5. Double-click the model or right-click and select "Convert to JME binary" from the context-menu.
  6. In the Projects Explorer Assets node you should see your model j3o file.
  7. Double-click it to view it in the SceneViewer.
  8. Click on the lightbulb to turn on the light if you cannot see your model

Note: It is important that you copy the model file and its textures to the correct assets folder before creating the j3o file because the paths for textures (and possibly other things) will be stored as absolute (to the assets folder root) when you convert that model. This means the texture location should not change after the import.

Working With a Model

Notes About Model Assets

The original OgreXML .mesh.xml, .scene, .material and .skeleton.xml model files will not be included in the distribution assets.jar file of your distributed game, they are only available in the assets folder so you are able to recreate the .j3o file from the original if you ever come to change it in blender and have to export it again.

About the SceneViewer and SceneExplorer window

The SceneViewer and SceneExplorer windows are shared among plugins to save system resources. This means that you will have to keep an eye on what plugin is using the scene right now and what you are actually modifying in these windows.

Most plugins will deliver their own UI elements to modify the scene so the SceneExplorer is more of a global tool. The simple SceneComposer however heavily relies on its functions as other plugins might too in the future.

About the projects AssetManager

Each jMP project has its own internal AssetManager that has the projects assets folder registered as a FileLocator. When the project is run, the assets folder is compressed into a jar file and added to the projects main jar classpath. This way the editors in jMP and the running game have the same asset folder structure.

You might wonder why jMP requires you to copy the model that is to be converted to j3o into the assets folder before. The Model Import Tool also copies the model and associated files to the project directory before converting. To load the model it needs to be in a folder (or jar etc..) that belongs to the projects AssetManager root. To load a model from some other folder of the filesystem, that folder would have to be added to the AssetManager root. If every folder that contains a model was in the root of the AssetManager, all textures named "hull.jpg" for example would be the same for the AssetManager and it would only deliver the texture of the first model folder that was added.

To have a valid jME3 object, the paths to textures and other assets belonging to the model have to be read with the correct, final path that can then be stored in the j3o object. The j3o object will use those paths when it is loaded with the AssetManager and it requires the AssetManager to deliver the assets on those paths, this is why the folder structure while converting has to be the same as when loading.

view online version