Scaled objects as static geometry

lvella
Posts: 16
Joined: Thu Oct 30, 2008 4:28 pm

Scaled objects as static geometry

Post by lvella »

I need to build a scene with multiple static objects that share the same trimesh, but they differ in location, orientation and scale. In the rendering engine (Ogre), I am using the same mesh to instantiate multiple objects, just differing in the transformation.

The obvious way I thought to build this scene inside Bullet is to create for each Ogre's mesh a btBvhTriangleMeshShape (sharing the same data through btStridingMeshInterface) and for each instance of that mesh I create a new rigid body. The problem is that I could not find a way to apply a scale to a btRigidBody. It is estated in btTransform's API documentation that it does not support scale, so I could not use it to scale the motion state used to build the rigid body.

Do I need to create a scaled btBvhTriangleMeshShape for each object in different scale from the original? There is a better way to build up this world?

I thought that because the objects will be static, it would work to simply ignore the documentation and set a scaled matrix inside btTransform when building the motion state of each rigid body. What do you think?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Scaled objects as static geometry

Post by Erwin Coumans »

btScaledBvhTriangleMeshShape allows you to re-use the same btBvhTriangleMeshShape with different scaling among several rigid bodies. In general, always use the collision shape for local scaling, instead of the rigid body world transform.

Hope this helps,
Erwin
lvella
Posts: 16
Joined: Thu Oct 30, 2008 4:28 pm

Re: Scaled objects as static geometry

Post by lvella »

Thanks!
Didn't see that...

Edit: Well, the Doxygen generated documentation seems outdated, it does not include this class.