The trouble here is that UpdateNormals considers all triangles which share a given vertex. When two identical triangles are placed "back to back" everything cancels out and the normal vectors become zero.
You really should specify the normals manually when building the mesh. This guarantees you get what you want, not what UpdateNormals guesses you want. However, here is a lazy fix without doing that.
Graphics3D 640,480,0,2
cam = CreateCamera()
TurnEntity cam,90,0,0
MoveEntity cam,0,0,-10
CameraZoom cam, 5
lit = CreateLight()
TurnEntity lit,90,0,0
square = CreateMesh()
ripsurf = CreateSurface(square)
v1 = AddVertex(ripsurf,-1,0,-1)
v2 = AddVertex(ripsurf,-1,0,1)
v3 = AddVertex(ripsurf,1,0,-1)
v4 = AddVertex(ripsurf,1,0,1)
AddTriangle(ripsurf,v1,v2,v3)
AddTriangle(ripsurf,v2,v4,v3)
; We have a one-sided square with no normals defined. Now apply quick and dirty fix.
UpdateNormals square
temp = CopyMesh(square)
FlipMesh temp
AddMesh temp, square
FreeEntity temp
EntityColor square,255,0,0
EntityShininess square,1
While Not KeyDown(1)
TurnEntity square,1,0,0
RenderWorld
Flip
Wend
|