views:

58

answers:

1

I am using the FallingCubes demo in Bullet3D and noticed that the cubes rotate when they collide. However when I change the program to use spheres (btSphereShape), they do not rotate. Note that I am using the iphone sdk for this. Does anyone have any advice on how to get these spheres to rotate? Here is some of the relevant code:

btTransform bodyTransform;
bodyTransform.setIdentity();
bodyTransform.setOrigin(btVector3(0,10+i*3,0));
//btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1));
btCollisionShape* boxShape = new btSphereShape(0.5f);
btScalar mass(1.);//positive mass means dynamic/moving  object
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)
   boxShape->calculateLocalInertia(mass,localInertia);

btDefaultMotionState* myMotionState = new btDefaultMotionState(bodyTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,
                                               boxShape,localInertia);
btRigidBody* boxBody=new btRigidBody(rbInfo);
boxBody->setFriction(.3f);
sBoxBodies.push_back(boxBody);

boxBody->setActivationState(DISABLE_DEACTIVATION);
//add the body to the dynamics world
sDynamicsWorld->addRigidBody(boxBody);
+1  A: 

You could add a contact event handler and set a rotation there.

codymanix