SetRange

This function sets a light's range. You can retrieve the light range with the Camera::GetRange() function.

Syntax

Parameters

Example

--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
camera:SetRotation(35,0,0)
camera:Move(0,0,-8)

--Create a model
local model = Model:Box()
model:SetColor(0.0,1.0,0.0)
model:SetScale(10,1,10)

light = PointLight:Create()
light:SetPosition(0,1,0)

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

local deltarange = ((window:KeyDown(Key.Up)and 1 or 0) - (window:KeyDown(Key.Down)and 1 or 0)) * Time:GetSpeed() * 0.1
local range = light:GetRange().y
range = range + deltarange
range = Math:Max(range,0.7)
light:SetRange(range)

Time:Update()
world:Update()
world:Render()
context:SetBlendMode(Blend.Alpha)
context:DrawText("Light range: "..light:GetRange().y,2,2)

return true
end