Colors missing from meshes.
-
Darkness
- Greenskin
- Posts: 121
- Joined: Sat Mar 19, 2005 3:32 am
- Location: Austin, Texas
Colors missing from meshes.
Well, I finally got my internet back, so I've been converting my objects into meshes. The problem I have is some of them have no color. The objects themselves have no textures, they were supposed to be simply shaded, but when I load them in as entities they are without the color I gave them. In the XML file they have color, but there are none when I bring them into the scene. Anyone know how why this is or how I can fix it?
-Darkness
-Darkness
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
-
Darkness
- Greenskin
- Posts: 121
- Joined: Sat Mar 19, 2005 3:32 am
- Location: Austin, Texas
Hmmm...when I search the Ogre API reference for "vertexcolour", I don't find anything. The other thing is, just for the sake of testing, I made another object and gave it an actual texture. When I ran the "ogreXMLconverter" on it, it did not generate a material file. I load it up and it's just white. Just like the other objects. Oh, and I do have the ambient light turned on, so I don't think that's the problem. Is the ogreXMLconverter supposed to generate a material file? Do I need to set an option when I run the program on an object?sinbad wrote:Specifically you need to use the 'vertexcolour' option of at least one of the colour components in the pass (ambient, diffuse etc), see the manual for details.
I apologize if I seem a little snippy, but I've been messing with this for many hours and I'm just frustrated at this point. I'm sure I'm doin' something wrong, but I don't know what or where.
-Darkness
- haffax
- OGRE Retired Moderator

- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 8
- Contact:
Don't look for it in the API docs, but in the manual. Section 3.1.2 has it.
instead of something like
write
This uses the vertex colour as ambient component. this works likewise with diffuse and specular
instead of something like
Code: Select all
ambient 0.8 0.8 0.8
Code: Select all
ambient vertexcolour
- haffax
- OGRE Retired Moderator

- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 8
- Contact:
-
Darkness
- Greenskin
- Posts: 121
- Joined: Sat Mar 19, 2005 3:32 am
- Location: Austin, Texas
Hmmm...when I run "ogreXMLconverter" it doesn't generate a material file automatically? I have no idea how to make a material script let alone how to make it work with my objects. Don't get me wrong, I've looked at the material scripts that came with ogre, but there are numbers in there I have no idea what they are. And how do I tell it what material goes on what face? I just assumed the converter created a material script when it did the conversion. Is there a converter that I can get that will automatically generate a material script off of the XML file?
-Darkness
-Darkness
- haffax
- OGRE Retired Moderator

- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 8
- Contact:
The converter does what the name suggests it only converts between xml and binary meshes/skeletons. It can't create material files, as it doesn't know how you want the material.
This material should work for you:
This material should work for you:
Code: Select all
material mymaterial
{
technique
{
pass
{
ambient vertexcolour
diffuse vertexcolour
texture_unit
{
colour_op_ex source1 src_diffuse src_diffuse
}
}
}
}
-
Darkness
- Greenskin
- Posts: 121
- Joined: Sat Mar 19, 2005 3:32 am
- Location: Austin, Texas
Sinbad, here's the code I use:
I hope this works.
-Darkness
Code: Select all
//Load the main background
MaterialPtr bgmaterial = MaterialManager::getSingleton().create("Background", "General");
bgmaterial->getTechnique(0)->getPass(0)->createTextureUnitState("../Graphics/city.png");
bgmaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
bgmaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
//Disable lighting on background
bgmaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false);
//Create background rectangle
Rectangle2D* bgrect = new Rectangle2D(true);
//Cover whole screen
bgrect->setCorners(-1.0,1.0,1.0,-1.0);
//Kludge: set bounding box to a large size.
bgrect->setBoundingBox(AxisAlignedBox(-10000.0*Vector3::UNIT_SCALE, 100000.0*Vector3::UNIT_SCALE));
bgrect->setMaterial("Background");
//Render background before everything else
bgrect->setRenderQueueGroup(RENDER_QUEUE_BACKGROUND);
//Attach background to the scene
SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Background");
node->attachObject(bgrect);
-Darkness
- haffax
- OGRE Retired Moderator

- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 8
- Contact:
Darkness, a follow-up from the discussion on IRC.
This material is a semi-transparent light purple and it works, I have tested it using both OpenGL and dx9.
If your mesh is not transparent purple afterwards you need to post the material application code, as the error is most likely in it then.
This material is a semi-transparent light purple and it works, I have tested it using both OpenGL and dx9.
Code: Select all
material alpha_purple
{
technique
{
pass
{
depth_write off
scene_blend alpha_blend
texture_unit
{
colour_op_ex source1 src_manual src_manual 1.0 0.5 1.0 1.0 0.5 1.0
alpha_op_ex source1 src_manual src_manual 0.5 0.5
}
}
}
}
- haffax
- OGRE Retired Moderator

- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 8
- Contact:
Darkness, got your mesh working at last. Actually without changing the mesh, really. The two white faces in the image where because they are seperate submeshes and I forgot to rename the materials for them. (from Purple to alpha_purple)
So, your mesh is fine, the material is fine too. The problem lies in some other place then. But don't know where.
So, your mesh is fine, the material is fine too. The problem lies in some other place then. But don't know where.
-
Darkness
- Greenskin
- Posts: 121
- Joined: Sat Mar 19, 2005 3:32 am
- Location: Austin, Texas
Haff, I'm not sure what's goin' on either. If the meshes are good, then something must be wrong in the code somewhere. Based on my code for loading them in, is everything okay? Is there a step I need to do before I load them? I need to figure out what's goin' on, otherwise I can't get anywhere. Can't load models...can't finish project. 
-Darkness
-Darkness
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
Ok, I've looked. I don't have a mesh with vertex colours to hand, so I had to change your material a bit to this:
I then took the code above (changing the image to ogrelogo.png), and added:
and the result was

ie normal.
This thread is somewhat disjointed since conversations have happened on IRC - if this doesn't satisfy you need to sum up what your current problem is, and provide code, screenshots and media links, since it's difficult to derive here.
Code: Select all
material mymaterial
{
technique
{
pass
{
lighting off
texture_unit
{
colour_op_ex source1 src_manual src_current 1 0 0
}
}
}
}
Code: Select all
Entity* e = mSceneMgr->createEntity("2", "knot.mesh");
e->setMaterialName("mymaterial");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(e);

ie normal.
This thread is somewhat disjointed since conversations have happened on IRC - if this doesn't satisfy you need to sum up what your current problem is, and provide code, screenshots and media links, since it's difficult to derive here.
- haffax
- OGRE Retired Moderator

- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 8
- Contact:
-
Darkness
- Greenskin
- Posts: 121
- Joined: Sat Mar 19, 2005 3:32 am
- Location: Austin, Texas
Yeah. I wish I had saved the links to the pics and everything we had when talking on IRC so you could see what was goin' on. If the problem is in the code, then I need to find where the problem is. I posted all of the code I use to pull up the images and I cannot get the meshes to work properly. They show up, but with no materials on them. In OpenGL they absorb the background material. It's real strange.
I'm not sure what to do right now. I can't get any of the models to display correctly. Even got some models from Lightwave and converted them and they don't work either. So I'm just lost.
-Darkness
I'm not sure what to do right now. I can't get any of the models to display correctly. Even got some models from Lightwave and converted them and they don't work either. So I'm just lost.
-Darkness
-
Darkness
- Greenskin
- Posts: 121
- Joined: Sat Mar 19, 2005 3:32 am
- Location: Austin, Texas
