LightColor light,red#,green#,blue#
Parameters
|
light - light handle red# - red value of light green# - green value of light blue# - blue value of light |
Description
|
Sets the colour of a light. The default colour is white, 255,255,255. An r,g,b value of 255,255,255 will brighten everything the light shines on; 0,0,0 will have no effect at all. Tinted lights sell a scene instantly - a warm orange point light for a torch, a cold blue directional light for moonlight, a flickering red for danger. Values are not limited to 0-255. Negative values darken whatever the light shines on: an r,g,b of -255,-255,-255 subtracts light instead of adding it. This 'negative lighting' is useful for cheap shadow and gloom effects - park a negative point light in a corner to create a pool of darkness. Values above 255 overbrighten. See also: CreateLight, LightRange, LightConeAngles, AmbientLight. |
Example
; LightColor Example ; ------------------ Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,6,-14 RotateEntity camera,20,0,0 ; Keep ambient light low so the coloured light stands out AmbientLight 16,16,16 ; Point lights need well-tessellated geometry to show up, so use a ; subdivided plane and a high-segment sphere ground=CreatePlane(16) statue=CreateSphere(24) PositionEntity statue,0,1,0 ; A point light circling the statue light=CreateLight(2) ; A small full-bright marker sphere rides on the light so we can see it marker=CreateSphere(8,light) ScaleEntity marker,0.2,0.2,0.2 EntityFX marker,1 red=255 green=255 blue=255 angle#=0 While Not KeyDown(1) ; Hold keys 1/2, 3/4, 5/6 to lower and raise the red, green and blue values If KeyDown(2) And red>0 Then red=red-2 If KeyDown(3) And red<255 Then red=red+2 If KeyDown(4) And green>0 Then green=green-2 If KeyDown(5) And green<255 Then green=green+2 If KeyDown(6) And blue>0 Then blue=blue-2 If KeyDown(7) And blue<255 Then blue=blue+2 ; Apply the colour to the light, and tint the marker to match LightColor light,red,green,blue EntityColor marker,red,green,blue ; Circle the light around the statue angle=angle+1 PositionEntity light,Cos(angle)*5,3,Sin(angle)*5 ; 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,"Keys 1-6: change red/green/blue Arrow keys: move camera Esc: exit" Text 0,20,"LightColor light,"+red+","+green+","+blue Flip Wend End
Index