Point
This function transforms a point from one space to another.
Syntax
- static Vec3 Point(const Vec3& point, Entity* src, Entity* dst)
- static Vec3 Point(float x, float y, float z, Entity* src, Entity* dst)
- static Vec3 Point(const Vec3& point, const Mat4& src, const Mat4& dst)
- static Vec3 Point(float x, float y, float z, const Mat4& src, const Mat4& dst)
Parameters
- point: the point to be transformed.
- x: the X component of the point to be transformed.
- y: the Y component of the point to be transformed.
- z: the Z component of the point to be transformed.
- src: the source entity or 4x4 matrix to transform the point from.
- dst: the destination entity or 4x4 matrix to transform the point to.
Returns
Returns the transformed point.
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->SetPosition(3,0,0);
while (true)
{
//Close the window to end the program
if (window->KeyHit(Key::Escape) || window->Closed()) return false;
Leadwerks::Time::Update();
world->Update();
world->Render();
//We're going to transform the position (2,0,0) from global space to the model's local space
//Because the model is positioned at (3,0,0) the point will be at (-1,0,0) in local space (relative to the model).
Vec3 position = Transform::Point(2,0,0,NULL,model);
context->SetBlendMode(Blend::Alpha);
context->DrawText(position.ToString(),2,2);
context->SetBlendMode(Blend::Solid);
context->Sync(false);
}
return 0;
}