This is something I've been wondering about alot.
When two objects collide how do you tell how "hard" they hit each other ?
I know you can make some simple physics formulars to approximate this (velocity*weight I believe)
but that would not always work I think. Imagine two objects just scraping each others surfaces. They would
not collide very hard but the newton formulars would say they did.
Or imagine a 5000 kg giant swinging at something with and axe of 100 kg. Then I dont know how you can calculate the total impact. I mean
the axe is only 100 kg but the total force is something else of course.
Strange thing is that ODE somehow knows the impact since the objects behave right. ODE just dont wanna tell anyone.
From a collision info you can obtain the contact normal n. You can then compute the speed of the object(s) in the direction of this normal (relSpeed = n dot object.velocity). relSpeed*object.mass should be the force you mean.
I can see what you mean with your solution but I can't see how you compute the entire chain of rotational forces.
I mean in the axe-example the arm swinging the axe would not be moving, only rotating and the 5000 body behind the blow
would maybe not be moving at all but still have a massive impact.
I'm trying to make a boxing-game using ODE but cant make the distinction between a slap from a girl and a Mike Tyson punch
Theres alot of things that should be taken into consideration, like the speed and how much of the body is (rotated I assume) into the punch etc.
A strictly arm punch might be as fast as a punch where you use your entire body but will not be nowhere as hard.
I see hacks to get closer but it would be so much better whithout hacks.
Ah, well, I see.
ODE supports reading the forces applied by joints (contacts are joints, too). Currently jME Physics 2 does not provide this information. For breaking joints and e.g. your scenario this would be handsome, though. You can have a look into the ODE docs on how to use joint feedback. But I'm not sure ODEJava already has the access methods for it (otherwise the natives have to be changed, too). You can improve the jME Physics 2 ODE binding to support it… patches are welcome
I'll look into the JointFeedback solution then post the result.
According to the odedocs jointfeedback tells what joints give what force to a body, but only the
bodies that they are directly attached to. So that wouldnt work I guess.
I'm not really sure I'm looking at it the right way.
contacts are joints that's why it would work
irrisor said:
contacts are joints that's why it would work
Suddenly hit me what the hell your meaning. I stared myself blind ! Dont read forcefeedback of the different
joints but of the CONTACTS which are also joints then you can see how much force that CONTACT(joint) applied to the body that was hit.
DOUGH ! (needs head slapping smiley here). I'll try it later.
I know I shouldnt bump but couldnt help it..
I made a class ContactJoint with superclass Joint (in your modified OdeJava, if any interrest I could upload that, there's no integration to JME physics2 though).
looks like this
public class ContactJoint extends joint {
…
}
Then pretty much created the joint like in the other joint classes (dJointCreateContact or something, am at work now so can't look).
In the collision handling code I just call contact.ignoreContact() and create a contact joint instead and attach it to the colliding bodies.
Then calls enableJointFeedBackTracking() on the joint.
This works pretty well as things are colliding just like before, of course now I was hoping to be able to read collision forces.
After world.step() I iterate those joints (which are now stored in a collection ) and call getJointFeedBack().getForce1(),getJointFeedBack().getForce2().
Those always return the vector {0,0,0}… So do the getTorque1().getTorque2()-
At last I call joint.delete() on all contactjoints.
Any idears ?
Edit : did you ever get this to work yourself Irrisor ?
Can't understand if something as basic as this is not supported by ODE. Force of impact is an issue in any game.