def __init__(self): self.m_defaultContactProcessingThreshold=bullet.BT_LARGE_FLOAT self.m_idle=False self.keep=[] # setup #collision configuration contains default setup for memory, collision setup self.m_collisionConfiguration = bullet.btDefaultCollisionConfiguration(); #use the default collision dispatcher. #For parallel processing you can use a diffent dispatcher #(see Extras/BulletMultiThreaded) self.m_dispatcher = bullet.btCollisionDispatcher(self.m_collisionConfiguration); self.m_broadphase = bullet.btDbvtBroadphase(); #the default constraint solver. #For parallel processing you can use a different solver #(see Extras/BulletMultiThreaded) self.m_solver = bullet.btSequentialImpulseConstraintSolver(); self.m_dynamicsWorld = bullet.btDiscreteDynamicsWorld( self.m_dispatcher, self.m_broadphase, self.m_solver, self.m_collisionConfiguration); self.m_dynamicsWorld.setGravity((0.0, -10.0, 0.0));
import swigbullet as bullet if __name__ == "__main__": broadphase = bullet.btDbvtBroadphase() collisionConfiguration = bullet.btDefaultCollisionConfiguration() dispatcher = bullet.btCollisionDispatcher(collisionConfiguration) solver = bullet.btSequentialImpulseConstraintSolver() dynamicsWorld = bullet.btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration) dynamicsWorld.setGravity((0, -10, 0)) groundShape = bullet.btStaticPlaneShape((0, 1, 0), 1) fallShape = bullet.btSphereShape(1) groundMotionState = bullet.btDefaultMotionState(bullet.btTransform(bullet.btQuaternion(0, 0, 0, 1), (0, -1, 0))) groundRigidBodyCI = bullet.btRigidBodyConstructionInfo(0, groundMotionState, groundShape, (0, 0, 0)) groundRigidBody = bullet.btRigidBody(groundRigidBodyCI) dynamicsWorld.addRigidBody(groundRigidBody) fallMotionState = bullet.btDefaultMotionState(bullet.btTransform(bullet.btQuaternion(0, 0, 0, 1), (0, 50, 0))) mass = 1 fallInertia = (0, 0, 0) fallShape.calculateLocalInertia(mass, fallInertia) fallRigidBodyCI = bullet.btRigidBodyConstructionInfo(mass, fallMotionState, fallShape, fallInertia) fallRigidBody = bullet.btRigidBody(fallRigidBodyCI) dynamicsWorld.addRigidBody(fallRigidBody)