コード例 #1
0
 def setUp(self):
     self.step = 1.0 / 60
     self.motion_state1 = bullet.btDefaultMotionState()
     self.motion_state2 = bullet.btDefaultMotionState()
     self.radius = 1.0
     self.inertia = bullet.btVector3(1, 1, 1)
     self.sphere_shape = bullet.btSphereShape(self.radius)
     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.hull = bullet.btConvexHullShape(self.points)
     self.info = bullet.btRigidBodyConstructionInfo(1.0, self.motion_state1,
                                                    self.sphere_shape,
                                                    self.inertia)
     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
     self.t2 = bullet.btTransform.identity
     self.body1 = bullet.btRigidBody(self.info)
     self.body2 = bullet.btRigidBody(1.0, self.motion_state2, self.hull,
                                     self.v1)
     self.m1 = bullet.btMatrix3x3.identity
     self.m2 = bullet.btMatrix3x3.identity
コード例 #2
0
 def setUp(self):
     self.step = 1.0/60
     self.motion_state1 = bullet.btDefaultMotionState()
     self.motion_state2 = bullet.btDefaultMotionState()
     self.radius = 1.0
     self.inertia = bullet.btVector3(1, 1, 1)
     self.sphere_shape = bullet.btSphereShape(self.radius)
     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.hull = bullet.btConvexHullShape(self.points)
     self.info = bullet.btRigidBodyConstructionInfo(
         1.0,
         self.motion_state1,
         self.sphere_shape,
         self.inertia
     )
     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
     self.t2 = bullet.btTransform.identity
     self.body1 = bullet.btRigidBody(self.info)
     self.body2 = bullet.btRigidBody(1.0, self.motion_state2,
                                     self.hull, self.v1)
     self.m1 = bullet.btMatrix3x3.identity
     self.m2 = bullet.btMatrix3x3.identity
コード例 #3
0
ファイル: demoapplication.py プロジェクト: asumin/onibi
    def	localCreateRigidBody(self, mass, startTransform, shape):
        assert((not shape or shape.getShapeType() != bullet.INVALID_SHAPE_PROXYTYPE));

        # rigidbody is dynamic if and only if mass is non zero, otherwise static
        isDynamic = (mass != 0.0);

        localInertia=(0,0,0);
        if (isDynamic):
            shape.calculateLocalInertia(mass,localInertia);

        # using motionstate is recommended,
        # it provides interpolation capabilities,
        # and only synchronizes 'active' objects

        myMotionState = bullet.btDefaultMotionState(startTransform);

        cInfo=bullet.btRigidBodyConstructionInfo (mass,myMotionState,shape,localInertia);

        body = bullet.btRigidBody(cInfo);
        body.setContactProcessingThreshold(self.m_defaultContactProcessingThreshold);

        self.m_dynamicsWorld.addRigidBody(body);

        self.m_keep.append((myMotionState, cInfo, body, shape))

        return body;
コード例 #4
0
    def localCreateRigidBody(self, mass, startTransform, shape):
        assert ((not shape
                 or shape.getShapeType() != bullet.INVALID_SHAPE_PROXYTYPE))

        # rigidbody is dynamic if and only if mass is non zero, otherwise static
        isDynamic = (mass != 0.0)

        localInertia = (0, 0, 0)
        if (isDynamic):
            shape.calculateLocalInertia(mass, localInertia)

        # using motionstate is recommended,
        # it provides interpolation capabilities,
        # and only synchronizes 'active' objects

        myMotionState = bullet.btDefaultMotionState(startTransform)

        cInfo = bullet.btRigidBodyConstructionInfo(mass, myMotionState, shape,
                                                   localInertia)

        body = bullet.btRigidBody(cInfo)
        body.setContactProcessingThreshold(
            self.m_defaultContactProcessingThreshold)

        self.m_dynamicsWorld.addRigidBody(body)

        self.m_keep.append((myMotionState, cInfo, body, shape))

        return body
コード例 #5
0
 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)
コード例 #6
0
 def test_add_sphere(self, pos=bullet.btVector3(0, 0, 0)):
     self.sphere_shape = bullet.btSphereShape(1)
     self.sphere_motion_state = bullet.btDefaultMotionState(
         bullet.btTransform(bullet.btQuaternion.identity, pos))
     self.sphere_mass = 1.0
     self.fall_inertia = bullet.btVector3(0, 0, 0)
     self.sphere_shape.calculate_local_inertia(self.sphere_mass,
                                               self.fall_inertia)
     self.sphere_rigid_body_cinfo = bullet.btRigidBodyConstructionInfo(
         self.sphere_mass, self.sphere_motion_state, self.sphere_shape,
         self.fall_inertia)
     self.sphere_rigid_body = \
         bullet.btRigidBody(self.sphere_rigid_body_cinfo)
     self.dynamics_world.add_rigid_body(self.sphere_rigid_body)
コード例 #7
0
 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)
コード例 #8
0
 def test_add_sphere(self, pos=bullet.btVector3(0, 0, 0)):
     self.sphere_shape = bullet.btSphereShape(1)
     self.sphere_motion_state = bullet.btDefaultMotionState(
         bullet.btTransform(bullet.btQuaternion.identity,
                            pos)
     )
     self.sphere_mass = 1.0
     self.fall_inertia = bullet.btVector3(0, 0, 0)
     self.sphere_shape.calculate_local_inertia(self.sphere_mass,
                                               self.fall_inertia)
     self.sphere_rigid_body_cinfo = bullet.btRigidBodyConstructionInfo(
         self.sphere_mass, self.sphere_motion_state, self.sphere_shape,
         self.fall_inertia
     )
     self.sphere_rigid_body = \
         bullet.btRigidBody(self.sphere_rigid_body_cinfo)
     self.dynamics_world.add_rigid_body(self.sphere_rigid_body)
コード例 #9
0
ファイル: BasicDemo.py プロジェクト: asumin/onibi
    def createAndAppendBody(self, shape, mass, transform):
        # rigidbody is dynamic if and only if mass is non zero, otherwise static
        isDynamic = (mass != 0.0)

        localInertia = (0, 0, 0)
        if (isDynamic):
            shape.calculateLocalInertia(mass, localInertia)

        # using motionstate is recommended,
        # it provides interpolation capabilities, and only synchronizes 'active' objects
        myMotionState = bullet.btDefaultMotionState(transform)
        rbInfo = bullet.btRigidBodyConstructionInfo(mass, myMotionState, shape,
                                                    localInertia)
        body = bullet.btRigidBody(rbInfo)

        # add the body to the dynamics world
        self.m_dynamicsWorld.addRigidBody(body)
        self.m_keep.append((shape, myMotionState, body))
コード例 #10
0
ファイル: BasicDemo.py プロジェクト: asumin/onibi
    def createAndAppendBody(self, shape, mass, transform):
        # rigidbody is dynamic if and only if mass is non zero, otherwise static
        isDynamic = (mass != 0.0);

        localInertia=(0,0,0);
        if (isDynamic):
            shape.calculateLocalInertia(mass,localInertia);

        # using motionstate is recommended, 
        # it provides interpolation capabilities, and only synchronizes 'active' objects
        myMotionState = bullet.btDefaultMotionState(transform);
        rbInfo=bullet.btRigidBodyConstructionInfo(mass,
                myMotionState,
                shape,
                localInertia);
        body = bullet.btRigidBody(rbInfo);

        # add the body to the dynamics world
        self.m_dynamicsWorld.addRigidBody(body);
        self.m_keep.append((shape, myMotionState, body));
コード例 #11
0
 def test_linear_sleeping_threshold(self):
     self.info.linear_sleeping_threshold = 0.2
     self.body2 = bullet.btRigidBody(self.info)
     self.assertEquals(self.body2.linear_sleeping_threshold,
                       self.info.linear_sleeping_threshold)
コード例 #12
0
 def test_ctor(self):
     self.body1 = bullet.btRigidBody(self.info)
     self.v1 = bullet.btVector3(1, 0, 0)
     self.body2 = bullet.btRigidBody(1.0, self.motion_state1, self.hull,
                                     self.v1)
コード例 #13
0
ファイル: HelloWorld.py プロジェクト: asumin/onibi
    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);
コード例 #14
0
 def test_linear_sleeping_threshold(self):
     self.info.linear_sleeping_threshold = 0.2
     self.body2 = bullet.btRigidBody(self.info)
     self.assertEquals(self.body2.linear_sleeping_threshold,
                       self.info.linear_sleeping_threshold)
コード例 #15
0
 def test_ctor(self):
     self.body1 = bullet.btRigidBody(self.info)
     self.v1 = bullet.btVector3(1, 0, 0)
     self.body2 = bullet.btRigidBody(1.0, self.motion_state1,
                                     self.hull, self.v1)
コード例 #16
0
    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)

    for i in range(300):
        dynamicsWorld.stepSimulation(1 / 60.0, 10)