Say I have a mesh with one triangle as a surface and I'm wanting to have a flatshaded triangle using the vertex colours instead of a brush. (EntityFX mesh,6).
Do I have to set the same VertexColor at every vertex or will applying it to one vertex be enough?
Marg
Just on a per vert basis when you need to. Also, remember to set the EntityFX flag to 2 in order to enable it.
Unsure of what you mean?
Is it every vertex in the triangle?
Thanks
Marg
A triangle is made up of 3 vertexs. A vertex is a point where two or more lines from triangles meet. That's the best way to think about it.
A mesh is made from surfaces. A surface is made from triangles. A triangle is made from vertexs.
____
/\ /\
/ \/ \
--------
Say that was your mesh. It has three triangles and 5 vertexs.
But you could always have 3 vertices for each of those triangles, so 9 verts instead of 5. This is useful if you want all three triangles to be a single, different colour for example, rather than the mesh having a smooth colour gradient along each triangle from vertex to vertex.
You colour each vertex, not each triangle - and then the triangle is coloured by all 3 vertices it's made up of. So if a vertex is used in more than one triangle, all the triangles it's used in will be coloured by it.
Thanks,
What I was questioning was if the triangle is flat shaded and using vertex colours then which vertex will give the colour. It seems the first vertex does.
Running the following gives a nice 'mixture' red,green,blue. Puting in the flat shading takes the colour from the first vertex.
Graphics3D 800,600
SetBuffer BackBuffer()
camera=CreateCamera()
CameraViewport camera,0,0,800,600
light=CreateLight()
plane=CreateMesh()
surface = CreateSurface(plane)
AddVertex( surface, -10, 0, 0)
AddVertex( surface, 0,10,0)
AddVertex( surface, 10,0,0)
AddTriangle( surface, 0, 1, 2)
PositionEntity plane,0,0,25
EntityFX plane,1+2 ; +4 for flat shading
VertexColor( surface,0, 255,0 ,0)
VertexColor( surface,1, 0 ,255,0)
VertexColor( surface,2, 0 ,0 ,255)
While Not KeyHit(1)
UpdateWorld
RenderWorld
Flip
Wend
End
Can anyone confirm?
Marg
@mrtricks,
Thats what I was getting at.
And using your 3 triangle with the 9 vertex you only need give the VertexColor to the first vertex of each triangle to get 3 different coloured triangles.
For flat shaded ones that is.
Marg
Okay, I didn't know that; I haven't used flatshaded tris yet.