rotating rigidbodies with mass 0.0

amuhamed
Posts: 2
Joined: Fri Apr 12, 2013 10:42 pm

rotating rigidbodies with mass 0.0

Post by amuhamed »

Hello there,

I have following problem: (I'm working with cocos3d)

I have a scene where I load a sphere (mass 1.0) and I'm moving (applyImpulse to the sphere.rigidBody) the sphere with the accelerometer.

I have cubes as platforms (with mass 0.0) hanging around in the "sky".
Now I want to (randomly) rotate the cubes so as the sphere moves along the cubes it gets harder because some cubes rotate.

My problem is: I can't apply any impulse or force or torque to the cubes because they have mass 0.0 (infinite) and it doesn't affect the cubes at all. But if I set a mass to the cubes like 1.0, they fall down from the "sky" and are not hanging around anymore.

Any idea to this problem?

Greets
allsey87
Posts: 33
Joined: Fri Oct 26, 2012 1:50 pm

Re: rotating rigidbodies with mass 0.0

Post by allsey87 »

A mass of 0.0 represents infinite mass, and Bullet simulates physics. Hence if F = ma, and F / m = a, it doesn't matter how big F become, as if m is already infinite, you will always get zero acceleration.

To achieve what you are trying to do, I would suggest disabling gravity for those 'floating' bodies you are talking about after adding them to the simulation. See http://bulletphysics.org/Bullet/phpBB3/ ... f=9&t=4392 for details on this one...
allsey87
Posts: 33
Joined: Fri Oct 26, 2012 1:50 pm

Re: rotating rigidbodies with mass 0.0

Post by allsey87 »

Upon re-reading your question, an alternative solution that might better would be to create a constraint between those floating boxes and the some fixed position in the world. Most of the btTypedConstraint objects have a constructor which takes a single body and constrains it somewhere in the world. Have a look at the ConstraintDemo for some inspiration on what you are trying to achieve...
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: rotating rigidbodies with mass 0.0

Post by Basroil »

These bodies should be kinematic ones rather than static or dynamic, that is that they interact with dynamic objects but are not simulated themselves. That would let you avoid any constraints, let you move them around as you please, and lower simulation times too.