# How do I create a manual object with colors for each vertex?

How do I create a shaded manual object with colours for each vertex? Eg if ogreObj is the Ogre::ManualObject :

ogreObj->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);


will allow me to select each vertex's colour with ogreObj->colour(r, g, b) after each ogreObj->position(x, y, z) and ogreObj->normal(x, y, z) call.

However, if I change the material to BaseWhite, color() instructions are ignored. I read that you must disable lighting int the .material script, but I need it active... Any advice?

ANSWER: This Ogre forum's thread has a simple .material script that works for this purpose:

material Voxel/Default
{
technique
{
pass
{
diffuse vertexcolour
specular vertexcolour
ambient vertexcolour
lighting on

}
}
}

• have you tried using a custom material, similar to the base one, but with your own vertex and pixel shaders? – teodron Aug 27 '13 at 8:14
• – teodron Aug 27 '13 at 8:15
• Thank you both! But the thread teodron linked at worked for me. Specifically, I just made a .material script with this content: material Voxel/Default { technique { pass { diffuse vertexcolour specular vertexcolour ambient vertexcolour lighting on } } } – UberLambda Aug 27 '13 at 8:40
• Put your update in the question, as an edit. I can't answer it either because I just did that in a comment by supplying a link. There's an "ethical" rule: if you supply a link and not an explanation, you should comment and not answer. When you get the reputation, you'll answer it yourself :). – teodron Aug 27 '13 at 8:53
• You can answer your own question, you just have to wait a while. Please don't "answer" the question by placing the answer text in the question itself. I've reposted your answer as an actual answer; feel free to post your version if you like and I will delete mine. – Josh Jan 4 '14 at 18:30

As you discovered, a material script can be used for this purpose.

material Voxel/Default
{
technique
{
pass
{
diffuse vertexcolour
specular vertexcolour
ambient vertexcolour
lighting on

}
}
}