Bullet physics engine, how to freeze an object?
Using Bullet 2.76 I'm trying to freeze an object (rigid body) so that it instantly stops moving, but still responds to collisions.
I tried setting it's activation state to DISABLE_SIMULATION, but then it's virtually nonexistent to other objects. Furthermore, if objects "collide" with it when it's disabled, strange things begin to happen (object's falling through static bodies, etc.)
I suppose, temporarily converting it to a static rigid body could work, but is there an existing "native" way to achieve this on Bullet's side?
Edit: Is there a way to turn off gravity for a specific object?
该文档有点缺乏,但可以假设下面的方法可以用来禁用特定主体上的引力:
void btRigidBody::setGravity(const btVector3 &acceleration)
Just set rigid body's mass to 0, then it become static...
http://bullet.googlecode.com/svn/trunk/Demos/HelloWorld/HelloWorld.cpp
There are functions for btRigidBody
called setLinearFactor(x,y,z)
and setAngularFactor(x,y,z)
that allow you to limit motion along a specific axis and rotation about a specific axis respectively. Calling both functions with all 0
's as arguments should stop all motion. Calling them again with all 1
's will allow motion again.
上一篇: 子弹物理问题
下一篇: 子弹物理引擎,如何冻结一个对象?