Box2D Forums

It is currently Sat May 25, 2013 8:06 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Collision strength
PostPosted: Sat Nov 14, 2009 3:01 pm 
Offline

Joined: Fri Oct 16, 2009 12:01 am
Posts: 7
Having a problem getting the collision strength as its always zero. Doesn't matter if a body his a static object or another dynamic body. This is the code for trying to get the strength:

Code:
void Physics::BeginContact(b2Contact *contact)
{
   b2Manifold *manifold = contact->GetManifold();

   float strength = 0;
   for (int i=0; i<manifold->m_pointCount; ++i)
      strength = manifold->m_points[i].m_normalImpulse;

   strength = strength/manifold->m_pointCount;
}


Am I doing something wrong? Or has there been no strength calculated yet? If it hasn't been calculated yet where am I supposed to get the info?


Top
 Profile  
 
 Post subject: Re: Collision strength
PostPosted: Sat Nov 14, 2009 6:06 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
You need to use the post-solve callback.


Top
 Profile  
 
 Post subject: Re: Collision strength
PostPosted: Sun Nov 15, 2009 12:00 pm 
Offline

Joined: Fri Oct 16, 2009 12:01 am
Posts: 7
In PostSolve() even checking with the impulse and a linear velocity of the object if you drop a block on a stack of blocks there are a bunch of sounds played at once. Set it too high and then nothing plays when just falling on the ground. Other games have physics based sounds, whats the secret?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Exabot [Bot] and 3 guests


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

Search for:
Powered by phpBB® Forum Software © phpBB Group