# Multi-Media Asset Pipeline

Assets are files that are not code. Your multi-media assets includes, for example, your textures (image files), models (mesh files), and sounds (audio files).

- You create textures in a graphic editor, for example Gimp, and export them as PNG or JPG.
- You create models in a 3D mesh editor, for example Blender, and export it in Ogre Mesh XML or Wavefront OBJ format.
- You create sounds in an audio editor, for example Audacity, and export them as WAVE or OGG.

DO | DON'T
--- | ---
Save original models plus textures into `assets/Textures`. | Don't leave textures or models in a folder outside your JME project: The game cannot load or reference them from there.
Save sounds into `assets/Sounds`. | Don't leave audio files in a folder outside your JME project: The game cannot load or reference them from there.
Create low-polygon models. | Don't create high-polygon models, they render too slow to be useful in games.
Only use Diffuse Map, Normal Map, Glow Map, Specular Map in your models' materials. | Don't use unsupported material properties that are not listed in the Materials Overview.
Use UV texture / texture atlases / baking for each texture map. | Don't create models based on multiple separate textures, it will break the model into separate meshes.
Convert original models to JME3's .j3o format. Move .j3o files into `assets/Models`. | Don't reference original Blender/Ogre/OBJ files in your load() code, because these unoptimized files are not automatically packaged into the final JAR.

Read on for details.

### Use The Assets Folder

Store your assets in subfolders of your project's `assets` directory. The `assets` directory is the default path where a JME game's Asset Manager looks for files to load.

    jMonkeyProjects/MyGame/assets/Interface/ # .font, .jpg, .png, .xml
    jMonkeyProjects/MyGame/assets/MatDefs/   # .j3md
    jMonkeyProjects/MyGame/assets/Materials/ # .j3m
    jMonkeyProjects/MyGame/assets/Models/    # .j3o
    jMonkeyProjects/MyGame/assets/Scenes/    # .j3o
    jMonkeyProjects/MyGame/assets/Shaders/   # .j3f, .vert, .frag
    jMonkeyProjects/MyGame/assets/Sounds/    # .ogg, .wav
    jMonkeyProjects/MyGame/assets/Textures/  # .jpg, .png; also .mesh.xml+.material, .mtl+.obj,

Prepare the `asset` folder structure for your individual project:

1. Agree on a directory structure with the graphic designers.
2. Create subfolders of `assets` in any way that suits your project (see example above). Stick with one system.
   - If different assets belong together, create a parallel subdirectory structure for them.
     Example: For car models, create `Textures/vehicles/car1/`, `Materials/vehicles/car1/`, `Models/vehicles/car1/`, , `Sounds/vehicles/car1/` (etc) directories now.
3. Agree on a file naming and numbering scheme with the graphic designers.
   - Are some assets used interchangeably? Systematic naming and numbering lets developers easily swap out assets by swapping out parts of the path String.
   - Decide on naming standards for naming interactive parts (arms/legs) of animated models.

See also:

- More details on Asset Manager, including tips how to work with assets when using other IDEs.
- Use Asset Packs to bundle, share, and manage assets!

### Create Textures and Materials

Install a graphic editor such as Gimp or Photoshop. Consult the graphic editor's documentation for specific details how to do the following tasks.

1. Create textures in a graphic editor.
   - Save all textures to your prepared subfolders in the `assets/Textures` directory.
2. (Optional) If you plan to use JME materials that you set programmatically from the code, create .j3m materials in the SDK.
   - Save these .j3m files into the `assets/Materials` directory.

Storing the textures inside your project directory is necessary for the paths in JME's binary model files (.j3o) to work. Treat the paths of your assets like class names of java classes, they define a specific asset. When you later generate .j3o files, compile class files, and distribute the project, paths and files need to be available in their final absolute form. It is imperative to keep the same directory structure from beginning to end.

If you ever change the assets directory structure, you will have to do manual refactoring (just as for Java package name changes): You will need to re-export all affected models, regenerate all affected .j3o files, and manually update all affected paths in your code.

### Create 3D Models

Install a mesh editor such as Blender or 3D Studio MAX. Reuse textures and materials as much as possible. Consult the mesh editor's documentation for specific details how to do the following tasks.

Note that UV coords are part of the mesh and not part of the material, so if you import your mesh successfully you can later apply the texture again and it will map correctly.

1. Create 3D models in a mesh editor.
   1. Create simple low-polygon models. High-polygon models may look pretty in static 3D art contests, but they unnecessarily slow down dynamic games.
   2. Create materials for your models either in the 3D editor, or in the jME3 SDK. Only use Diffuse Map (minimum), Normal Map, Glow Map, and Specular Map.
      Every material feature not listed in the Materials Overview is unsupported and ignored by JME3.
   3. Unwrap the model in the 3D editor and generate a UV texture (i.e. one texture file that contains all the pieces of one model from different angles).
      Don't use multiple separate texture files with one model, it will break the model into several meshes.
2. Export the model mesh in one of the following formats: .blend, Wavefront .OBJ/.MTL, Ogre .mesh/.material/.scene.
   1. Bake each texture into one file when exporting. (Create a Texture Atlas.)
   2. Save exported models to subfolders of the `assets/Textures` directory, together with their Textures. (for now)

See also:

When I load the model in JME, why does it look different than in the 3D editor?
3D models will never look identical in a game engine and in a mesh editor. Mesh editors are optimized for high-quality offline rendering, and many of the material and texture options simply do not work in a live rendering context. Also, the shaders that render the materials in JME are different than in your mesh editor's renderer. Remind your graphic designers to only focus on features that game engines support.

### Convert 3D Models to .j3o Format

Convert all models and scenes to jME3's binary .j3o format to load() them. You use the jMonkeyEngine SDK to do the conversion.

1. Confirm that you exported the model into the `assets/Textures` directory (or subdirectories) together with all its textures.
2. In the SDK, right-click the model and choose "Convert to j3o Binary".
   The paths in the j3o now reference files with an absolute `assets/Textures/???` path.
3. Now, move the .j3o into the corresponding `assets/Models/` or `assets/Scenes/` directory.
4. Use the AssetManager to load() the .j3o files.

This process ensures that the texture paths are correct, and it also keeps your `assets/Models` folder free from textures. You can reuse your set of textures for many models.

Must I convert to .j3o? ??? Yes!

- .j3o is an optimized format to store parts of a jME3 scene graph. A .j3o file can contain one shape, one model, or a whole scene.
- Only .j3o files can store all of jme3's material and other options, other formats can only be considered meshes with UV mapping data and always need to be worked on.
- .j3o files work seamlessly across platforms and can also be automatically adapted for certain platforms on distribution.
- (Optional) You can store the model's physical properties, materials, lights, particle emitters, and audio nodes, in the .j3o file.
  Use the jMonkeyEngine SceneComposer to add these properties.
- The default Ant build script copies .j3o / .j3m files, sounds, and textures, into the distributable JAR automatically.

Important: Unoptimized external model files (.mesh.xml, .material, .obj, .mat, .blend, etc) are not bundled by the default build script into the final executables! If you try to run executables containing code that loads non-.j3o models, you get a Runtime Error (resource not found). The final application code should only reference .j3o files. (Note that you will not get this runtime error when running development builds straight from the SDK!)

## See Also

- Save and Load
- Model Loader and Viewer

spatial, node, mesh, geometry, scenegraph, sdk

view online version