def load(self):
     assert not self._loaded, "Cannot load scenario twice!"
     
     self._loaded = True
     
     # Create the rigid bodies for the main staircase        
     orientation = PyUtils.angleAxisToQuaternion( (self._angle,(0,1,0)) )
     size = MathLib.Vector3d( self._staircaseWidth, self._riserHeight, self._threadDepth )
     pos = PyUtils.toPoint3d( self._position ) + MathLib.Vector3d( 0, -self._riserHeight/2.0, 0 )
     delta = MathLib.Vector3d(size)
     delta.x = 0
     delta = orientation.rotate( delta )
     for i in range(self._stepCount):
         box = PyUtils.RigidBody.createBox( size, pos = pos + delta * (i+1), locked = True, orientation=orientation )
         Physics.world().addRigidBody(box)
     
     # Create the rigid bodies for both ramps
     rampHeights = ( self._leftRampHeight, self._rightRampHeight )
     
     deltaRamp = MathLib.Vector3d(self._staircaseWidth/2.0,0,0)
     deltaRamp = orientation.rotate( deltaRamp )
     deltaRamps = (deltaRamp, deltaRamp * -1)
     for deltaRamp, rampHeight in zip( deltaRamps, rampHeights ):
         if rampHeight is None: continue
         deltaRamp.y = rampHeight/2.0
         box = PyUtils.RigidBody.createBox( (0.02,rampHeight,0.02), pos = pos + deltaRamp + delta , locked = True, orientation=orientation )
         Physics.world().addRigidBody(box)
         box = PyUtils.RigidBody.createBox( (0.02,rampHeight,0.02), pos = pos + deltaRamp + (delta * self._stepCount) , locked = True, orientation=orientation )
         Physics.world().addRigidBody(box)
         deltaRamp.y = rampHeight
         rampOrientation = orientation * PyUtils.angleAxisToQuaternion( (math.atan2(self._riserHeight, self._threadDepth), (-1,0,0)) )
         rampLen = self._stepCount * math.sqrt( self._riserHeight*self._riserHeight + self._threadDepth*self._threadDepth )
         box = PyUtils.RigidBody.createBox( (0.04,0.02,rampLen), pos = pos + deltaRamp + (delta * ((self._stepCount+1) * 0.5)) , locked = True, orientation=rampOrientation )
         Physics.world().addRigidBody(box)
Ejemplo n.º 2
0
    def load(self):
        assert not self._loaded, "Cannot load scenario twice!"

        self._loaded = True

        # Create the rigid bodies for the main staircase
        orientation = PyUtils.angleAxisToQuaternion((self._angle, (0, 1, 0)))
        size = MathLib.Vector3d(self._staircaseWidth, self._riserHeight,
                                self._threadDepth)
        pos = PyUtils.toPoint3d(self._position) + MathLib.Vector3d(
            0, -self._riserHeight / 2.0, 0)
        delta = MathLib.Vector3d(size)
        delta.x = 0
        delta = orientation.rotate(delta)
        for i in range(self._stepCount):
            box = PyUtils.RigidBody.createBox(size,
                                              pos=pos + delta * (i + 1),
                                              locked=True,
                                              orientation=orientation)
            Physics.world().addRigidBody(box)

        # Create the rigid bodies for both ramps
        rampHeights = (self._leftRampHeight, self._rightRampHeight)

        deltaRamp = MathLib.Vector3d(self._staircaseWidth / 2.0, 0, 0)
        deltaRamp = orientation.rotate(deltaRamp)
        deltaRamps = (deltaRamp, deltaRamp * -1)
        for deltaRamp, rampHeight in zip(deltaRamps, rampHeights):
            if rampHeight is None: continue
            deltaRamp.y = rampHeight / 2.0
            box = PyUtils.RigidBody.createBox((0.02, rampHeight, 0.02),
                                              pos=pos + deltaRamp + delta,
                                              locked=True,
                                              orientation=orientation)
            Physics.world().addRigidBody(box)
            box = PyUtils.RigidBody.createBox(
                (0.02, rampHeight, 0.02),
                pos=pos + deltaRamp + (delta * self._stepCount),
                locked=True,
                orientation=orientation)
            Physics.world().addRigidBody(box)
            deltaRamp.y = rampHeight
            rampOrientation = orientation * PyUtils.angleAxisToQuaternion(
                (math.atan2(self._riserHeight, self._threadDepth), (-1, 0, 0)))
            rampLen = self._stepCount * math.sqrt(
                self._riserHeight * self._riserHeight +
                self._threadDepth * self._threadDepth)
            box = PyUtils.RigidBody.createBox(
                (0.04, 0.02, rampLen),
                pos=pos + deltaRamp + (delta * ((self._stepCount + 1) * 0.5)),
                locked=True,
                orientation=rampOrientation)
            Physics.world().addRigidBody(box)
 def interpret(self, value):
     value = self.basicInterpret(value)
     if isinstance(value, MathLib.Quaternion) : return value
     else : return PyUtils.angleAxisToQuaternion( value )
Ejemplo n.º 4
0
 def interpret(self, value):
     value = self.basicInterpret(value)
     if isinstance(value, MathLib.Quaternion): return value
     else: return PyUtils.angleAxisToQuaternion(value)