Rotating an object representing the ground (Mass = 0)

Post Reply
tmason
Posts: 19
Joined: Wed Aug 27, 2014 5:02 pm

Rotating an object representing the ground (Mass = 0)

Post by tmason »

Hello,

Hopefully this is something simple but I am not sure.

I have a rigid body representing the ground in a world I am building.

So the ground object itself works 100% as expected.

Now, I want to rotate the ground such that it works like a door/hatch on the floor; the ground will rotate on the x or z axis and everything on top of the ground will fall through.

I tried this:

Code: Select all

PhysicsShapeRigidBody->activate();
PhysicsShapeRigidBody->applyTorqueImpulse((*AxisAngleOfRotation));
Where PhysicsShapeRigidBody represents the ground but that doesn't work.

I am thinking this is because the mass is equal to zero but if that is the case how can I have an object be set to be in one position at times and not be affected by gravity but be affected by rotations/other forces that I apply manually?

Thank you for your time.
STTrife
Posts: 109
Joined: Tue May 01, 2012 10:42 am

Re: Rotating an object representing the ground (Mass = 0)

Post by STTrife »

Have you tried setAngularVelocity (const btVector3 &ang_vel) ???
tmason
Posts: 19
Joined: Wed Aug 27, 2014 5:02 pm

Re: Rotating an object representing the ground (Mass = 0)

Post by tmason »

STTrife wrote:Have you tried setAngularVelocity (const btVector3 &ang_vel) ???
Thank you; I got that to work by doing what you said as well as #1 setting the mass greater than zero (0) and :

Code: Select all

PhysicsShapeRigidBody->setLinearFactor(btVector3(0,0,1));
PhysicsShapeRigidBody->setAngularFactor(btVector3(0,0,1));
So this indeed rotates the "ground" without it falling.

One last thing, when you use setAngularVelocity() the object will rotate forever it seems, I was hoping for a "nudge" effect where the object stops after a while.

Is that possible?

Thanks again for your time.
STTrife
Posts: 109
Joined: Tue May 01, 2012 10:42 am

Re: Rotating an object representing the ground (Mass = 0)

Post by STTrife »

I think you can do that with btRigidBody::setDamping (btScalar lin_damping, btScalar ang_damping).
tmason
Posts: 19
Joined: Wed Aug 27, 2014 5:02 pm

Re: Rotating an object representing the ground (Mass = 0)

Post by tmason »

STTrife wrote:I think you can do that with btRigidBody::setDamping (btScalar lin_damping, btScalar ang_damping).
Thank you again!

Works; exactly what I needed :)
Post Reply