OGRE mesh missing materials / textures

When I apply a texture or material to something in Blender, I can see it fine in the render:







But when I export it using the OGRE mesh exporter and load it in the game, the texture or materials no longer display:







When I export my meshes, I end up with fewer files than the example models:






WARNING DesktopAssetManager 2:36:20 PM Cannot locate resource: tree/cone.material
WARNING MeshLoader 2:36:20 PM Material Tree not found. Applying default material
WARNING LwjglRenderer 2:36:20 PM Uniform m_VertexColor is not declared in shader.


I think I'm using the exporter incorrectly, because I don't end up with any image files. I don't know if I am using the wrong settings or my setup in Blender is wrong, so I'm hoping someone can tell me what I need to fix.
1 Like

Duunno about blender, but  it should

also generate a core.material (defines the textures and materials)

and copy the used textures to the output folder.



Maybee a checkbox for material export somewhere unchecked?

1 Like

I think I have all the right options selected (specifically “copy textures”) but still the materials don’t export:



1 Like

I think the answer is in your post



WARNING DesktopAssetManager 2:36:20 PM Cannot locate resource: tree/cone.material



Have you tried to rename your Scene.material to cone.material?



In the exporter you can specify the name of the material file in Material Settings (we can see it in your screen shot)



give it a try

1 Like

That solved part of the problem:







Still no textures, obviously, since they never exported. Look at the material file from my tree:


material Tree
{
   receive_shadows on
   technique
   {
      pass
      {
         ambient 0.500000 0.500000 0.500000 1.000000
         diffuse 0.640000 0.640000 0.640000 1.000000
         specular 0.500000 0.500000 0.500000 1.000000 12.500000
         emissive 0.000000 0.000000 0.000000 1.000000
      }
   }
}



Now, the material file from the example ninja:

material Ninja
{
        technique
        {
                pass
                {
                        ambient 0 0 0 1
         diffuse 1 1 1 1
         specular 1 1 1 25.6
         emissive 0 0 0
               
                        texture_unit
                        {
                                texture Ninja.jpg
                                tex_coord_set 0
                        }
                }
        }
}



The ninja material file has a section texture_unit where it references the exported image file, while mine has neither. So the exporter doesn't realize that there's a texture on the model, despite it showing on the Blender render. How can I fix this?
1 Like

hum… strange.



Well you can add what's missing yourself in the file.

I never really use the ogre material as it's exported, because it's limited to a single diffuse texture.



Have you got only one diffuse texture in blender?

is it in the first slot? (maybe that can have an effect)



If you don't find, you can look in the exporter script how it's done and how it exports the texture, to figure out what's wrong



Are you using JME2 or JME3?




1 Like
Well you can add what's missing yourself in the file.


As well as the texture, I think you also have to tell it how to project it onto the model, like tex_coord_set 0, and I don't know how to edit that correctly if I do UV mapping. If you have some insight into that, then it would definitely be a good alternative.

I never really use the ogre material as it's exported, because it's limited to a single diffuse texture.

How do you do it? Do you edit the material file manually, or is there another way?

Have you got only one diffuse texture in blender?

is it in the first slot? (maybe that can have an effect)


I'm not familiar with texturing, actually I don't even know how to apply a defuse texture. But hopefully this will help?




If you don't find, you can look in the exporter script how it's done and how it exports the texture, to figure out what's wrong


I think it's just a problem with my setup... but the Python code isn't as scary as I thought it would be.

Are you using JME2 or JME3?


I'm using the JME3 nightly build.
1 Like

First you can try tex_coord_set 0 in the file, it should refer to a set of UV coordinates…

mapping coordinates are in the mesh.xml file (you can look into it you should find them)

kidneytrader said:

How do you do it? Do you edit the material file manually, or is there another way?

In this post i explained  how you could export J3o files with ogre exporter
http://www.jmonkeyengine.com/forum/index.php?topic=13635.0

But...to be honest, most of the time it is quicker to do manually.

If you use JME3 you can do it many ways

1. Use existing material definitions


        Spatial treeModel=assetManager.loadModel("path/to/your/model");
        Material treeMaterial = new Material(assetManager, "Commmon/MatDefs/Misc/ColoredTextured.j3md");
        treeMaterial.setTexture("m_ColorMap", assetManager.loadTexture("path/to/your/tree/texture.png"));
        treeModel.setMaterial(treeMaterial);



2.Make your own material file using material definition :
create a j3m file like that :


Material Tree : Common/MatDefs/Light/ColoredTextured.j3md {
   MaterialParameters {
                m_ColorMap: path/to/your/tree/texture.png
        }
}


and in the SimpleInit


  Spatial treeModel=assetManager.loadModel("path/to/your/model");
  treeModel.setMaterial(assetManager.loadMaterial("pass/to/your/material.j3m"));



3.Embed it in the J3o file
- create the j3m file like in previous step
- double click on your mesh.xml file, this should generate a J3o file.
- right click on it and click on "Edit in scene composer",you should see your tree (all red like your first screenshot) in the model View.
- in the bottom left corner in the scene Explorer window, you should see the geom objects of the file (basicaly, your tree geom)
- Click on it and in the properties window (top right corner), you should see the properties of it
- In those properties there is a "Material" property associated with a list box, your material should be in it, choose it.

If every things went right you should see in the model view your tree properly textured (make sure the light is on by clicking on the bulb icon in the top right corner of the model view window).

Click on the save button in the scene composer window and your done. (don't forget that step!!)

Just load your model in the simpleInit (the J3o file) and it should be like in the model view.


I'm not familiar with texturing, actually I don't even know how to apply a defuse texture. But hopefully this will help?

Actualy you do...because you did it on this model :p
The diffuse map is the color or texture map...

just give up the Scene.material file, you don't need it anymore
1 Like
nehon said:

First you can try tex_coord_set 0 in the file, it should refer to a set of UV coordinates...
mapping coordinates are in the mesh.xml file (you can look into it you should find them)


I added a reference to the texture and tex_coord_set 0 in the material file, and opened it with this code:

tree = assetManager.loadModel("tree/cone.mesh.xml");
      rootNode.attachChild(tree);



Unsupported texture_unit directive: tex_coord_set




It's almost there, but there's no texture mapping into in the mesh - just faces and vertices. Meanwhile:

treeModel=assetManager.loadModel("tree/cone.mesh.xml");
        Material treeMaterial = new Material(assetManager, "Common/MatDefs/Misc/ColoredTextured.j3md");
        treeMaterial.setTexture("m_ColorMap", assetManager.loadTexture("tree/tree-texture.png"));
        treeModel.setMaterial(treeMaterial);
        rootNode.attachChild(treeModel);



Unsupported texture_unit directive: tex_coord_set




So it's mapping the textures differently each time, but they're both wrong. I don't know how relevant it is, but I think the second method cancels the shading or something, because I'm getting a much higher FPS and the undersides look different. Regardless, I'm pretty sure I'm using the exporter incorrectly, since it didn't copy or map the textures.
1 Like

did you apply all modifiers on the mesh before exporting?

you sould if it's not the case.



Did you uv map your model in the first place?



if you can't find, could you link your .blend file? i'm gona look into it

1 Like

There weren't any modifiers, so there aren't any to apply. I also didn't UV map it, because it appears fine in the render. It's just a tube projection. I attached the tree, but really it happens with everything I try to export, not just this model. Thanks for helping!

1 Like

In fact i don't know if ogre can export material without UVs, never tried…

To know if your materail is going to show up, in blender go to game menu and check Blender GLSL Material.

And i think you should uv map it…but to be honest it's going to be a pain as the tree is a merge from multiple objects.






1 Like

Nope ogre needs uv, however a normal exporter (all I worked with) did convert on ogre.xml export stuff like box mapping to actuall uv coordinates.

1 Like