Problem seeing materials after exporting with blender

Problems building or running the engine, queries about how to use features etc.
kevkev009
Gnoblar
Posts: 4
Joined: Sun Jan 16, 2005 10:01 pm

Problem seeing materials after exporting with blender

Post by kevkev009 »

Hey all,

I UV mapped the model and exported it with blender. Then I converted it for use in OGRE.

I loaded the model, and I see the model, but no material. It's all white. I cant figure out what I need to do to correct this, and I searched meticulously through the forums.

After I convert the XML to .mesh do I have to have that exported material file in the same directory as the .mesh? Or does the mesh itself contain all the info? I tried both ways, and I still have the same problem.

The code I have is the same as the first OGRE program code. I just changed the spaceship model to my model. So I get the skybox loaded perfectly and can move around. However, as I said, the mesh is all white.

Can anyone shed any insight? Any help will be appreciated. Thanks. :)
reimpell
OGRE Contributor
OGRE Contributor
Posts: 570
Joined: Mon Mar 01, 2004 10:35 am
Location: Hamburg, Germany

Re: Problem seeing materials after exporting with blender

Post by reimpell »

kevkev009 wrote:After I convert the XML to .mesh do I have to have that exported material file in the same directory as the .mesh?
Be sure that the Ogre resource system does find the material and texture files. You may want to alter your resources.cfg file accordingly. Also ensure that the texture image width and height are a multiple of two.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

If in doubt, check Ogre.log which should tell you what went wrong.
kevkev009
Gnoblar
Posts: 4
Joined: Sun Jan 16, 2005 10:01 pm

Post by kevkev009 »

Ok, I've got it to the point where the log says everything is loading...

In the log it says it's parsing my material script earth.material, then a little bit below that it says it's loading my earth.mesh, and my 2D texture earthmap.jpg with 5 mip map levels (earthmap.jpg is 512x512). The game comes into view and the earth still doesn't show its texture.

Do I have to do anything else except point the engine to the required resources? I have earth.mesh, earth.material and earthmap.jpg all in the same folder whose path has been included in my resources.cfg. Like I said the game code is exactly the same as the first OGRE application tutorial, except that I'm loading earth.mesh instead of razor.mesh, and I altered the resources.cfg file to include the path that my files are in. Everything loads fine when I have razor.mesh (the aircraft) as the loading model. So I doubt its a lighting problem.

It seems to me that OGRE is loading it properly, but I maybe did something wrong in Blender.

What I did in Blender are these actions exactly: I made a sphere. I went to UV Face Select Mode hit Shift+F10 in one window and loaded my earth texture. Then I did a UV unwrap (sphere) which applied the Earth perfectly to the texture. Now this is where I am foggy with Blender. After I did the UV unwrap, it showed the texture on the model when I look at it in object mode with the show texture box selected (as opposed to shaded, solid, wireframe, etc). I'm not sure if that simply by unwrapping the mesh to the texture that it's actually applying the texture to the mesh. After doing the unwrap, I went to File->Export->OGRE XML. It loaded the exporter script with no problem, as I configured Python correctly in the system variables. The exporter loaded with the default options, export textures and export armature selected. I named the material I wanted to export earth.material. I selected my root directory F:\ as the place to export to. It said it exported the mesh which was sphere.mesh.xml and the material earth.material.

But interestingly, while in Blender, I don't see it on the mesh when I do a rendering! I think that might be where I've gone wrong. I'm new to texturing in Blender and I may have missed a step somewhere, so if any of you seasoned Blender folk could advise me on this part I'd appreciate it. :)

Anyway, proceeding with the conversion. I converted using the OgreXMLCoverter downloaded in the Command Line Tools download. I copied my XML file and the material file into the folder containing the XMLconverter. I dragged the xml file onto the converter. A DOS window came up and it was doing stuff, then it finished, the window quit, and sphere.mesh appeared. I couldn't see what was happening in the DOS window as the conversion took place very quickly. So I can't see if it reported any errors. Is there a way to do the conversion so I can see what happens? Maybe by opening a DOS prompt and navigating the the converter, running it and somehow executing on the mesh to convert? I renamed sphere.mesh to earth.mesh and copied earth.mesh and earth.material into the folder I configured in resources.cfg.

I ran the program, configured to load earth.mesh and the sphere loaded but the texture wasn't on it. The sphere was white. Ogre.log had the statements written above.

That covers the entire process I've used. I'm using the latest OGRE version 0.15.2 [Hastur], Blender 2.36, and Python 2.3.4. I feel like I'm just an inch away from being able to start making stuff. There is probably just one major thing I'm doing wrong. If anyone could point out ANY faults, that would be great. Thanks again for your help.
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark

Post by DWORD »

I don't know the Blender details, but I would check that the name of the material you use on earth.mesh, and the name of material in earth.material match exactly. If they don't, Ogre will use the default material, which is all white.
reimpell
OGRE Contributor
OGRE Contributor
Posts: 570
Joined: Mon Mar 01, 2004 10:35 am
Location: Hamburg, Germany

Post by reimpell »

Does the .material file contain lines like:

Code: Select all

texture_unit {
  texture earthmap.jpg
}
Are there texcoords in the mesh.xml file?
kevkev009
Gnoblar
Posts: 4
Joined: Sun Jan 16, 2005 10:01 pm

Post by kevkev009 »

I figured out the problem...my UV corrinates weren't being exported to the mesh. It was a Blender problem after all. It's fixed now, and thanks again for your help.
makob
Kobold
Posts: 32
Joined: Wed Jan 28, 2004 10:09 pm
Location: Aalborg, Denmark

Post by makob »

It seems like I have the same kind of trouble, but I'm pretty stuck -- I'm a programmer more than I'm a 3d-modeller, so bare with me ;)

How did you make Blender (ie. OgreXML exporter) save the texture coordinates? Is there some fancy button I have to click? ;)

Cheers,
Jakob
6 times 7 equals 42.
kevkev009
Gnoblar
Posts: 4
Joined: Sun Jan 16, 2005 10:01 pm

Post by kevkev009 »

Don't worry makob, I'm more of a programmer than a modeler too. :)

Well, this is what I did. After you go into UV face select, open a texture, apply an unwrap and set your UVs, then go to the shading panel (hotkey F5, but the buttons are there below your editing windows) and select material buttons. There will probably be no materials assigned. All you have to do is add a material. Then the material's buttons pop up. Make sure to select the TexFace button. After that export the model and you should then see the UV coordinates listed in your modelname.mesh.xml file. Just a reminder: Convert to .mesh, and make sure OGRE knows where to find your mesh, material file, and the specific textures (in resources.cfg). Finally, you should be abel to load the textured model. :D

Hope that solves the problem for you.
reimpell
OGRE Contributor
OGRE Contributor
Posts: 570
Joined: Mon Mar 01, 2004 10:35 am
Location: Hamburg, Germany

Post by reimpell »

kevkev009 wrote:All you have to do is add a material.
The exporter is also supposed to work for meshs with only an uv texture assigned, without any Blender materials. In this case the mesh has no specular color.
ibrown
Gremlin
Posts: 164
Joined: Wed Aug 18, 2004 6:41 pm
Location: London

Post by ibrown »

It took me a long time to figure that out too (the bit about the texture not appearing in the 3d window that is). It seems like this:

If, in blender, you have a material with a texture (regardless of whether it is UV mapped or not) then it will not appear textured in the 3d view, it WILL appear textured in the Blender render (F12) and it will not appear textured in ogre. So ... materials with a texture are a waste of time.
If, on the other hand, you forget about assigning a material and just go into UV Face select mode and load an image into the UV image window then you get the exact opposite results ... the object IS textured in the blender 3d view, it is NOT textured in the blender render (F12) and it IS textured in the exported mesh.

So, the basic rule seems to be:

1. Don't use textures on materials in blender, instead assign textures directly to the faces.
2. If you can see it in the 3d view then it is likely to export correctly. If you can see it in the render but not the 3d view then it probably won't export correctly.

This is just my experience from a few luchtimes hacking around with blender. If someone can give a definitive answer as to how this works that would be great (I searched the blender forums though and didn't find anything).

Ian
User avatar
Cyberdigitus
Halfling
Posts: 55
Joined: Thu Mar 04, 2004 7:08 pm
Location: Belgium

Post by Cyberdigitus »

ibrown, indeed that's how blender works.

they seem to relate uv's directly with an image you set in the uv map window. I hope they will support using the texture of a material someday.
. . .