SetPosition
Sets the position of an entity in 3-dimensional space, using local or global coordinates.
Syntax
- void SetPosition(const float x, const float y, const float z, const bool global = false)
- void SetPosition(const Vec3& position, const bool global = false)
Parameters
- x: X component of the specified position.
- y: Y component of the specified position.
- z: Z component of the specified position.
- position: the position to set.
- global: indicates whether the position should be set in global or local space.
Remarks
An entity can be positioned in local or global coordinates. Local coordinates are relative to the entity parent's space.
If the entity does not have a parent, local and global coordinates are the same.
Leadwerks uses a left-handed coordinate system.  This means that if you hold your left hand as shown below, your middle finger, index finger, and thumb will point in the directions of the X, Y, and Z axes, respectively.
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, -4);
    Light* light = DirectionalLight::Create();
    light->SetRotation(35, 35, 0);
    //Create a model
    Model* model = Model::Box();
    while (true)
    {
        if (window->Closed() || window->KeyDown(Key::Escape)) return false;
        model->SetPosition(Math::Sin(Leadwerks::Time::GetCurrent() / 10.0), 0, 0);
        Leadwerks::Time::Update();
        world->Update();
        world->Render();
        context->SetBlendMode(Blend::Alpha);
        context->DrawText(model->GetPosition().ToString(), 2, 2);
        context->Sync();
    }
    return 0;
}