some questions: falling objects

haba
Posts: 21
Joined: Sun Oct 12, 2008 3:38 pm

some questions: falling objects

Post by haba »

Hi,

Just started messing with Bullet, and have some questions. My scene, so far, is just a plane (representing the floor) and a box falling on it, directly from above. I'm having some problems with the results however:

1) The box seems to fall really slowly, and always at the same speed, independently of the mass. I'm guessing vacuum? If so, how can I change this?

2) Also, there are other threads on this forum with more or less my problem, and people talk alot about scale. Well, i get it if it's all happening in a non vacuum environment. I don't otherwise.

3) Concerning my last question, what are the units, in bullet, for the size of a btBoxShape, for example? As, in order to look realistic, I would have to set my gravity accordingly.


Thanks!
chunky
Posts: 145
Joined: Tue Oct 30, 2007 9:23 pm

Re: some questions: falling objects

Post by chunky »

1) The box seems to fall really slowly, and always at the same speed, independently of the mass. I'm guessing vacuum? If so, how can I change this?
First guess, you have damping and it's falling at it's terminal velocity.

If not that, could you provide actual numbers? How big and heavy is it? What's gravity at? What's the actual speed?
For that last one, try printf("speed: %f\n", mRigidBody->getLinearVelocity().length());
2) Also, there are other threads on this forum with more or less my problem, and people talk alot about scale. Well, i get it if it's all happening in a non vacuum environment. I don't otherwise.
A box that's ten thousand meters across will appear to drop really, really, really slowly under normal gravity. Consider how far it'll travel in a unit of time compared to its overall size. On-screen it'll move one pixel every few seconds while it's actually moving at dozens of meters per second. It's not just scale that causes issues, but the computer-screen-representation of it.
3) Concerning my last question, what are the units, in bullet, for the size of a btBoxShape, for example? As, in order to look realistic, I would have to set my gravity accordingly.
Whatever you want. Typically meters for length. Units gets a mention on the wiki

Gary (-;
haba
Posts: 21
Joined: Sun Oct 12, 2008 3:38 pm

Re: some questions: falling objects

Post by haba »

chunky wrote:First guess, you have damping and it's falling at it's terminal velocity.

If not that, could you provide actual numbers? How big and heavy is it? What's gravity at? What's the actual speed?
For that last one, try printf("speed: %f\n", mRigidBody->getLinearVelocity().length());
My gravity is -10m/s^2.
I have two boxes, both falling from 10m above the floor.
Box1 has 5Kg of mass; Box2 has 10Kg of mass.
Box1 has a 2m edge; Box2 has a 4m edge. (meaning 1 and 2 is passed to btBoxShape, respectively).
Both boxes accelerate the same way, reaching the same velocity when they hit the ground, which is ~24.5m/s.

Any suggestions on how I can make this all look realistic?


Thanks
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Re: some questions: falling objects

Post by ola »

The gravity is the same on both objects, so they will have the same acceleration when they fall. Thus they will have the same speed when they hit the ground. This is not depending on the mass or size of the object.

Remember that Bullet does not add any air resistance itself. Your simulation is happening in a vacuum, and the result you describe is realistic.

If you want to do a simple "hack" resembling some air resistance (which is what I believe you are after), set some damping on the objects, and make the damping larger on the larger object. If you need more realistic aerodynamics, you'll have to add forces on the objects yourself. Google up aerodynamic drag, you get this: http://hypertextbook.com/physics/matter/drag/

Best regards,
Ola
haba
Posts: 21
Joined: Sun Oct 12, 2008 3:38 pm

Re: some questions: falling objects

Post by haba »

ola wrote:The gravity is the same on both objects, so they will have the same acceleration when they fall. Thus they will have the same speed when they hit the ground. This is not depending on the mass or size of the object.

Remember that Bullet does not add any air resistance itself. Your simulation is happening in a vacuum, and the result you describe is realistic.

If you want to do a simple "hack" resembling some air resistance (which is what I believe you are after), set some damping on the objects, and make the damping larger on the larger object. If you need more realistic aerodynamics, you'll have to add forces on the objects yourself. Google up aerodynamic drag, you get this: http://hypertextbook.com/physics/matter/drag/

Best regards,
Ola

You mean make the damping smaller on the larger object?
My understanding is that damping is a force opposite to the velocity, it would make sense that that force is smaller for the larger object, no?
Another thing, how is damping calculated in bullet? What are the order of values?

Thanks again!
mreuvers
Posts: 69
Joined: Sat May 10, 2008 8:39 am

Re: some questions: falling objects

Post by mreuvers »

haba wrote:The box seems to fall really slowly, and always at the same speed, independently of the mass. I'm guessing vacuum? If so, how can I change this?
What are your simulation settings? Fixed timestep, number of substeps? And what is the scale of the objects/world?

Regarding the same speed, that's indeed the famous Newton law ;-) I'm not sure how to fix that. Perhaps you should apply a counter force to certain objects based on their mass? Or ask Erwin to implement airfriction? :)
haba wrote:Also, there are other threads on this forum with more or less my problem, and people talk alot about scale. Well, i get it if it's all happening in a non vacuum environment. I don't otherwise.
Well consider to look at a distance of 10 km to a large sea container that's being dropped from 1 km high. On a 2D image this might appear to look exactly the same as when you look from a distance of 10 meter to a shoebox that is dropped from 1 m high. But I can guarantee you that the shoebox hits the ground sooner, simply because both the container and the shoebox fall exactly at the same speed. However on screen the situations appear to look identical.
haba wrote:Concerning my last question, what are the units, in bullet, for the size of a btBoxShape, for example? As, in order to look realistic, I would have to set my gravity accordingly.
To my understanding units are just whatever you want them to be. Meters, feet whatever. It shouldn't really matter; physics will remain the same. For communication purposes I'd like to stick to meters though. If you set the gravity -9.8 you should be fine.

EDIT: Somehow the other replies weren't available when I typed this, so my apologies for the double answers ;)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: some questions: falling objects

Post by Erwin Coumans »

Indeed, as Mark and others correctly answered, the simulation of huge objects appears 'slower' than small objects, due to camera/display scale.

Try using smaller objects.
Thanks,
Erwin
haba
Posts: 21
Joined: Sun Oct 12, 2008 3:38 pm

Re: some questions: falling objects

Post by haba »

Do you have any suggestions on how to set the damping on the objects? I mean, it should be a relation of mass and dimensions of the object.
If you don't think that using damping is the best way to achieve realistic results, can you suggest a better way? And maybe some examples? :P

Thanks again!
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Re: some questions: falling objects

Post by ola »

Bullet's default damping is depending on the velocity, whereas aerodynamic drag is depending on velocity squared. I'd recommend you modify or add squared-velocitiy depending damping for linear movement, and keep bullet's default damping for the angular movement.

I think the best solution would be to create your own derived rigid body class from btRigidBody, and override the applyDamping function. But since it's not defined as virtual that's not possible. You could still just add "virtual" to the bullet code and do it anyway, but then you'd have to do that every time you update to a new bullet version.

Or you can apply forces externally on the rigid bodies for each internal bullet simulation step. You can use the internal tick callback for that, there's some info on that on the "spaceship" part in this link:
http://www.bulletphysics.com/mediawiki- ... e_Snippets
see also
http://www.bulletphysics.com/Bullet/php ... ack#p10269

Use your rigid body's aabb to find the projected area for each axis direction, create a function to set the body's drag coefficient that you can store in each rigid body. Use the link I provided earlier for background information, http://hypertextbook.com/physics/matter/drag/ which has an example table for drag coefficients for various shapes.

Best regards,
Ola