GetConeAngles

This function gets the outer and inner cone angles of a spotlight.

Syntax

Returns

The spotlight outer and inner cone angles in the X and Y components of the returned Vec2, respectively.

Example

#include "Leadwerks.h"

using namespace Leadwerks;
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);

SpotLight* light = SpotLight::Create();
light->SetPosition(0, 3, 0);
light->Turn(90, 0, 0);
light->SetConeAngles(10, 7.5);

while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;

float delta = (window->KeyDown(Key::Up) - window->KeyDown(Key::Down)) * Leadwerks::Time::GetSpeed() * 0.1;
Vec2 angles = light->GetConeAngles();
angles.x += delta;
angles.x = Math::Clamp(angles.x, 1, 45);
angles.y = angles.x * 0.75;
light->SetConeAngles(angles.x, angles.y);

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

context->SetBlendMode(Blend::Alpha);
context->DrawText("Cone angles: " + angles.ToString(), 2, 2);

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