AddTorque
This function adds torque (angular force) to an entity.
Syntax
- void AddTorque(float x, floaty, float z, bool global = true)
- void AddTorque(const Vec3& torque, bool global = true)
Parameters
- x: x component of the torque to add.
- y: y component of the torque to add.
- z: z component of the torque to add.
- torque: the torque to add.
- global: if set to true, the torque will be added in global space. Set this to false to use local space.
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, -6);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);
//Create the ground
Model* ground = Model::Box(10, 1, 10);
ground->SetPosition(0, -0.5, 0);
ground->SetColor(0.0, 1.0, 0.0);
//Create a shape
Shape* shape = Shape::Box(0, 0, 0, 0, 0, 0, 10, 1, 10);
ground->SetShape(shape);
shape->Release();
//Create a model
Model* model = Model::Box(10, 1, 1);
model->SetPosition(0, 0.5, 0);
model->SetColor(0.0, 0.0, 1.0);
model->SetMass(1);
//Create a shape
shape = Shape::Box(0, 0, 0, 0, 0, 0, 10, 1, 1);
model->SetShape(shape);
shape->Release();
//Add some torque
model->AddTorque(10000, 0, 0);
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
}