SetRange

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

Syntax

Parameters

Example

#include "Leadwerks.h"

using namespace Leadwerks;

Light* light = NULL;
int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
World* world = World::Create();
Camera* camera = Camera::Create();
camera->SetRotation(35,0,0);
camera->Move(0,0,-8);

//Create a model
Model* 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)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;

float deltarange = (window->KeyDown(Key::Up) - window->KeyDown(Key::Down)) * Leadwerks::Time::GetSpeed() * 0.1;
float range = light->GetRange().y;
range += deltarange;
range = Math::Max(range,0.7);
light->SetRange(range);

Leadwerks::Time::Update();
world->Update();
world->Render();

context->SetBlendMode(Blend::Alpha);
context->DrawText("Light range: "+String(light->GetRange(.y)),2,2);

context->Sync();
}
return 0;
}