

= Models and Scenes

Like <<shape#,Shape>>s, 3D models are also made up of <<mesh#,Mesh>>es, 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:


.  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#,Asset Manager>> to load models as <<spatial#,Spatial>>s into a jME application. 
[source,java]

----
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 link:http://www.blender.org/[Blender], with an OgreXML Exporter plugin. 


*Tip:* Learn how to create link:http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/UV_Map_Basics[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:


*  <<jme3/external/blender#,Creating jME3 compatible 3D models in Blender>>

To export your models as Ogre XML meshes with materials:


.  Open the menu File &gt; Export &gt; 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 with `something.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 <<sdk#,jMonkeyEngine SDK>> to <<sdk/model_loader_and_viewer#,load and view models>>. You can <<sdk/scene_composer#,create scenes>> from them and write code that loads them into your application. 

