예제 #1
0
    def translate_backward(self, amount):
        """Translates the object backward along the inertial X,Z
        plane.
        """
        quat = quaternion.set_to_rotation_about_y(self.yaw)

        matrix = matrix33.create_from_quaternion(quat)
        vec = matrix33.apply_to_vector([0.0, 0.0, 1.0], matrix)
        vec *= amount
        self.transform.inertial.translate(vec)
예제 #2
0
    def translate_forward( self, amount ):
        """Translates the object forward along the inertial X,Z
        plane.
        """
        quat = quaternion.set_to_rotation_about_y( self.yaw )

        matrix = matrix33.create_from_quaternion( quat )
        vec = matrix33.apply_to_vector(
            [0.0, 0.0,-1.0],
            matrix
            )
        vec *= amount
        self.transform.inertial.translate( vec )
예제 #3
0
 def orient(self, pitch=None, yaw=None, roll=None):
     """Over-ride the current orientation.
     """
     if yaw != None:
         quat = quaternion.set_to_rotation_about_y(yaw)
         self.transform.orientation = quaternion.cross(
             quat, self.transform.orientation)
     if pitch != None:
         quat = quaternion.set_to_rotation_about_x(pitch)
         self.transform.orientation = quaternion.cross(
             quat, self.transform.orientation)
     if roll != None:
         quat = quaternion.set_to_rotation_about_z(roll)
         self.transform.orientation = quaternion.cross(
             quat, self.transform.orientation)
예제 #4
0
    def _update(self):
        """Updates the orientation of the object.

        This should be called once all of the yaw / pitch
        modifications are applied.
        """
        # limit our pitch to +- 1/2 pi
        if self.pitch > self.piOver2:
            self.pitch = self.piOver2
        if self.pitch < -self.piOver2:
            self.pitch = -self.piOver2

        pitchQuat = quaternion.set_to_rotation_about_x(self.pitch)
        yawQuat = quaternion.set_to_rotation_about_y(self.yaw)

        quat = quaternion.cross(pitchQuat, yawQuat)
        quaternion.normalise(quat)
        self.transform.orientation = quat
예제 #5
0
    def _update( self ):
        """Updates the orientation of the object.

        This should be called once all of the yaw / pitch
        modifications are applied.
        """
        # limit our pitch to +- 1/2 pi
        if self.pitch > self.piOver2:
            self.pitch = self.piOver2
        if self.pitch < -self.piOver2:
            self.pitch = -self.piOver2
        
        pitchQuat = quaternion.set_to_rotation_about_x( self.pitch )
        yawQuat = quaternion.set_to_rotation_about_y( self.yaw )
        
        quat = quaternion.cross( pitchQuat, yawQuat )
        quaternion.normalise( quat )
        self.transform.orientation = quat
 def orient( self, pitch = None, yaw = None, roll = None ):
     """Over-ride the current orientation.
     """
     if yaw != None:
         quat = quaternion.set_to_rotation_about_y( yaw )
         self.transform.orientation = quaternion.cross(
             quat,
             self.transform.orientation
             )
     if pitch != None:
         quat = quaternion.set_to_rotation_about_x( pitch )
         self.transform.orientation = quaternion.cross(
             quat,
             self.transform.orientation
             )
     if roll != None:
         quat = quaternion.set_to_rotation_about_z( roll )
         self.transform.orientation = quaternion.cross(
             quat,
             self.transform.orientation
             )