Applyforce & Applyimpulse behavior
Posted: Tue Nov 27, 2012 6:58 am
Hello,
I'm trying to build some 'ballistic missile simulator' program that relies heavily on applying force to a rigid body (the missile).
Currently I'm using the applycentralimpulse method to launch the missile (initial push).
Can someone confirm me of how this method behaves? If I apply a force, how long does that force actually works?
My current assumption is that applycentralforce works based on the time given to the following stepsimulation.
When I see the DiscreteDynamicsWorld code, any force applied to a rigidbody will be cleared after a call to stepsimulation method. Meaning that a force is active constantly during a simulation step.
given : impulse = force * working_time
If i use applycentralforce(0, 500, 0) and then call stepsimulation for 60 milliseconds step, then that will be the same as using applycentralimpulse(0, 30, 0) and calling stepsimulation for 60 miliseconds.
( 30 impulse = 500 force * 0.06 second )
Is that correct?
And about units... I used SI units (Kgs , newtons , meters, seconds). Does that means when I apply force in newtons and define mass in kilograms, I would get the positions in meters? and velocity in meter/second (from rigidbody->getLinearVelocity())?
Also, from the forum I found something about a rigidbody going into sleep mode. Causing apply force/impulse to be ignored. Does that means I always have to call rigidbody->activate() before applying force/impulse? (just to be safe)
In my experiment I didn't encounter this 'sleeping' issue though (my code is modified directly from the helloworld example). Maybe because I applied the impulse right after the the line where I added the rigidbody to a dynamicworld? When does a rigidbody sleep anyway?
Sorry if my questions are too basic. I haven't got much experience in this.
And thanks in advance!
I'm trying to build some 'ballistic missile simulator' program that relies heavily on applying force to a rigid body (the missile).
Currently I'm using the applycentralimpulse method to launch the missile (initial push).
Can someone confirm me of how this method behaves? If I apply a force, how long does that force actually works?
My current assumption is that applycentralforce works based on the time given to the following stepsimulation.
When I see the DiscreteDynamicsWorld code, any force applied to a rigidbody will be cleared after a call to stepsimulation method. Meaning that a force is active constantly during a simulation step.
given : impulse = force * working_time
If i use applycentralforce(0, 500, 0) and then call stepsimulation for 60 milliseconds step, then that will be the same as using applycentralimpulse(0, 30, 0) and calling stepsimulation for 60 miliseconds.
( 30 impulse = 500 force * 0.06 second )
Is that correct?
And about units... I used SI units (Kgs , newtons , meters, seconds). Does that means when I apply force in newtons and define mass in kilograms, I would get the positions in meters? and velocity in meter/second (from rigidbody->getLinearVelocity())?
Also, from the forum I found something about a rigidbody going into sleep mode. Causing apply force/impulse to be ignored. Does that means I always have to call rigidbody->activate() before applying force/impulse? (just to be safe)
In my experiment I didn't encounter this 'sleeping' issue though (my code is modified directly from the helloworld example). Maybe because I applied the impulse right after the the line where I added the rigidbody to a dynamicworld? When does a rigidbody sleep anyway?
Sorry if my questions are too basic. I haven't got much experience in this.
And thanks in advance!