[ODE] Collision response etc

Byron Wright bslayerw at mindspring.com
Tue Jan 28 19:56:02 2003


I initially attempted that. The problem is that the existence of contact
points does not constitute a "bump" (or high impact). The problem is
that if the object is resting on a ground plane for example,  then the
collision callback is called every time step  (and contact joints are
created) create a horrible array of sound effects. That is why I was
attempting to figure out the forces applied to the objects since that
will most likely help me figure out if the objects are bouncing or have
collided and are not simply resting on/against one another. The problem
still remains that when retrieving the force on a body (in the callback
or not) I still get a result of 0. 

-Byron

-----Original Message-----
From: David Walker [mailto:david.walker530@ntlworld.com] 
Sent: Tuesday, January 28, 2003 6:38 PM
To: Byron Wright
Subject: Re: [ODE] Collision response etc


Hello,

I think the best place to do this is in the collision callback. when you
actually create the contact joints. that would probably be a good place
to play the sound. I don't know for sure because I haven't done this yet
(It's on my list of things to do) but that's how I'm going to tackle it.
I'm also going to put scoring in there somewhere.

Does this make sense?

David


----- Original Message -----
From: "Byron Wright" <bslayerw@mindspring.com>
To: <ode@q12.org>
Sent: Tuesday, January 28, 2003 6:21 PM
Subject: RE: [ODE] Collision response etc


> *bump*.
>
> Anyone have any idea on how I might solve this?
>
> -Byron
>
> -----Original Message-----
> From: ode-admin@q12.org [mailto:ode-admin@q12.org] On Behalf Of Byron 
> Wright
> Sent: Friday, January 24, 2003 5:30 PM
> To: ode@q12.org
> Subject: [ODE] Collision response etc
>
>
> New to ODE, trying to figure out how to play a sound effect when 
> objects collide.
>
> Here are the steps I take to produce a "bump" sound effects.
>
> - do collision detection and response
> - world step
> - check all bodies for contact joints, if they have contact joints and

> their forces are greater than 0 then play a the bump sound effect
>
>
>
> The problem is that after a collision and the contact joints have been

> created the magnitude of the force is alway 0. When should I get be 
> requisting the force from my bodies? Or should I be checking something

> else to find out if the body has been "bumped"?
>
> Here is my update function :
>
> void update(float dt) {
>     dSpaceCollide(space, 0, &NearCallback);
>     dWorldStep (world, dt);
>     //iterate though all boxes, if they have contact joints
(collision)
>     //then play a sound effect if the box's force is greater than 0
>
>     //BodyCollection is = typedef vector<dBodyID> BodyCollection;
>     BodyCollection::iterator it = boxBodies.begin();
>
>     while(it != boxBodies.end()) {
>         int numJoints = dBodyGetNumJoints(*it);
>         if(numJoints > 0) {
>         for(int joints = 0; joints < numJoints; ++ joints) {
>             dJointID joint = dBodyGetJoint (*it, joints);
>                 if(dJointGetType(joint) == dJointTypeContact) {
>                 //it's a contact joint. check force of
> bodies
>                   const dReal * forceA = dBodyGetForce(*it);
>
>       cout << magnitude(forceA) << endl;
>                   if(magnitude(forceA) > 0.05 ) {
>       Mix_PlayChannel(-1,bump,0);
>                   }
>             }
>         }
>
>         }
>        ++it;
>     }
>
>     //remove all contact joints from the system
>     dJointGroupEmpty(contactGroup);
> }
>
> Byron Wright
>
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode
>
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode