Hello!
OK, I've got some basic 3D stuff working, but I'm now wondering where to go from here. So far, I have a rotating 3D cube, with vertices stored as VertexPositionNormalColoured type (i.e. untextured). I then use a vertex buffer / index buffer to draw this. All working fine.
Now what I'd like to do is have lots of different cubes all at different positions. By analogy to another thread I've seen, I think the best way to do this is to have a wrapper class containing (a) the world matrix for each cube and (b) a reference to the vertex buffer / index buffer above. Does that sound sensible?? I think that should work fine - though could require multiple Draw() calls, one per cube? Memory-wise, only one instance of the buffers, which is good.
My next question is: what if I wanted different colours for the different cubes? The issue then is, these are essentially different vertex buffers aren't they (given the colour is stored in the vertex). Do I need (option 1) one vertex buffer per potential colour of box or what?
Other options would be:
(option 2) fake the colour change by altering the ambientLighting on the shader - but that seems hokey. Or,
(option 3) before drawing each cube, loop through the vertices in the buffer, update the colour, SetData again and then draw the cube. But that will be slow.
Presumably the memory hit is the right move here?
Finally - one more question!! I've wrapped the vertex buffer / index buffer / vertices in a TriangleManager<T> class. I was attempting (option 3) above, so I added my initial (bland) vertices to the TriangleManager and then subsequently went:
foreach(VertexPositionColourNormal v in triangleManager.vertices)
{
v.SetColor(newColor);
}
Only problem is - nothing changes in the vertex list when I do this (despite solid code in the SetColor() function). Will List<T> not allow this kind of updating?? I do then call SetData again, but the initial vertex colours persist.
Thanks in advance for any tips! Sorry for the long post, not sure what to cut out to make it shorter :|.
Muzz