|
entity - mesh entity, or a parent of mesh entities, whose level moves level - the level of detail, from 1 to CountEntityLODs distance# - how far from the camera the level takes over, in world units camera (optional) - the camera the distance is for; 0 uses the camera drawn last, or before any has drawn a full HD view at CameraZoom 1 (default) |
|
Moves where a level of detail takes over. Simpler versions switch where their loss of detail would look smaller than a pixel. That is a good start, but you know your game: a racing game's trackside trees can drop detail early, a museum's statues late. SetEntityLODDistance puts a level's switch where you want it, and EntityLODDistance reads it back. For levels from AutoEntityLODs, SimplifyEntityLOD and SetEntityLODMesh, the distance is turned into the loss of detail that switches there, for that camera's viewport and zoom. So the switch still follows the view: a camera half as wide, or zoomed out, switches nearer, and an entity scaled up twice switches twice as far away. For hand-made levels from AddEntityLOD it is the distance itself. Levels stay in order: a distance nearer than the level before, or further than the one after, is an error. The new switch belongs to the mesh and the copies you make from it afterwards, and SaveMesh keeps it in the file. The World Editor's Prepare Model tab sets these distances for a full HD view. See also: EntityLODDistance, SimplifyEntityLOD, SetEntityLODMesh, AutoEntityLODs, EntityLODTransition. |
; SetEntityLODDistance Example
; ----------------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
PositionEntity camera,0,1,-6
light=CreateLight()
RotateEntity light,45,45,0
; A detailed pickup with a much simpler version
gem=CreateSphere(32)
ScaleMesh gem,0.8,1.2,0.8
EntityColor gem,80,200,255
SimplifyEntityLOD gem,1,0.05
; Where the simpler version takes over, in metres from the camera
switch#=10
SetEntityLODDistance gem,1,switch,camera
wire=True
While Not KeyDown(1)
; [ / ] bring the switch nearer or push it further away
change#=0
If KeyHit(26) And switch>2 Then change=-2
If KeyHit(27) And switch<40 Then change=2
If change<>0
switch=switch+change
SetEntityLODDistance gem,1,switch,camera
EndIf
; Space shows the triangles
If KeyHit(57) Then wire=Not wire
WireFrame wire
TurnEntity gem,0,1,0
; 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 [ / ] : move the switch Space: wireframe Esc: exit"
Text 0,20,"SetEntityLODDistance gem,1,"+switch+",camera (EntityLODDistance says "+Int(EntityLODDistance(gem,1,camera))+")"
Text 0,40,"Camera "+Int(EntityDistance(camera,gem))+" m away: drawing level "+EntityLODLevel(gem,camera)
Flip
Wend
End