Is there a built-in way for simulating a small sphere in space that has an repelling effect on the objects around it? If not, then how does this method sound:
Each frame, find all dynamic objects within a certain radius of the sphere. Then for each object, apply a tangental force.
Thanks,
Brian
Simulating force from single point
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Simulating force from single point
There is no out-of-the-box demo that shows how to do this, but it should be fairly easy.brianh wrote: Each frame, find all dynamic objects within a certain radius of the sphere. Then for each object, apply a tangental force.
1) create a btSphereShape and btRigidBody (see localCreateRigidBody in the demos)
2) disable collision response
3) add custom callback, and apply the desired impulse for each object colliding within this callback
You can see the use of the collision callback in Bullet/Demos/ConcaveDemo/ConcaveCollisionDemo.cpp, look for 'CustomMaterialCombinerCallback'.
Enabling the collision callback and disabling collision response can be done using collision flags:
Code: Select all
//enable custom material callback
rigidBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK | btCollisionObject::CF_NO_CONTACT_RESPONSE);
Erwin