def setupObstacleThree(self, pos, scale, turn):
   # Box A
   shape = BulletBoxShape(Vec3(0.1, 0.1, 0.1))
   
   bodyA = BulletRigidBodyNode('Box A')
   bodyA.setRestitution(1.0)
   bodyNP = self.worldNP.attachNewNode(bodyA)
   bodyNP.node().addShape(shape)
   bodyNP.setCollideMask(BitMask32.allOn())
   bodyNP.setPos(pos)
   bodyNP.setHpr(turn)
   
   visNP = loader.loadModel('media/models/box.egg')
   visNP.setScale(Vec3(0.1, 0.1, 0.1)*2*scale)
   visNP.clearModelNodes()
   visNP.reparentTo(bodyNP)
   
   self.world.attachRigidBody(bodyA)
   
   #Box B
   shape = BulletBoxShape(Vec3(0.1,0.1,0.1))
   
   bodyB = BulletRigidBodyNode('Box B')
   bodyB.setRestitution(1.0)
   bodyNP = self.worldNP.attachNewNode(bodyB)
   bodyNP.node().addShape(shape)
   bodyNP.setCollideMask(BitMask32.allOn())
   bodyNP.setPos(pos)
   bodyNP.setHpr(turn)
   
   visNP = loader.loadModel('media/models/box.egg')
   visNP.setScale(Vec3(0.1,0.1,0.1)*2*scale)
   visNP.clearModelNodes()
   visNP.reparentTo(bodyNP)
   
   self.world.attachRigidBody(bodyB)
   
   # Slider
   frameA = TransformState.makePosHpr(Point3(0, 0, 0), Vec3(0, 0, 0))
   frameB = TransformState.makePosHpr(Point3(0, 0, 0), Vec3(0, 0, 0))
   
   slider = BulletSliderConstraint(bodyA, bodyB, frameA, frameB, True)
   slider.setDebugDrawSize(2.0)
   slider.setLowerLinearLimit(0)
   slider.setUpperLinearLimit(12)
   slider.setLowerAngularLimit(-90)
   slider.setUpperAngularLimit(-85)
   self.world.attachConstraint(slider)
   
   # Box C
   shape = BulletBoxShape(Vec3(1, 3, 0.1))
   
   bodyC = BulletRigidBodyNode('Box C')
   bodyC.setRestitution(1.0)
   bodyNP = self.worldNP.attachNewNode(bodyC)
   bodyNP.node().addShape(shape)
   bodyNP.node().setMass(0.1)
   bodyNP.node().setDeactivationEnabled(False)
   bodyNP.setCollideMask(BitMask32.allOn())  
   bodyNP.setPos(Vec3(pos.getX() + 3, pos.getY() - 4, pos.getZ()))
   bodyNP.setHpr(turn)
   
   visNP = loader.loadModel('media/models/box.egg')
   visNP.setScale(Vec3(1, 3, 0.1)*2*scale)
   visNP.clearModelNodes()
   visNP.reparentTo(bodyNP)
   
   self.world.attachRigidBody(bodyC)
   
   bodyNP.node().setLinearVelocity(-100)
   
   # Slider
   frameA = TransformState.makePosHpr(Point3(0, 0, 0), Vec3(0, 0, 0))
   frameB = TransformState.makePosHpr(Point3(0, 0, 0), Vec3(0, 0, 0))
   
   slider = BulletSliderConstraint(bodyA, bodyC, frameA, frameB, True)
   slider.setDebugDrawSize(2.0)
   slider.setLowerLinearLimit(2)
   slider.setUpperLinearLimit(6)
   slider.setLowerAngularLimit(-90)
   slider.setUpperAngularLimit(-85)
   self.world.attachConstraint(slider)
  def setup(self):
    self.worldNP = render.attachNewNode('World')

    # World
    self.debugNP = self.worldNP.attachNewNode(BulletDebugNode('Debug'))
    self.debugNP.show()
    self.debugNP.node().showWireframe(True)
    self.debugNP.node().showConstraints(True)
    self.debugNP.node().showBoundingBoxes(False)
    self.debugNP.node().showNormals(False)

    self.world = BulletWorld()
    self.world.setGravity(Vec3(0, 0, -9.81))
    self.world.setDebugNode(self.debugNP.node())

    # Box A
    shape = BulletBoxShape(Vec3(0.5, 0.5, 0.5))

    bodyA = BulletRigidBodyNode('Box A')
    bodyNP = self.worldNP.attachNewNode(bodyA)
    bodyNP.node().addShape(shape)
    bodyNP.setCollideMask(BitMask32.allOn())
    bodyNP.setPos(-3, 0, 4)

    visNP = loader.loadModel('models/box.egg')
    visNP.clearModelNodes()
    visNP.reparentTo(bodyNP)

    self.world.attachRigidBody(bodyA)

    # Box B
    shape = BulletBoxShape(Vec3(0.5, 0.5, 0.5))

    bodyB = BulletRigidBodyNode('Box B')
    bodyNP = self.worldNP.attachNewNode(bodyB)
    bodyNP.node().addShape(shape)
    bodyNP.node().setMass(1.0)
    bodyNP.node().setDeactivationEnabled(False)
    bodyNP.setCollideMask(BitMask32.allOn())
    bodyNP.setPos(0, 0, 0)

    visNP = loader.loadModel('models/box.egg')
    visNP.clearModelNodes()
    visNP.reparentTo(bodyNP)

    self.world.attachRigidBody(bodyB)

    # Slider
    frameA = TransformState.makePosHpr(Point3(2, 0, 0), Vec3(0, 0, 45))
    frameB = TransformState.makePosHpr(Point3(0, -3, 0), Vec3(0, 0, 0))

    slider = BulletSliderConstraint(bodyA, bodyB, frameA, frameB, True)
    slider.setDebugDrawSize(2.0)
    slider.setLowerLinearLimit(0)
    slider.setUpperLinearLimit(6)
    slider.setLowerAngularLimit(-60)
    slider.setUpperAngularLimit(60)
    self.world.attachConstraint(slider)