ForceEntityLOD entity,level

Parameters

entity - mesh entity

level - level of detail to draw
-1: choose by distance, as every mesh does to begin with
0: the full mesh
1 and up: that level; a level past the last draws the last

Description

Draws one level of detail of a mesh for every camera, whatever the distance.

Use it to look at a simpler version up close and judge it, to keep a far-away object at full detail through a cutscene, or to rule levels of detail out while you chase a drawing problem. It works on hand-made levels and on the versions AutoEntityLODs made, and it stops any fading between levels while it is set. CopyEntity copies the setting.

Gotcha: a mesh forced to full detail costs full price at every distance, so set it back to -1 when you are done. Levels of detail affect drawing only, so forcing one changes nothing for collisions or picks.

See also: EntityLODLevel, AutoEntityLODs, CountEntityLODs, EntityLODTransition, AddEntityLOD.

Example

; ForceEntityLOD Example
; ----------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,2,-6

light=CreateLight()
RotateEntity light,45,45,0

; A detailed boulder: 6,240 triangles
rock=CreateSphere(40)
ScaleMesh rock,1.2,0.8,1
EntityColor rock,150,140,120

; A row of boulders running into the distance
Dim rocks(9)
For n=0 To 9
    rocks(n)=CopyEntity(rock)
    PositionEntity rocks(n),(n Mod 2)*4-2,0,4+n*6
    AutoEntityLODs rocks(n)
Next
HideEntity rock

forced=-1
WireFrame True

While Not KeyDown(1)

    ; 0 draws the full mesh and 1 to 4 a simpler version, everywhere
    If KeyHit(11) Then forced=0
    For version=1 To 4
        ; Keys 1 to 4 have scancodes 2 to 5
        If KeyHit(version+1) Then forced=version
    Next
    ; A chooses by distance again
    If KeyHit(30) Then forced=-1

    For n=0 To 9
        ForceEntityLOD rocks(n),forced
        TurnEntity rocks(n),0,0.2,0
    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   0-4: force a version   A: automatic   Esc: exit"
    Text 0,20,"ForceEntityLOD rock,"+forced+"   (-1 = automatic)"
    Text 0,40,"Triangles drawn: "+TrisRendered()

    Flip

Wend

End

Index