; FlipMesh Example ; ---------------- ; Triangles are one-sided. FlipMesh reverses every triangle in a mesh ; so it faces the other way - the classic trick for sky domes: flip a ; giant sphere and view it from the inside. Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() ; A huge sphere surrounding the camera, painted with a sky texture sky=CreateSphere() ScaleEntity sky,100,100,100 sky_tex=LoadTexture("media/sky.bmp") EntityTexture sky,sky_tex EntityFX sky,1 ; The documented command: turn the sphere inside-out so its faces ; point INWARDS, towards our camera FlipMesh sky flipped=1 While Not KeyDown(1) ; Space flips the mesh again - unflipped, the faces point away ; from us and the whole sky disappears If KeyHit(57) Then FlipMesh sky : flipped=1-flipped ; Arrow keys look around If KeyDown(200) Then TurnEntity camera,-1,0,0 If KeyDown(208) Then TurnEntity camera,1,0,0 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Space: FlipMesh again Arrow keys: look around Esc: exit" If flipped Then Text 0,20,"Flipped: faces point inwards - a perfect sky dome" Else Text 0,20,"Not flipped: faces point outwards - invisible from inside!" EndIf Flip Wend End