Loading more than one mesh


I’m a new jme developer and I’m beginning to import models. I tried to import simple models and no problems appeared, but when I export some obj models having more than one mesh in the OgreXML format, Blender saves multiple meshes with their own materials (e.g. one mesh for face, another for body etc). Can I export all the meshes in one? I’ve tried to join all the meshes to a major one with blender (face joins body), but when I export the model and then create the Spatial in jme(reading the path of the “merged” mesh), all the meshes that are joined to the major doesn’t have their materials!

I give a more clear example:

I have an .obj model with 3 meshes and I export it. I have :

mesh1.mesh.xml , mesh2.mesh.xml , mesh3.mesh.xml

and their materials

mesh1.material, mesh2.material mesh3.material

so I import the folder in Assets/Models/Test and now I have to create something like:

[java]Spatial head = assetManager.loadModel( [path] );

Spatial face = assetManager.loadModel( [path] ) [/java]

one for each mesh and than attach them to a common node. I think there is a way to merge those mesh with their materials! What do you think?


The division in geometries depends on a few things like textures and objects in blender. Separate objects in blender will yield separate geometry later just as separate textures will yield separate geometry.

You could also export as a .scene, then the loader will load all geometrys the scene consists of.

Also mesh.xml suipport submeshes, (at least from 3dsmax, how taht works from blender i dont know)

You can merge the objects in Blender into a single object, then you will get a single OBJ file.

Thanks to everybody! I’ll try these methods

This is what I get, if I join all the meshes together:

As you can see, I have only one mesh with 4 materials applied to it.

Now this is what I get if I export the single mesh with OgreXML exporter:

I have 4 different materials with several names, so when I write in JME:

[java]Spatial diablos = assetManager.loadModel(“Models/Diablos/rdmobj03.mesh.xml”);


compiler couldn’t find the associated material (with the same name of the mesh), or at least one material with the same name (excluding the other 3). What I have to do?

If i try to import the .scene, it reacts like if I attached it only 1 material :

So jme find only one match (= one right material), the others are set by default red.

You have to toggle the “Separate Materials” option in the exporter

Thank you Momoko Fan, I haven’t seen that option before! I still have problems with diablo model (jme gives me error when reading .j3o file), but with other models all works fine.

What is the exception with that model?

This issue should be fixed at this point

1 Like