Animate mass

EchoEcho
Posts: 5
Joined: Tue Jul 20, 2010 5:22 pm

Animate mass

Post by EchoEcho »

Can I animate mass for object???

I try this code:

Code: Select all

btVector3 inertia;
body->getCollisionShape()->calculateLocalInertia(new_mass, inertia);
body->setMassProps(new_mass, inertia);
body->updateInertiaTensor();
I dont change mass and I have different result unlike simulation without this code.

And If it isnt posible and I must created new object, How I really need read velocity and other stuff and apply on new object with new mass??????
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Animate mass

Post by dphil »

That should be correct. It's exactly what I do (I activate my rigid body afterward, but I don't think that's necessary) in my simulation and the mass it works as expected (no need to remove the body and create a new one with the new mass). Something else could be causing problems in your simulation, but your mass update code looks correct.