; MeshCullBox Example ; ------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-12 light=CreateLight() RotateEntity light,45,45,0 ; A long fence welded into ONE mesh, 40 units wide but centred on the origin fence=CreateMesh() For i=0 To 20 post=CreateCube() ScaleMesh post,0.4,1.5,0.4 PositionMesh post,i*2-20,0,0 AddMesh post,fence FreeEntity post Next ; Half-size of the box the renderer tests against the view frustum half#=20.0 While Not KeyDown(1) ; [ and ] shrink and grow the cull box If KeyDown(26) And half>0.5 Then half=half-0.2 If KeyDown(27) And half<20 Then half=half+0.2 ; Corner plus width/height/depth, in the mesh's own local space MeshCullBox fence,-half,-half,-half,half*2,half*2,half*2 ; The fence drifts across the view all by itself PositionEntity fence,Sin(MilliSecs()/20.0)*22,0,0 ; 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,"[ / ]: resize the cull box Arrows: camera Esc: exit" Text 0,20,"MeshCullBox fence,"+(-half)+","+(-half)+","+(-half)+","+(half*2)+","+(half*2)+","+(half*2) Text 0,40,"TrisRendered() = "+TrisRendered()+" (0 means the fence was culled away)" Text 0,60,"Shrink the box and the fence pops out while it is still on screen" Flip Wend End