Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Sun Mar 19, 2017 10:53 pm 
Offline

Joined: Tue Jan 31, 2017 8:07 pm
Posts: 23
It appears that whatever I set my object's mass to be, it has no effect on how it behaves in the scene. When changing the gravity, my object falls faster or slower, but not when changing the mass (even from 1 to 10000, no change).

Am I doing something wrong here?

Code:
btCollisionShape* bulletCollisionShape = new btBoxShape(btVector3(0.05f, 0.1f, 0.05f));
btScalar bulletMass = 1;
btVector3 bulletInertia(0, 0, 0);
bulletCollisionShape->calculateLocalInertia(bulletMass, bulletInertia);

...

btRigidBody::btRigidBodyConstructionInfo bulletRigidBodyCI(bulletMass, bulletMotionstate, bulletCollisionShape, bulletInertia);


Top
 Profile  
 
PostPosted: Sun Mar 19, 2017 11:03 pm 
Offline

Joined: Thu Apr 14, 2016 3:44 pm
Posts: 32
gravity accelerates all objects equally https://www.youtube.com/watch?v=5C5_dOEyAfk


Top
 Profile  
 
PostPosted: Mon Mar 20, 2017 8:57 pm 
Offline

Joined: Tue Jan 31, 2017 8:07 pm
Posts: 23
Well how can I have objects that fall differently then, without changing the gravity?


Top
 Profile  
 
PostPosted: Mon Mar 20, 2017 10:45 pm 
Offline
User avatar

Joined: Fri Nov 04, 2005 2:22 pm
Posts: 109
I use setLinearFactor()...

http://www.bulletphysics.org/mediawiki- ... e_Snippets

may be is wrong but for my engine is good... try.


Top
 Profile  
 
PostPosted: Mon Mar 20, 2017 11:50 pm 
Offline

Joined: Tue Jan 31, 2017 8:07 pm
Posts: 23
Hmm, I tried setLinearFactor() but after entering the weight of my bullet (0.00745KG) for the y-axis value, it just stops mid-air after falling slightly.


Top
 Profile  
 
PostPosted: Tue Mar 21, 2017 12:08 am 
Offline

Joined: Tue Jan 31, 2017 8:07 pm
Posts: 23
Is this to do with my stepSimulation()? I'm currently doing dynamicsWorld->stepSimulation(1 / 60.f, 10) but I've tried using deltaTime and my object just instantly appears on the ground then, it's so fast.

When I draw the scene with a debug drawer, the object seems to be falling as expected (with different gravities at least, mass still has no effect), which is even weirder because I don't see how that would affect things.


Top
 Profile  
 
PostPosted: Thu Mar 23, 2017 11:33 am 
Offline

Joined: Thu Mar 23, 2017 11:17 am
Posts: 2
jimjamjack wrote:
Is this to do with my stepSimulation()? I'm currently doing dynamicsWorld->stepSimulation(1 / 60.f, 10) but I've tried using deltaTime and my object just instantly appears on the ground then, it's so fast.

When I draw the scene with a debug drawer, the object seems to be falling as expected (with different gravities at least, mass still has no effect), which is even weirder because I don't see how that would affect things.


There is a diference between delta time and time step. Delta time is using to calculate the last time passed since the frame start, time step is how many steps do you want to use in this process. For example, only call this function if the delta_time is greater than 16.6 (in miliseconds), you need this if in your engine there is a frame that consumes a lot of time to process a task and your delta_time increases


Top
 Profile  
 
PostPosted: Thu Mar 23, 2017 11:50 am 
Offline

Joined: Sun Jan 07, 2007 4:29 pm
Posts: 79
Location: Oxford, England
If you want heavy objects to fall (accelerate) faster than light ones, you have to ask yourself why. The most likely answer is that the objects are affected by drag (air resistance) too - in which case rather than hacking gravity, it's probably better to add a drag force. This will give more realistic motion in all directions, not just vertically.

Drag affects lighter objects more because the drag force is calculated as:

dragForce = CL * dynamicPressure * area

where

* CL is the coefficient of drag (look it up - for a sphere it's around 0.5)
* dynamicPressure = 0.5 * airDensity * speed^2 where speed is the speed of the object relative to the air.
* area is the cross-sectional area of the object (pi r^2 for a sphere).
* the force acts in the direciton opposite to the motion of the object relative to the air.

This force only depends on the properties and motion of the object - not on its mass. The acceleration it produces is therefore greater on objects with low mass, since acceleration = force / mass (Newton's second law). That's why a feather falls slower than a stone on earth, where there's an atmosphere, and on the moon where there's not. It's also why you can throw a stone further than a feather (on Earth).


Top
 Profile  
 
PostPosted: Fri Mar 24, 2017 1:10 am 
Offline

Joined: Tue Jan 31, 2017 8:07 pm
Posts: 23
Thanks DannyChapman, I'm assuming this is what I'm looking for. Does Bullet have built-in functions for altering a specific rigidBody's drag?

The reason I posted the thread was because I found it strange that my bullet object was falling extremely quickly under the default "earth" gravity, and when trying to change this by altering the rigidBody's mass, obviously had no success. So although I could probably just alter the gravity, it seems like a bit of a hack, so drag seems like the way to go.

But yeah, finding the right values for 'dragForce = CL * dynamicPressure * area' for my own model would be a bit of a pain so hopefully Bullet has something to help with it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group