EntityLODLevel ( entity[,camera] )

Parameters

entity - mesh entity

camera (optional) - camera to ask about; 0 uses the last camera drawn by RenderWorld (default)

Description

Returns which level of detail a camera last chose for a mesh.

0 is the full mesh and 1 and up are its levels, hand-made or made by AutoEntityLODs. -1 means that camera has not chosen a level for this mesh yet, for example because the mesh has been hidden or beyond its EntityCullRange since it got its levels. A choice stays until the camera chooses again. A mesh without levels returns 0.

Read it after RenderWorld, which is when the choice is made. Each camera chooses for itself, so in split-screen the two players' views can draw different levels of the same tree. While two levels fade into each other, this is the one the choice has settled on.

Use it in a debug overlay, or to save work on things far away: a rock drawn at its simplest version is too far for its sparkle particles to matter.

See also: AutoEntityLODs, ForceEntityLOD, EntityLODDistance, RenderLODSelections, CountEntityLODs.

Example

; EntityLODLevel 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

wire=False

While Not KeyDown(1)

    ; Space shows the triangles
    If KeyHit(57) Then wire=Not wire
    WireFrame wire

    For n=0 To 9
        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   Space: wireframe   Esc: exit"
    Text 0,20,"Version each boulder used (0 = full detail, -1 = not drawn yet):"
    ; Read after RenderWorld: the choice this camera just made
    For n=0 To 9
        Text 0,40+n*20,"EntityLODLevel(rock "+(n+1)+",camera) = "+EntityLODLevel(rocks(n),camera)
    Next

    Flip

Wend

End

Index