Hi everybody!!!
I need to change the colour of each polygon of a scene to have 1 diferent colour per polygon. I haven't find in wich data structure is stored the colour of the vertices.
Has anybody idea on how to change the colour of each polygon of a scene (the mesh and its submeshes)?
Many thanks!!!
Modifying vertex colours
-
- OGRE Retired Moderator
- Posts: 1365
- Joined: Tue Sep 07, 2004 12:43 pm
- Location: Aalborg, Denmark
I'm afraid this isn't as easy as it sounds. To do this you need to understand how Ogre stores its meshes into hardware vertex and index buffers. You can find an introduction to this in the manual.
Your .mesh can have vertex colours depending on how it's exported, but it probably has not. So basically what you have to do I think, is to modify the vertex declaration of each SubMesh (or Mesh if they use shared vertices) to also have a VET_COLOUR/VES_DIFFUSE element, and then bind a new vertex buffer containing the old data plus the new colour information for each vertex.
If you want each of the polygons to have a completely seperate colour (as opposed to colours interpolated between shared vertices), you'll also have to triple your vertices because the polygons cannot share them if they have different colours.
And btw remember to use a material with
otherwise the vertexcolours will be ignored.
Your .mesh can have vertex colours depending on how it's exported, but it probably has not. So basically what you have to do I think, is to modify the vertex declaration of each SubMesh (or Mesh if they use shared vertices) to also have a VET_COLOUR/VES_DIFFUSE element, and then bind a new vertex buffer containing the old data plus the new colour information for each vertex.
If you want each of the polygons to have a completely seperate colour (as opposed to colours interpolated between shared vertices), you'll also have to triple your vertices because the polygons cannot share them if they have different colours.
And btw remember to use a material with
Code: Select all
(...)
ambient vertexcolour
diffuse vertexcolour
(...)