ClearEntityLODs entity
Parameters
| entity - mesh entity whose levels of detail are removed |
Description
|
Removes every level of detail from an entity and goes back to its base mesh. The entity draws its full-detail mesh again at any distance, and the references it was holding to the replacement meshes are released. Use it when the LOD table no longer suits the entity - a building that was a background prop and has now become the level the player walks through, or a hero object you want to show at full quality for a cut scene. It is also how you rebuild a table. AddEntityLOD insists on strictly increasing distances and there is no command to remove a single level, so if you want to re-tune the distances - for a quality setting in your options menu, say - clear the table and add the levels again from scratch. Gotcha: this does not touch EntityCullRange. An entity that was set to vanish past 180 units still vanishes there; clear the cull range separately by setting it to 0. Calling this on an entity that has no levels registered is harmless. Requires Extended mode. See also: AddEntityLOD, EntityCullRange, RenderLODSelections, CopyEntity. |
Example
; ClearEntityLODs 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 AddEntityLOD tree,tree_mid,10 AddEntityLOD tree,tree_far,20 ; A forest of copies - CopyEntity copies the complete LOD table Dim trees(59) For n=0 To 59 trees(n)=CopyEntity(tree) PositionEntity trees(n),(n Mod 6)*4-10,0,(n/6)*5 Next HideEntity tree HideEntity tree_mid HideEntity tree_far lods_on=True While Not KeyDown(1) ; Space strips or re-registers the LOD table on every tree If KeyHit(57) lods_on=Not lods_on For n=0 To 59 If lods_on AddEntityLOD trees(n),tree_mid,10 AddEntityLOD trees(n),tree_far,20 Else ClearEntityLODs trees(n) EndIf Next EndIf ; 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 Space: toggle LODs Esc: exit" If lods_on Text 0,20,"LODs registered: amber from 10 units, red from 20" Else Text 0,20,"ClearEntityLODs called - every tree uses its base mesh" EndIf Text 0,40,"Trees drawn with a LOD mesh: "+RenderLODSelections() Flip Wend End
Index