| entity - entity handle |
|
Returns how an entity would take part in a bake now: LIGHTMAP_OFF (0), LIGHTMAP_ON (1) or LIGHTMAP_CONTRIBUTE (2). For an entity left automatic, it gives what the automatic rules decide today, so it changes when the entity gains collisions or a body. Entities that are not meshes or terrains give LIGHTMAP_OFF. Small objects count at the current LightBakeQuality and LightBakeDetail. See also: EntityLightmap, EntityLightmapReason, BakeLighting. |
; EntityLightmap Example
; ----------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
PositionEntity camera,0,2.5,-5
RotateEntity camera,20,0,0
AmbientLight 10,10,16
; The floor and a red wall are static scenery: they bake into lightmaps
ground=CreateCube()
ScaleEntity ground,3,0.1,3
wall=CreateCube()
ScaleEntity wall,0.1,1.5,3
PositionEntity wall,-2.5,1.5,0
EntityColor wall,230,40,30
; A crate the player can push must not be baked, or its shadow would stay
; behind when it moves: light probes light it instead
crate=CreateCube()
ScaleEntity crate,0.4,0.4,0.4
PositionEntity crate,0,0.5,0
EntityColor crate,200,170,120
EntityLightmap crate,LIGHTMAP_OFF
; A small bolt on the wall casts baked shadows but probes light it
bolt=CreateSphere(8)
ScaleEntity bolt,0.08,0.08,0.08
PositionEntity bolt,-2.35,1.5,-1
EntityLightmap bolt,LIGHTMAP_CONTRIBUTE
; A warm lamp, fully baked, so the crate takes its light from the probes
lamp=CreateLight(2)
PositionEntity lamp,0.5,2.5,0
LightRange lamp,3
LightColor lamp,255,220,170
LightBakeMode lamp,LIGHT_BAKED
; Probes a unit apart through the room, and closer together over the floor,
; where the crate goes
LightProbeSpacing 1
LightProbeVolume 0,0.75,0,6,1.5,6
LightBakeQuality 0
bake=BakeLighting()
While LightBakeState(bake)=LIGHT_BAKE_RUNNING
RenderWorld
Text 0,0,"Baking: "+(LightBakeProgress(bake)/10)+"%"
Flip
Wend
FreeLightBake bake
probes=True
While Not KeyDown(1)
; The crate slides to and fro; near the red wall its probes turn it red
PositionEntity crate,Sin(MilliSecs()/20.0)*1.8,0.5,0
; Space switches the crate's probe lighting off and on
If KeyHit(57) Then
probes=Not probes
EntityLightProbes crate,probes
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: crate's probes on/off Esc: exit"
Text 0,20,"Wall: mode "+EntityLightmapMode(wall)+" because "+EntityLightmapReason(wall)
Text 0,40,"Crate: mode "+EntityLightmapMode(crate)+" because "+EntityLightmapReason(crate)
Text 0,60,"Bolt: mode "+EntityLightmapMode(bolt)+" because "+EntityLightmapReason(bolt)
Text 0,80,"EntityLightProbes crate,"+probes
Flip
Wend
End