EntityLODTriangles ( entity,level )

Parameters

entity - mesh entity

level - 0 for the full mesh, or a level of detail from 1 to CountEntityLODs

Description

Returns how many triangles one of a mesh's levels of detail has.

Use it to show what levels of detail save, in a debug overlay or an options screen, or to decide whether a far-away version is cheap enough for a crowd of copies. It counts every surface of that level. For the triangles actually drawn in the last frame, across every entity, use TrisRendered.

Gotcha: a level below 0 or above CountEntityLODs is an error.

See also: CountEntityLODs, AutoEntityLODs, EntityLODLevel, CountTriangles.

Example

; EntityLODTriangles 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=True

While Not KeyDown(1)

    ; Space shows or hides 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"
    ; Level 0 is the full mesh; each simpler version follows
    For l=0 To CountEntityLODs(rocks(0))
        Text 0,20+l*20,"EntityLODTriangles(rock,"+l+") = "+EntityLODTriangles(rocks(0),l)
    Next
    Text 0,140,"Triangles drawn: "+TrisRendered()

    Flip

Wend

End

Index