; RenderCulledEntities Example ; ---------------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,4,-15 CameraClsColor camera,20,30,50 light=CreateLight() RotateEntity light,45,45,0 ground=CreatePlane() EntityColor ground,60,80,55 ; A ring of 80 pillars surrounds the camera, so some are always off screen pillar=CreateCylinder(12) ScaleMesh pillar,0.6,2,0.6 PositionMesh pillar,0,2,0 EntityColor pillar,80,200,255 For n=0 To 79 copy=CopyEntity(pillar) PositionEntity copy,Cos(n*4.5)*(12+(n Mod 4)*8),0,Sin(n*4.5)*(12+(n Mod 4)*8) ; Distance culling: pillars stop rendering 40 units from the camera EntityCullRange copy,40 Next HideEntity pillar While Not KeyDown(1) ; Arrow keys move the camera - turn around to see frustum culling change If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld ; Counts pillars rejected by EntityCullRange or by frustum culling Text 0,0,"Arrow keys: move camera Esc: exit" Text 0,20,"RenderCulledEntities() = "+RenderCulledEntities()+" of 80 pillars" Text 0,40,"Pillars beyond 40 units, or outside the view, are culled" Flip Wend End