Hello, I'm new to bullet but I did something similar in the game I'm working on so maybe I can help. (I have a door that the player can push to open/close.)
You can use a "spDoorHinge" constraint from the bullet Constraints Demo. I have the wall with the hole for the door and the door is just a btRigidbody in the shape of a door with a btHingeConstraint applied to it.
So my code to create/add the door to the dynamicsworld is something like this:
Code:
//door
btCollisionShape* pDoorShape = new btBoxShape(btVector3(5.0f, 5.9f, 0.5f)); //the door shape
trans.setIdentity();
trans.setOrigin(btVector3(105.0f, 2.0f, 29.5f)); //position of the door
motionState = new btDefaultMotionState(trans);
pDoorBody = new btRigidBody(btScalar(1.0), motionState, pDoorShape, btVector3(1,1,1)); //mass=1.0
const btVector3 btPivotA(4.8f , 0.0f, 0.0f ); // position of the door pivot
btVector3 btAxisA( 0.0f, 1.0f, 0.0f ); // pivot pointing up Y-axis (rotate on Y axis)
btHingeConstraint* spDoorHinge;
spDoorHinge = new btHingeConstraint( *pDoorBody, btPivotA, btAxisA );//add HingeConstraint to the door
spDoorHinge->setLimit( -PI * 0.5f, PI * 0.5f ); //set door movement limit from -90° to+90° (PI=3.1415)
dynamicsWorld->addConstraint(spDoorHinge); //add door hinge constraints to the world
dynamicsWorld->addRigidBody(pDoorBody); //add door to the world
//If you want to dampen the movement of the door you can do
pDoorBody->setDamping(1.4f,0.0); // modify the first argument to increase damping strength.
pDoorBody->applyDamping(1.4);
Hope this helps. This is my first post here so hopefully this comes out ok. I tried adding some comments just now hopefully they aren't too confusing...lol
Check the Constraint Demo for the btHingeConstraint.