def test_add_ground(self):
     self.ground_shape = bullet.btStaticPlaneShape(
         bullet.btVector3(0, 1, 0), 1)
     self.ground_motion_state = bullet.btDefaultMotionState(
         bullet.btTransform(bullet.btQuaternion.identity,
                            bullet.btVector3(0, -1, 0)))
     self.ground_rigid_body_cinfo = bullet.btRigidBodyConstructionInfo(
         0, self.ground_motion_state, self.ground_shape,
         bullet.btVector3(0, 0, 0))
     self.ground_rigid_body = \
         bullet.btRigidBody(self.ground_rigid_body_cinfo)
     self.dynamics_world.add_rigid_body(self.ground_rigid_body)
 def test_add_ground(self):
     self.ground_shape = bullet.btStaticPlaneShape(
         bullet.btVector3(0, 1, 0), 1
     )
     self.ground_motion_state = bullet.btDefaultMotionState(
         bullet.btTransform(bullet.btQuaternion.identity,
                            bullet.btVector3(0, -1, 0))
     )
     self.ground_rigid_body_cinfo = bullet.btRigidBodyConstructionInfo(
         0, self.ground_motion_state, self.ground_shape,
         bullet.btVector3(0, 0, 0)
     )
     self.ground_rigid_body = \
         bullet.btRigidBody(self.ground_rigid_body_cinfo)
     self.dynamics_world.add_rigid_body(self.ground_rigid_body)
 def setUp(self):
     # Describe a cube
     self.points = [
         bullet.btVector3(-1, -1, -1),
         bullet.btVector3(-1, 1, -1),
         bullet.btVector3(-1, -1, 1),
         bullet.btVector3(-1, 1, 1),
         bullet.btVector3(1, 1, 1),
         bullet.btVector3(1, -1, 1),
         bullet.btVector3(1, -1, -1),
         bullet.btVector3(1, 1, -1)
     ]
     self.hull1 = bullet.btConvexHullShape(self.points)
     self.hull2 = bullet.btBox2dShape(self.points[4])
     self.shape1 = bullet.btCompoundShape()
     self.plane = bullet.btStaticPlaneShape(bullet.btVector3(0, 0, 0), 1.0)
     self.v1 = bullet.btVector3(0, 0, 0)
     self.v2 = bullet.btVector3(0, 0, 0)
     self.v3 = bullet.btVector3(0, 0, 0)
     self.t1 = bullet.btTransform.identity
 def setUp(self):
     # Describe a cube
     self.points = [
         bullet.btVector3(-1, -1, -1),
         bullet.btVector3(-1, 1, -1),
         bullet.btVector3(-1, -1, 1),
         bullet.btVector3(-1, 1, 1),
         bullet.btVector3(1, 1, 1),
         bullet.btVector3(1, -1, 1),
         bullet.btVector3(1, -1, -1),
         bullet.btVector3(1, 1, -1)
     ]
     self.hull1 = bullet.btConvexHullShape(self.points)
     self.hull2 = bullet.btBox2dShape(self.points[4])
     self.shape1 = bullet.btCompoundShape()
     self.plane = bullet.btStaticPlaneShape(bullet.btVector3(0, 0, 0),
                                            1.0)
     self.v1 = bullet.btVector3(0, 0, 0)
     self.v2 = bullet.btVector3(0, 0, 0)
     self.v3 = bullet.btVector3(0, 0, 0)
     self.t1 = bullet.btTransform.identity
示例#5
0
import 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(
示例#6
0
import 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)