# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Posted: Fri Aug 03, 2012 7:48 pm

Joined: Fri Aug 03, 2012 2:18 pm
Posts: 3
Hi,

I have implemented collision on wall segments (single .dae model) in a game using
bullet physics. Now I want the wall to have a door, and to open and let the player through,
so basically create a hole in the shape. There is a wall model with a door that is animated already.

What would be best practice here?
- Remove the RigidBody from the collisionWorld and add a new one when door opens/closes
- track it outside the world by reference and somehow manipulate the sub shape (I'm assuming this will need a CompoundShape)

Is there some other approach that is better?

Best regards
Andreas
Hobby programmer

Top

 Posted: Tue Aug 07, 2012 4:22 am

Joined: Tue Aug 07, 2012 3:27 am
Posts: 6
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)
//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.

Last edited by Shogo on Fri Aug 17, 2012 1:13 pm, edited 1 time in total.

Top

 Posted: Wed Aug 08, 2012 11:14 pm

Joined: Sat Nov 26, 2011 5:41 pm
Posts: 22
andreas wrote:
Hi,
What would be best practice here?
- Remove the RigidBody from the collisionWorld and add a new one when door opens/closes
- track it outside the world by reference and somehow manipulate the sub shape (I'm assuming this will need a CompoundShape)

Is there some other approach that is better?

Usually it is better to remove the body and insert a new, modified body. There are some issues/bugs with trying to change the shape of existing objects in some situations.. you'll think it works and then it'll bug out somewhere else..

Or use a real simulated physical door like the other poster suggested.

Top

 Posted: Thu Feb 21, 2013 7:55 pm

Joined: Wed Feb 20, 2013 6:14 am
Posts: 6
how to converts an axis vector, or direction vector, from the world coordinate system to a body's local coordinate system ?

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 4 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 10 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities