Ogre XML and Materials

Hello!



Because of the discussion of using obj or ogre xml files I want to use in future ogre xml.

To export the files I’ve just downloaded “IOgre” for Cinema 4D and created a simple sofa with a diffuse Material on it.

Nothing special only one color.

At the export I get one …mesh.xml file and one …material file.

But everytime I want to load that model into the scene I get the error message that my material called “Mat” could’nt be found.



pre type="php"
10.08.2011 12:52:16 com.jme3.scene.plugins.ogre.MeshLoader applyMaterial


WARNUNG: Material Mat not found. Applying default material


10.08.2011 12:52:16 com.jme3.scene.plugins.ogre.MeshLoader startElement


WARNUNG: Unknown tag: submeshnames. Ignoring.


10.08.2011 12:52:16 com.jme3.scene.Node attachChild


INFO: Child (HyperNURBS-geom-1) attached to this node (HyperNURBS-ogremesh)


10.08.2011 12:52:16 com.jme3.scene.Node attachChild


INFO: Child (HyperNURBS-ogremesh) attached to this node (geometryNode)
/pre



Hope somebody had a similar problem?!



Thanks!





regards



-René

The material file has to have the same name as the ogre scene file, the name isn’t stored in the mesh file so the loader needs the names to be the same.

The two files are named

  1. Sofa.mesh.xml
  2. Sofa.material



    I don’t know what’s wrong!? Could it something to do with the fact that I load my scene from a custom path?



    “assetManager.registerLocator(path, FileLocator.class.getName());”



    I register the path extracted from a JFileChooser.





    regards



    -Rene

its possible, try add it to your assets folder and see if that works.

No, it doesn’t work. I’m still get the message that the material is not found!?

Does the material file contain a material with the name ‘Mat’?

I am sure everybody has the same problems and rediscovers the same solutions. As Normen said the materials (all of them) must be stored in a single file named exactly the same as the name of your scene. So if your scene is “xyz.scene” you also must have the file “xyz.material”. So take all your material files for all meshes and copy their contents into a single file. If you want to use only a single mesh rather than a scene you need to rename its material file after its name, so if you have a mesh “abc.mesh” its material file should be “abc.material”. This could be simplified in the future I am sure but it works for now.

I had the same problem and traced through the code a bit and realized that this error message may not always be valid. In my case, the asset manager did find the given material file, but the problem was that inside it I had declared a non-existent texture file.



This throws an AssetNotFoundException and the catch block in the MeshLoader.load method erroneously interprets it as the .material file not being found. I believe this is a bug.

This should work better with the nightly. The texture not found error is cought at the material loader and not the mesh loader