Resizing Collision Shapes

fiaafly
Posts: 2
Joined: Wed Jun 29, 2011 2:11 pm

Resizing Collision Shapes

Post by fiaafly »

Hello this is my first post in this forum.

I am looking for a way to adjust te size of a colison shape. In my case i have a ball represened by a sphere collision shape. i want to change the size of the ball while the ball is moving. unfortunatly this does not seem to be that easy.
For instance i want to increase te size of the ball by a given factor.

Is there an easy way to achieve this, and what are th nessesary steps to do?

Best regards
fiaa
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Resizing Collision Shapes

Post by dphil »

From the manual:
Some collision shapes can have local scaling applied. Use btCollisionShape::setScaling(vector3). Non uniform scaling with different scaling values for each axis, can be used for btBoxShape, btMultiSphereShape, btConvexShape, btTriangleMeshShape. Uniform scaling, using x value for all axis, can be used for btSphereShape. Note that a non-uniform scaled sphere can be created by using a btMultiSphereShape with 1 sphere. As mentioned before, the btScaledBvhTriangleMeshShape allows to instantiate a btBvhTriangleMeshShape at different non-uniform scale factors. The btUniformScalingShape allows to instantiate convex shapes at different scales, reducing the amount of memory.
Note that I think this is slightly outdated. Use setLocalScaling; there is no setScaling. For a btSphereShape (as I assume in your case), you can also use setUnscaledRadius. For example, calling setUnscaledRadius(2) followed by setLocalScaling(btVector3(3,3,3)) would result in a ball with radius 6.
fiaafly
Posts: 2
Joined: Wed Jun 29, 2011 2:11 pm

Re: Resizing Collision Shapes

Post by fiaafly »

Thank you this actually worked well :)