Move
Sets the position of an entity in 3-dimensional space, using local or global coordinates.
Syntax
- void Move(const Vec3& position, bool global=false)
- void Move(float x, float y, float z, bool global=false)
Parameters
- position: the movement to add.
- x: the X component of the movement to add.
- y: the Y component of the movement to add.
- z: the Z component of the movement to add.
- global: if set to true, the scale of the movement will be in global space, otherwise it will be affected by the entity's own scale.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
Model* model = NULL;
int counter;
void UpdateMatrixHook(Entity* entity)
{
counter++;
}
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,1,-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,-90,0);
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
//Make the model move in a circle
model->Turn(0,Leadwerks::Time::GetSpeed()*0.5,0);
model->Move(0,0,0.1);
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
return 0;
}