Hi. Is it possible to set gravity for individual objects?
I tried calling set gravity on my rigid bodies but they still maintain the gravity of the dynamics world. Any ideas?
Gravity question
-
ca$per
- Posts: 35
- Joined: Fri May 21, 2010 2:48 pm
Re: Gravity question
Same question here. Any ideas?
-
robagar
- Posts: 48
- Joined: Fri May 21, 2010 1:49 am
Re: Gravity question
Call setGravity on the body *after* adding it to the world. World gravity is re-applied in btDiscreteDynamicsWorld::addRigidBody() it seems.
-
ca$per
- Posts: 35
- Joined: Fri May 21, 2010 2:48 pm
Re: Gravity question
Thank you! Seems to work.
-
vidjogamer
- Posts: 13
- Joined: Thu Apr 29, 2010 11:59 pm
Re: Gravity question
Thanks! I really appreciate your help.
Also, I am a complete beginner and I was wondering the best way to move objects around?
I have just been making tests programs to familiarize myself with the API.
I have been using functions like applyCentralForce() to make my objects move. Is this the best way to make objects move? Whats the difference between impulse and force?
Here is my situation: I have a cube falling onto a large plane acting as the ground. I can apply a force north, west, south or east with w,a,s,d respectively. This works just as expected unless I wait for a brief amount of time almost as if the cube "settles in". Then the keys do nothing. I can not seem to figure out why or how to remedy this. Any advice?
Also, I am a complete beginner and I was wondering the best way to move objects around?
I have just been making tests programs to familiarize myself with the API.
I have been using functions like applyCentralForce() to make my objects move. Is this the best way to make objects move? Whats the difference between impulse and force?
Here is my situation: I have a cube falling onto a large plane acting as the ground. I can apply a force north, west, south or east with w,a,s,d respectively. This works just as expected unless I wait for a brief amount of time almost as if the cube "settles in". Then the keys do nothing. I can not seem to figure out why or how to remedy this. Any advice?
-
robagar
- Posts: 48
- Joined: Fri May 21, 2010 1:49 am
Re: Gravity question
You're welcome
I'm new to bullet myself, but I can help with the physics bits maybe. Applying forces seems like a reasonable way of making things move to me 
An impulse is a force applied over time. When you push something you change its momentum, and the change in momentum is equal to the force multiplied by the amount of time you push for, assuming the force is constant. I guess calling applyCentralForce really means "apply this force for the whole step time", equivalent to applyCentralImpulse(force * stepTime)
Impulses are useful if you don't really care about the exact force or the time taken, just the end result.
Not sure about your cube settling in, but I believe bullet does have a mechanism for putting objects to sleep if it thinks they are inactive, so it doesn't waste cpu time on stationary objects. Perhaps that's the problem, but I would expect applying a force would wake them up...
An impulse is a force applied over time. When you push something you change its momentum, and the change in momentum is equal to the force multiplied by the amount of time you push for, assuming the force is constant. I guess calling applyCentralForce really means "apply this force for the whole step time", equivalent to applyCentralImpulse(force * stepTime)
Impulses are useful if you don't really care about the exact force or the time taken, just the end result.
Not sure about your cube settling in, but I believe bullet does have a mechanism for putting objects to sleep if it thinks they are inactive, so it doesn't waste cpu time on stationary objects. Perhaps that's the problem, but I would expect applying a force would wake them up...
-
dphil
- Posts: 237
- Joined: Tue Jun 29, 2010 10:27 pm
Re: Gravity question
You probably figured the problem out by now, but just in case... I agree with robagar that it is likely a sleeping issue. Objects fall asleep if stationary for too long, and I believe there are also thresholds of motion below which the object remains unaffected. These can be set by setSleepingThresholds(btScalar linear,btScalar angular). Defaults are 0.8 for both, I think. Other than reducing those, you can try calling rigidBody->activate(true) right before applying a force to see if that helps.