Пример #1
0
 def _CountRotations(self, curYaw):
     """
     Count the number of full ship rotations that have occurred.
       fetch positive or negative from direction (float)
       fetch the yaw from the camera rotation quaternion
     """
     spinDirection = mathCommon.GetLesserAngleBetweenYaws(
         self.prevYaw, curYaw)
     if spinDirection == 0.0:
         return
     if self.prevDirection is None:
         self.prevDirection = spinDirection
     if self.prevDirection * spinDirection < 0.0:
         self.prevYaw = self.startYaw = curYaw
         self.prevDirection = spinDirection
     caughtSpin = False
     if self.prevYaw < curYaw:
         caughtSpin = self.prevYaw < self.startYaw < curYaw and spinDirection > 0.0
     elif self.prevYaw > curYaw:
         caughtSpin = self.prevYaw > self.startYaw > curYaw and spinDirection < 0.0
     if caughtSpin:
         self.numSpins += 1
         self.spinCounterLabel.text = util.FmtAmt(self.numSpins)
         self.spinCounterTimer = AutoTimer(30000, self.HideSpinCounter)
         if self.numSpins >= self.spinCounterLabel.startSpinCount + 10 and not self.spinCounterLabel.displayTriggered:
             self.spinCounterLabel.Show()
             uicore.animations.BlinkIn(self.spinCounterLabel,
                                       duration=0.5,
                                       endVal=0.6,
                                       loops=2)
             self.spinCounterLabel.displayTriggered = True
         elif self.numSpins % 1000 == 0 and self.spinCounterLabel.displayTriggered:
             uicore.animations.SpColorMorphTo(self.spinCounterLabel,
                                              startColor=(1.0, 1.0, 1.0,
                                                          0.6),
                                              endColor=(0.0, 1.0, 1.0, 1.0),
                                              duration=1.0,
                                              sleep=True)
             uicore.animations.SpColorMorphTo(self.spinCounterLabel,
                                              startColor=(0.0, 1.0, 1.0,
                                                          1.0),
                                              endColor=(1.0, 1.0, 1.0, 0.6),
                                              duration=1.0)
         elif self.numSpins % 100 == 0 and self.spinCounterLabel.displayTriggered:
             uicore.animations.SpColorMorphTo(self.spinCounterLabel,
                                              startColor=(1.0, 1.0, 1.0,
                                                          0.6),
                                              endColor=(1.0, 1.0, 1.0, 1.0),
                                              duration=0.75,
                                              sleep=True)
             uicore.animations.SpColorMorphTo(self.spinCounterLabel,
                                              startColor=(1.0, 1.0, 1.0,
                                                          1.0),
                                              endColor=(1.0, 1.0, 1.0, 0.6),
                                              duration=0.75)
     self.prevYaw = curYaw
Пример #2
0
 def SmoothMove(self, targetPosition, targetRotation, targetTilt, targetDist, durationMS, callbackOnEnd = None):
     sPos, sRot, sTilt, sDist = (self.GetPointOfInterest(),
      self.yaw,
      self.pitch,
      self.zoom)
     ePos, eRot, eTilt, eDist = (targetPosition,
      targetRotation,
      targetTilt,
      targetDist)
     eRot = sRot + mathCommon.GetLesserAngleBetweenYaws(sRot, eRot)
     self._smoothMoveTimer = AutoTimer(50, self.UpdateSmoothMove, sPos, sRot, sTilt, sDist, ePos, eRot, eTilt, eDist, blue.os.GetWallclockTime(), float(durationMS), callbackOnEnd)
Пример #3
0
def GetAngleFromEntityToCamera(entity, overrideYaw=None, offset=None):
    activeCamera = sm.GetService('cameraClient').GetActiveCamera()
    cameraYaw = -activeCamera.yaw
    if overrideYaw:
        cameraYaw = overrideYaw
    if offset:
        cameraYaw = offset + cameraYaw
    playerYaw = GetEntityYaw(entity)
    retval = 0.0
    if playerYaw != None and cameraYaw != None:
        lesserYaw = mathCommon.GetLesserAngleBetweenYaws(playerYaw, cameraYaw)
        retval = lesserYaw
    return retval
Пример #4
0
 def _CountRotations(self, curYaw):
     spinDirection = mathCommon.GetLesserAngleBetweenYaws(
         self.prevYaw, curYaw)
     if spinDirection == 0.0:
         return
     if self.prevDirection is None:
         self.prevDirection = spinDirection
     if self.prevDirection * spinDirection < 0.0:
         self.prevYaw = self.startYaw = curYaw
         self.prevDirection = spinDirection
     caughtSpin = False
     if self.prevYaw < curYaw:
         caughtSpin = self.prevYaw < self.startYaw < curYaw and spinDirection > 0.0
     elif self.prevYaw > curYaw:
         caughtSpin = self.prevYaw > self.startYaw > curYaw and spinDirection < 0.0
     if caughtSpin:
         self.numSpins += 1
         self.spinCounterLabel.text = util.FmtAmt(self.numSpins)
         self.spinCounterTimer = base.AutoTimer(30000, self.HideSpinCounter)
         if self.numSpins >= self.spinCounterLabel.startSpinCount + 10 and not self.spinCounterLabel.displayTriggered:
             self.spinCounterLabel.Show()
             uicore.animations.BlinkIn(self.spinCounterLabel,
                                       duration=0.5,
                                       endVal=0.6,
                                       loops=2)
             self.spinCounterLabel.displayTriggered = True
         elif self.numSpins % 1000 == 0 and self.spinCounterLabel.displayTriggered:
             uicore.animations.SpColorMorphTo(self.spinCounterLabel,
                                              startColor=(1.0, 1.0, 1.0,
                                                          0.6),
                                              endColor=(0.0, 1.0, 1.0, 1.0),
                                              duration=1.0,
                                              sleep=True)
             uicore.animations.SpColorMorphTo(self.spinCounterLabel,
                                              startColor=(0.0, 1.0, 1.0,
                                                          1.0),
                                              endColor=(1.0, 1.0, 1.0, 0.6),
                                              duration=1.0)
         elif self.numSpins % 100 == 0 and self.spinCounterLabel.displayTriggered:
             uicore.animations.SpColorMorphTo(self.spinCounterLabel,
                                              startColor=(1.0, 1.0, 1.0,
                                                          0.6),
                                              endColor=(1.0, 1.0, 1.0, 1.0),
                                              duration=0.75,
                                              sleep=True)
             uicore.animations.SpColorMorphTo(self.spinCounterLabel,
                                              startColor=(1.0, 1.0, 1.0,
                                                          1.0),
                                              endColor=(1.0, 1.0, 1.0, 0.6),
                                              duration=0.75)
     self.prevYaw = curYaw
Пример #5
0
 def SmoothCameraBehindPlayer(self, camera, frameTime):
     entity = self._GetEntity(self.entID)
     if entity:
         isMoving = entity.position.position != self.lastPosition
         self.lastPosition = entity.position.position
         if isMoving and not uicore.uilib.rightbtn and not uicore.uilib.leftbtn:
             plrYaw = geo2.QuaternionRotationGetYawPitchRoll(entity.position.rotation)[0]
             curCamYaw = camera.GetRotationAsYaw()
             diff = mathCommon.GetLesserAngleBetweenYaws(plrYaw, curCamYaw)
             maxRot = self.minSmoothRadians * frameTime
             minRot = -maxRot
             if diff > maxRot:
                 maxRot = (diff - maxRot) * self.fasterThenSlowerRatio * frameTime + maxRot
             if diff < minRot:
                 maxRot = -((diff - minRot) * self.fasterThenSlowerRatio * frameTime + minRot)
             camera.AdjustYaw(diff / self.smoothLagFactor, maxRot, ignoreUpdate=True)
Пример #6
0
 def UpdateMovement(self):
     debug = sm.GetService('debugRenderClient')
     yaw = geo2.QuaternionRotationGetYawPitchRoll(
         self.entityRef.position.rotation)[0]
     velYaw = mathCommon.GetYawAngleFromDirectionVector(self.entVel)
     angle = mathCommon.GetLesserAngleBetweenYaws(yaw, velYaw)
     headingToApply = self.entityRef.movement.physics.velocity
     speed = geo2.Vec3Length((headingToApply[0], 0.0, headingToApply[2]))
     self.SetControlParameter('Speed', speed)
     moveState = self.entityRef.GetComponent('movement').moveState
     self.SetControlParameter('Moving',
                              int(moveState.GetStaticStateIndex() > 0))
     immed = moveState.GetImmediateRotation()
     if immed != 0.0:
         self.SetControlParameter('TurnAngle', immed / math.pi)
     else:
         self.SetControlParameter('TurnAngle', 0.0)
Пример #7
0
def GetAngleFromEntityToYaw(entity, yaw):
    lesserYaw = mathCommon.GetLesserAngleBetweenYaws(GetEntityYaw(entity), yaw)
    return lesserYaw
Пример #8
0
def GetAngleFromEntityToYaw(entity, yaw):
    """
    Returns the shortest angle between the entity's facing direction and a specified yaw.
    """
    lesserYaw = mathCommon.GetLesserAngleBetweenYaws(GetEntityYaw(entity), yaw)
    return lesserYaw