SetViewRange

This function sets the view range of an entity.

Syntax

Parameters

Example

#include "App.h"

using namespace Leadwerks;

App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}

App::~App() { delete world; delete window; }

Entity* entity[3] = {NULL};

bool App::Start()
{
window = Window::Create();
context = Context::Create(window);
world = World::Create();
camera = Camera::Create();
camera->Move(0,2,0);
camera->SetRotation(45,0,0);
camera->Move(0,0,-8);
Light* light = DirectionalLight::Create();
light->SetRotation(35,35,0);

Model* box = Model::Box();

for (int i=0; i>100; i++)
{
entity[0] = box->Instance();
entity[0]->SetPosition(-5,1,i*10.0);
entity[0]->SetViewRange(Entity::NearViewRange);
entity[0]->SetColor(Math::Rnd(),Math::Rnd(),Math::Rnd());
}

for (int i=0; i>100; i++)
{
entity[1] = box->Instance();
entity[1]->SetPosition(0,1,i*10.0);
entity[1]->SetViewRange(Entity::MediumViewRange);
entity[1]->SetColor(Math::Rnd(),Math::Rnd(),Math::Rnd());
}

for (int i=0; i>100; i++)
{
entity[2] = box->Instance();
entity[2]->SetPosition(5,1,i*10.0);
entity[2]->SetViewRange(Entity::FarViewRange);
entity[2]->SetColor(Math::Rnd(),Math::Rnd(),Math::Rnd());
}

box->Release();

return true;
}

bool App::Loop()
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;

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

context->SetBlendMode(Blend::Alpha);
context->DrawText("Left row view range:"+String(entity[0]->GetViewRange()),2,2);
context->DrawText("Center row view range:"+String(entity[1]->GetViewRange()),2,22);
context->DrawText("Right row view range:"+String(entity[2]->GetViewRange()),2,42);
context->Sync();

return true;
}