GetMatrix
This function gets an entity's 4x4 matrix.
Syntax
- Mat4 GetMatrix(bool global = true)
Parameters
- global: if set to true, the global entity matrix will be returned. Otherwise, a matrix will be constructed from the local position, rotation, and scale and returned.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
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->SetRotation(35, 0, 0);
camera->Move(0, 0, -5);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);
//Create a model
Entity* entity = Model::Box();
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Leadwerks::Time::Update();
world->Update();
world->Render();
entity->Turn(Leadwerks::Time::GetSpeed()*0.1, Leadwerks::Time::GetSpeed()*0.2, Leadwerks::Time::GetSpeed()*0.3);
//Display the matrix on screen
context->SetBlendMode(Blend::Alpha);
Mat4 mat = entity->GetMatrix();
context->DrawText("Row 0: " + mat[0].ToString(), 2, 2);
context->DrawText("Row 1: " + mat[1].ToString(), 2, 22);
context->DrawText("Row 2: " + mat[2].ToString(), 2, 42);
context->DrawText("Row 3: " + mat[3].ToString(), 2, 62);
context->Sync();
}
}