; AddEntityLOD 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 ; Each detail level is painted its own colour so switches are easy to spot green_brush=CreateBrush(60,200,80) amber_brush=CreateBrush(230,180,50) red_brush=CreateBrush(220,70,60) ; Detailed base tree, plus two cruder stand-in meshes tree=CreateSphere(16) ScaleMesh tree,1,2,1 PositionMesh tree,0,2,0 PaintMesh tree,green_brush tree_mid=CreateSphere(6) ScaleMesh tree_mid,1,2,1 PositionMesh tree_mid,0,2,0 PaintMesh tree_mid,amber_brush tree_far=CreateCube() ScaleMesh tree_far,0.9,1.8,0.9 PositionMesh tree_far,0,1.8,0 PaintMesh tree_far,red_brush ; Register the LOD levels: amber takes over at 12 units, red at 24 AddEntityLOD tree,tree_mid,12 AddEntityLOD tree,tree_far,24 ; A forest of copies - CopyEntity copies the complete LOD table For n=0 To 59 copy=CopyEntity(tree) PositionEntity copy,(n Mod 6)*4-10,0,(n/6)*5 Next HideEntity tree HideEntity tree_mid HideEntity tree_far While Not KeyDown(1) ; 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 Esc: exit" Text 0,20,"Green=base mesh Amber=LOD from 12 Red=LOD from 24" Text 0,40,"Trees drawn with a LOD mesh: "+RenderLODSelections() Flip Wend End