Is there a way to check the strength of a collision between two objects? Im working on a game and I want a object made of wood to break if hit with a certain strength, and I want an object made of metal to bend if is hit really hard. Is this possible with bullet?
Btw. how can I place an ID in a certain type of object so I can check what sort of material is made of?
strength of a crash?
-
- Posts: 4
- Joined: Sat Jul 05, 2008 12:10 am
Re: strength of a crash?
p.s.
btw, I do know how to "break" and "bend" the object itself, I change the entity of the object for a broken or bended one. I know they are more complex ways to do it but that trick is ok for now.
btw, I do know how to "break" and "bend" the object itself, I change the entity of the object for a broken or bended one. I know they are more complex ways to do it but that trick is ok for now.
-
- Posts: 72
- Joined: Fri Apr 04, 2008 6:07 pm
Re: strength of a crash?
I'm interested in this too. I'd like to play a sound when a block falls and hits the level mesh then not have it repeat forever since the block is still touching the level mesh.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: strength of a crash?
You can use a contact processed callback, or traverse the contact points. Each contact point stores the most recent applied impulse (getAppliedImpulse). Note that you might need to use the internal tick callback, to avoid missing collisions (See btDynamicsWorld::setInternalTickCallback).s there a way to check the strength of a collision between two objects? Im working on a game and I want a object made of wood to break if hit with a certain strength, and I want an object made of metal to bend if is hit really hard. Is this possible with bullet?
Each Bullet object (collision object, soft body and rigid body) can store user information, see btCollisionObject::setUserPointer/getUserPointer.Btw. how can I place an ID in a certain type of object so I can check what sort of material is made of?
Hope this helps,
Erwin
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: strength of a crash?
cobolt_dink wrote:I'm interested in this too. I'd like to play a sound when a block falls and hits the level mesh then not have it repeat forever since the block is still touching the level mesh.
See http://www.bulletphysics.com/Bullet/wor ... ual-worlds
Hope this helps,
Erwin
-
- Posts: 72
- Joined: Fri Apr 04, 2008 6:07 pm
Re: strength of a crash?
I'm already using DirectSound for all my playback. I just want to know when there has been a collision with enough force that a sound should be played. m_appliedImpulse seems like it would be the ticket but its always zero inside the contact added callback.
*edit*
I even quickly just changed it over to the contact processed callback and the impulse is still zero.
I see there is the internal tick callback. Not quite sure how to use it or how to be able to pass any data from it into the actual contact callback.
*edit*
I even quickly just changed it over to the contact processed callback and the impulse is still zero.
I see there is the internal tick callback. Not quite sure how to use it or how to be able to pass any data from it into the actual contact callback.
-
- Posts: 72
- Joined: Fri Apr 04, 2008 6:07 pm
Re: strength of a crash?
Does m_appliedImpulse even work at all with the regular collision or do you need to use continuous? I hacked my program so that btDynamicsWorld world is a global pointer so I could access it inside the tick callback and even inside the tick callback the impulse is zero. Tried with constant linear velocity and central impulse.
-
- Posts: 69
- Joined: Sat May 10, 2008 8:39 am
Re: strength of a crash?
We have the exact same problem. Mostly the p_cp.m_appliedImpulse which is passed to the contactAdded callback, is zero. Rendering the contact callback a bit useless. Is there perhaps another way to determine the exact applied impulse?