Ball
This function creates a new ball and socket joint.
Syntax
- static Joint* Ball(float posx, float posy, float posz, Entity* child, Entity* parent=NULL)
Parameters
- posx: the x component of the joint position.
- posy: the y component of the joint position.
- posz: the z component of the joint position.
- child: the child entity.
- parent: the parent entity. This may be NULL.
Returns
Returns a new joint.
Example
#include "App.h"
using namespace Leadwerks;
int main(int argc, const char *argv[])
{
Window* window = Window::Create();
Context* context = Context::Create(window);
World* world = World::Create();
float angle = 0;
window = Window::Create();
context = Context::Create(window);
world = World::Create();
Camera* camera = Camera::Create();
camera->Move(0, 0, -4);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);
Entity* parent = Model::Box();
parent->SetColor(0.0, 0.0, 1.0);
Entity* child = Model::Box();
child->SetColor(1.0, 0.0, 0.0);
child->SetShape(Shape::Box());
child->SetMass(1);
child->SetPosition(2, 0, 0);
child->AddTorque(1000, 0, 0);
auto joint = Joint::Ball(0, 0, 0, child, NULL);
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
}