Vector

This function transforms a vector from one space to another.

Syntax

Parameters

Returns

Returns the transformed vector.

Example

#include "Leadwerks.h"

using namespace Leadwerks;

Model* model = 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,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->SetRotation(0,180,0);
model->SetScale(2);
while (true)
{
if (window->KeyHit(Key::Escape) || window->Closed()) return false;

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

//We're going to transform the vector (1,0,0) from global space to the model's local space
//Because the model is rotated to (0,180,0) and scaled to (2,2,2) the vector will be at (-0.5,0,0) in local space (relative to the model).
Vec3 v = Transform::Vector(1,0,0,NULL,model);

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

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