Question about triangle face direction

Blitz3D Forums/Blitz3D Beginners Area/Question about triangle face direction


Well, when you do an AddTriangle (surface,v0,v1,v2) Blitz assumes that v0-v1-v2 are in clockwise order.



No it doesn't. The order will be clockwise or counterclockwise depending on the position of the verts and the order you declare them (within AddTriangle). For example if you have the following three verts...

v00=AddVertex(triSurface,-1,-1,0)
v01=AddVertex(triSurface, 0, 1,0)
v02=AddVertex(triSurface, 1,-1,0)

...then v00 will be at the bottom left, v01 in the middle at the top and v02 at the bottom right.

AddTriangle(triSurface,v00,v01,v02) would descibe it in a clockwise fashion; AddTriangle(triSurface,v02,v01,v00) counterckockwise. In one instance it would face "outwards", the other "inwards".

Observe:
Graphics3D 800,600,0,2
SetBuffer BackBuffer()

piv=CreatePivot()
cam=CreateCamera(piv)
PositionEntity cam,0,0,-20

triMeshA=CreateMesh()
triSurfaceA=CreateSurface(triMeshA)
A00=AddVertex(triSurfaceA,-1,-1,0)
A01=AddVertex(triSurfaceA, 0, 1,0)
A02=AddVertex(triSurfaceA, 1,-1,0)
AddTriangle(triSurfaceA,A00,A01,A02)
PositionEntity triMeshA,-1,0,0

triMeshB=CreateMesh()
triSurfaceB=CreateSurface(triMeshB)
B00=AddVertex(triSurfaceB,-1,-1,0)
B01=AddVertex(triSurfaceB, 0, 1,0)
B02=AddVertex(triSurfaceB, 1,-1,0)
AddTriangle(triSurfaceB,B02,B01,B00)
PositionEntity triMeshB,1,0,0

While Not KeyDown(1)
TurnEntity piv,1,0,0

RenderWorld
Flip
Wend