Jump to content

Transform::Plane

This function transforms a plane from one space to another.

Syntax

Parameters

Returns

Returns the transformed plane.

Remarks

Due to the ambiguity of this command (the function and class of one member are both called "Plane") the function should always be called so that the individual components of the input plane are specific, when programming in Lua script.  Use the third and fourth overloads of the function shown above in Lua.

Example

C++

#include "App.h"

using namespace Leadwerks;

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

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

Model* model = NULL;

bool App::Start()
{
//Create a window
window = Window::Create();

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

//Create a model
model = Model::Box();
model->SetColor(0.0,0.0,1.0);
model->SetPosition(3,0,0);

return true;
}

bool App::Loop()
{
//Close the window to end the program
if (window->KeyHit(Key::Escape) || window->Closed()) return false;

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

//We're going to transform the plane (1,0,0,0) from global space to the model's local space
//Because the model is positioned at (3,0,0) the plane will be at (1,0,0,3) in local space (relative to the model).
Plane p = Plane(1,0,0,0);
p = Transform::Plane(p,NULL,model);

context->SetBlendMode(Blend::Alpha);
context->DrawText(p.ToString(),2,2);
context->SetBlendMode(Blend::Solid);

context->Sync(false);

return true;
}

Lua

function App:Start()
--Create a window
self.window = Window:Create()
self.context = Context:Create(self.window)
self.world = World:Create()
local camera = Camera:Create()
camera:Move(0,0,-3)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

--Create a model
model = Model:Box()
model:SetColor(0.0,0.0,1.0)
model:SetPosition(3,0,0)

return true
end

function App:Loop()

if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end

Time:Update()
self.world:Update()
self.world:Render()

--We're going to transform the plane (1,0,0,0) from global space to the model's local space
--Because the model is positioned at (3,0,0) the plane will be at (1,0,0,3) in local space (relative to the model).
local p = Transform:Plane(1,0,0,0,nil,model)

self.context:SetBlendMode(Blend.Alpha)
self.context:DrawText(p:ToString(),2,2)
self.context:SetBlendMode(Blend.Solid)

self.context:Sync()

return true
end
  • You cannot edit this record