GetViewRange
This function gets an entity's view range.
Syntax
Returns
Returns the entity view range. This will be one of the following values:
Example
#include "Leadwerks.h"
using namespace Leadwerks;
Entity* entity[3] = { 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->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(0,1), Math::Rnd(0, 1), Math::Rnd(0, 1));
}
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(0, 1), Math::Rnd(0, 1), Math::Rnd(0, 1));
}
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(0, 1), Math::Rnd(0, 1), Math::Rnd(0, 1));
}
box->Release();
while (true)
{
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 0;
}