
This seems like a useful feature and I'm surprised it hasn't been implemented yet.
Is there any easy way to calculate the force in an OnCollision event, or do I need to use some external method (such as discussed in http://farseerphysics.codeplex.com/Thread/View.aspx?ThreadId=21011)? If using the separation value, how would I translate
that into a force that is in the scope of Farseer's force values? I believe separation is how much one geometry would have penetrated the other, is that correct? Therefore the greater the separation, the greater the force, but I still need some
way to convert that back to the amount of force that was applied at that point.
It would be nice to just be able to grab a force value at each contact point and be able to sum them to find a "net force" for example.
Thanks 



Sorry for the lack of replies. As i understand it, an impulse is applied based on the amount of interpenetration for each contact point. So basically, it'll take some math but i think it can be done.



Having a convenient helper function for this would be really useful. I think it is a pretty common problem  inflicting collision damage, deciding how loudly to play a collision sound, etc.
Presumably the code is there in the engine, since it has to calculate the collision response. It would just need to be wrapped up and made accessible.



I agree that it would be very useful to have it easily available in OnCollision. Maybe a field in each Contact that you can sum up to find the total force, or something like that.
I've been messing around with calculating it based on separation. I can see how it will work, but I'm kind of flaky on the formula to convert separation to force. What exactly is separation? Is it affected by the Body's parameters such as
mass or restitution coefficient? I guess the force comes out to be something like (total_separation * mass). Does that sound right?
In my game I am flinging objects at a platform and trying to determine the force that the object had on the platform. The platform is is suspended in the air by two joints  a fixed angle joint and a fixed revolute joint (to fix it in place rotationally
and prevent it from falling). I've found that if the foreign object collides near the joints, the separation value is less than it is if the object collides near the edges of the object (further from the joints). This is expected, I suppose.
It just tends to be problematic in my situation. I think I may switch the platform to be a static object instead of using joints to hold it in place and see if that works better.


Coordinator
Apr 4, 2009 at 12:16 AM

The contact system is not really suitable to do stuff like that. It works like this:
Arbiters contains 2 geometries that are in the vicinity of each other.
When the 2 geometries collide (determined by the narrow phase collision system) a contact is created.
The contact (or contacts) calculate the amount of penetration (called separation ) the geometries have and the impulse required to move the 2 geometries from each other.
It does not use force, it uses impulse. An instant change in velocity regardless of time (sort of).
You can use the separation value as some kind of "force". The more separation (penetration) the more life will be taken from your units. Beware that the timestep of the engine will need to be fixed for this to work consistently. It can also give problems
if your game starts to slow down. (more separation will occur).
Anyway, separation is just the quick and dirty way of doing it. You can always calculate the force on impact. Our good friend Newton has what is called Newton's second law: F = m*a
where F is force, m is mass and a is acceleration.
Acceleration is defined as a = dv/dt
where dv is deltavelocity and dt is deltatime.
You have your timestep (dt) and you have the velocity of the object (body.LinearVelocity). That should be all you require to calculate the force on impact.
I usually just look at the amount of linearvelocity an object have on impact: (1/body.LinearVelocity * magnitude) (You don't have to use magnitude) and remove the HP (Health Points) according to the value I obtain. But it all depend on how your game is put
together and if you are going to feed the "force factor" into the physics engine.

