Esempio n. 1
0
    def test_linearVelocity(self):
        world = DiscreteDynamicsWorld()
        world.setGravity(Vector3(0, 0, 0))
        obj = RigidBody(None, None, 1)
        obj.setLinearVelocity(Vector3(1, 2, 3))
        world.addRigidBody(obj)
        expectedSteps = 64
        numSteps = world.stepSimulation(1.0, expectedSteps, 1.0 / expectedSteps)
        self.assertEqual(numSteps, expectedSteps)

        position = obj.getMotionState().getWorldTransform().getOrigin()
        self.assertEquals(position.x, 1)
        self.assertEquals(position.y, 2)
        self.assertEquals(position.z, 3)
Esempio n. 2
0
    def test_linearVelocity(self):
        world = DiscreteDynamicsWorld()
        world.setGravity(Vector3(0, 0, 0))
        obj = RigidBody(None, None, 1)
        obj.setLinearVelocity(Vector3(1, 2, 3))
        world.addRigidBody(obj)
        expectedSteps = 64
        numSteps = world.stepSimulation(1.0, expectedSteps,
                                        1.0 / expectedSteps)
        self.assertEqual(numSteps, expectedSteps)

        position = obj.getMotionState().getWorldTransform().getOrigin()
        self.assertEquals(position.x, 1)
        self.assertEquals(position.y, 2)
        self.assertEquals(position.z, 3)
Esempio n. 3
0
    def test_stepSimulation(self):
        world = DiscreteDynamicsWorld()
        world.setGravity(Vector3(1, 2, 3))
        obj = RigidBody(None, None, 1)
        world.addRigidBody(obj)
        expectedSteps = 64
        numSteps = world.stepSimulation(1.0, expectedSteps, 1.0 / expectedSteps)
        self.assertEqual(numSteps, expectedSteps)

        position = obj.getMotionState().getWorldTransform().getOrigin()

        # Unfortunately, there is some error (as compared to physical reality)
        # in Bullet's results.  My fault?  Bullet's fault?  I'm not sure.
        self.assertEqual(position.x, 0.5 + 0.5 / expectedSteps)
        self.assertEqual(position.y, 1.0 + 1.0 / expectedSteps)
        self.assertEqual(position.z, 1.5 + 1.5 / expectedSteps)
Esempio n. 4
0
    def test_stepSimulation(self):
        world = DiscreteDynamicsWorld()
        world.setGravity(Vector3(1, 2, 3))
        obj = RigidBody(None, None, 1)
        world.addRigidBody(obj)
        expectedSteps = 64
        numSteps = world.stepSimulation(1.0, expectedSteps,
                                        1.0 / expectedSteps)
        self.assertEqual(numSteps, expectedSteps)

        position = obj.getMotionState().getWorldTransform().getOrigin()

        # Unfortunately, there is some error (as compared to physical reality)
        # in Bullet's results.  My fault?  Bullet's fault?  I'm not sure.
        self.assertEqual(position.x, 0.5 + 0.5 / expectedSteps)
        self.assertEqual(position.y, 1.0 + 1.0 / expectedSteps)
        self.assertEqual(position.z, 1.5 + 1.5 / expectedSteps)
Esempio n. 5
0
 def test_applyCentralImpulse(self):
     body = RigidBody(mass=1.0)
     body.applyCentralImpulse(Vector3(1, 2, 3))
     world = DiscreteDynamicsWorld()
     world.setGravity(Vector3(0, 0, 0))
     world.addRigidBody(body)
     expectedSteps = 64
     numSteps = world.stepSimulation(1.0, expectedSteps, 1.0 / expectedSteps)
     self.assertEqual(numSteps, expectedSteps)
     transform = body.getMotionState().getWorldTransform()
     position = transform.getOrigin()
     self.assertEqual(position.x, 1.0)
     self.assertEqual(position.y, 2.0)
     self.assertEqual(position.z, 3.0)
     rot = transform.getRotation()
     self.assertEqual(
         (rot.getX(), rot.getY(), rot.getZ(), rot.getW()), (0, 0, 0, 1))
Esempio n. 6
0
 def test_applyImpulse(self):
     body = RigidBody(mass=1.0)
     body.applyImpulse(Vector3(1, 2, 3), Vector3(1, 1, 1))
     world = DiscreteDynamicsWorld()
     world.setGravity(Vector3(0, 0, 0))
     world.addRigidBody(body)
     expectedSteps = 64
     numSteps = world.stepSimulation(1.0, expectedSteps,
                                     1.0 / expectedSteps)
     self.assertEqual(numSteps, expectedSteps)
     transform = body.getMotionState().getWorldTransform()
     position = transform.getOrigin()
     self.assertEqual(position.x, 1.0)
     self.assertEqual(position.y, 2.0)
     self.assertEqual(position.z, 3.0)
     rot = transform.getRotation()
     self.assertNotEqual((rot.getX(), rot.getY(), rot.getZ(), rot.getW()),
                         (0, 0, 0, 1))