; EntityCullRange 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 glowing marker crystal, copied into a long avenue ahead of the camera crystal=CreateSphere(8) ScaleMesh crystal,0.8,1.6,0.8 PositionMesh crystal,0,1.6,0 EntityColor crystal,80,200,255 Dim crystals(59) For n=0 To 59 crystals(n)=CopyEntity(crystal) PositionEntity crystals(n),(n Mod 4)*6-9,0,(n/4)*4 Next HideEntity crystal cull_range#=30 While Not KeyDown(1) ; Press [ / ] to change the cull distance (0 disables culling) If KeyDown(26) And cull_range>0 Then cull_range=cull_range-0.25 If KeyDown(27) And cull_range<100 Then cull_range=cull_range+0.25 ; Apply the rendering cull distance to every crystal For n=0 To 59 EntityCullRange crystals(n),cull_range Next ; Arrow keys move the camera 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 Text 0,0,"Arrow keys: move camera [ / ] : cull distance Esc: exit" If cull_range>0 Text 0,20,"EntityCullRange crystal,"+cull_range Else Text 0,20,"EntityCullRange crystal,0 (culling disabled)" EndIf Text 0,40,"Crystals culled this frame: "+RenderCulledEntities()+" of 60" Flip Wend End