Point

This function points an entity at another 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* entity1 = NULL;
Entity* entity2 = NULL;

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

//Create a model
entity1 = Model::Box();
entity1->SetColor(0.0,0.0,1.0);
entity1->SetRotation(0,-90,0);

//Create another model to point at the one that goes in circles
entity2 = Model::Box();
entity2->SetColor(0.0,1.0,0.0);
entity2->SetPosition(0,0,2);

return true;
}

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

//Make the model move in a circle
entity1->Turn(0,Leadwerks::Time::GetSpeed()*0.5,0);
entity1->Move(0,0,0.1);

//Point this at the moving box when the space key is pressed
if (window->KeyDown(Key::Space))
{
entity2->Point(entity1,2,Leadwerks::Time::GetSpeed()*0.1);
}

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

return true;
}