I viewed the SliderConstraintDemo to understand how to use it, and of course I also viewed the ConstraintDemo. I have this on my code so far:
Code: Select all
btRigidBody *base = addBox(btVector3(0, -1, 0), 44.f, 2.f, 2.f, 0.f);
btRigidBody *car = addBox(btVector3(0, 0, 0), 2.f, 2.f, 2.f, 1.f);
Code: Select all
btRigidBody* InvertedPendulum::addBox(btVector3 origin, float width, float height, float depth, float mass) {
btTransform t;
t.setIdentity();
t.setOrigin(origin);
btBoxShape* box = new btBoxShape(btVector3(width / 2.0, height / 2.0, depth / 2.0));
collisionShapes.push_back(box);
btVector3 inertia(0, 0, 0);
if (mass != 0.0)
box->calculateLocalInertia(mass, inertia);
btMotionState* motion = new btDefaultMotionState(t);
btRigidBody::btRigidBodyConstructionInfo info(mass, motion, box, inertia);
btRigidBody* body = new btRigidBody(info);
world->addRigidBody(body);
return body;
}
Code: Select all
btTransform frameInA, frameInB;
frameInA = btTransform::getIdentity();
frameInB = btTransform::getIdentity();
frameInA.setOrigin(btVector3(0.5, 0, 0));
frameInB.setOrigin(btVector3(0.5, 0, 0));
spSlider = new btSliderConstraint(*base, *car, frameInA, frameInB, true);
spSlider->setLowerLinLimit(loSliderLimit);
spSlider->setUpperLinLimit(hiSliderLimit);
world->addConstraint(spSlider,true);
So that's it guys. I hope you can give me a hand with this.