2009-07-12 1 views
0

Ich benutze die FallingCubes Demo in Bullet3D und bemerkte, dass die Würfel rotieren, wenn sie kollidieren. Wenn ich jedoch das Programm für die Verwendung von Sphären (btSphereShape) ändere, rotieren sie nicht. Beachten Sie, dass ich das iPhone SDK dafür verwende. Hat jemand einen Ratschlag, wie man diese Kugeln rotieren lässt? Hier ist ein Teil des relevanten Codes:Wie man Kugeln in bullet3d dreht

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);  

Antwort

1

Sie könnten einen Kontakt-Event-Handler hinzufügen und dort eine Rotation festlegen.