Exemplo n.º 1
0
 def update(self, deltaTime):
     self.__oscillator.constraints = mathUtils.matrixScale(self.__yprDeviationConstraints, SniperAimingSystem.__CONSTRAINTS_MULTIPLIERS)
     l_curYaw, l_curPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__g_curPitch)
     stabilizationOn = math.fabs(self._matrix.roll) < self.__stailizationLimit and SniperAimingSystem.__FILTER_ENABLED
     if stabilizationOn:
         l_curYaw, l_curNewPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     else:
         l_curNewPitch = l_curPitch
     if stabilizationOn:
         newLocal = l_curPitch + (l_curNewPitch - l_curPitch)
         newGunMat = AimingSystems.getPlayerGunMat(l_curYaw, newLocal)
         new__g_curPitch = newGunMat.pitch
         new__g_curPitch = self.__pitchfilter.update(new__g_curPitch, deltaTime)
         globalDelta = new__g_curPitch - self.__g_curPitch
     else:
         globalDelta = l_curNewPitch - self.__idealPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     self.__oscillator.update(deltaTime)
     l_curYaw = self.__idealYaw + self.__oscillator.deviation.x
     if stabilizationOn:
         l_curPitch = l_curPitch + self.__oscillator.deviation.y
     else:
         l_curPitch = self.__idealPitch + self.__oscillator.deviation.y
     l_curYaw, l_newCurPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     if not stabilizationOn:
         globalDelta = l_newCurPitch - self.__idealPitch
         l_curPitch = l_newCurPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     currentGunMat = AimingSystems.getPlayerGunMat(l_curYaw, l_curPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     return 0.0
Exemplo n.º 2
0
 def update(self, deltaTime):
     self.__oscillator.constraints = mathUtils.matrixScale(self.__yprDeviationConstraints, SniperAimingSystem.__CONSTRAINTS_MULTIPLIERS)
     l_curYaw, l_curPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__g_curPitch)
     stabilizationOn = math.fabs(self._matrix.roll) < self.__stailizationLimit and SniperAimingSystem.__FILTER_ENABLED
     if stabilizationOn:
         l_curYaw, l_curNewPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     else:
         l_curNewPitch = l_curPitch
     if stabilizationOn:
         newLocal = l_curPitch + (l_curNewPitch - l_curPitch)
         newGunMat = AimingSystems.getPlayerGunMat(l_curYaw, newLocal)
         new__g_curPitch = newGunMat.pitch
         new__g_curPitch = self.__pitchfilter.update(new__g_curPitch, deltaTime)
         globalDelta = new__g_curPitch - self.__g_curPitch
     else:
         globalDelta = l_curNewPitch - self.__idealPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     self.__oscillator.update(deltaTime)
     l_curYaw = self.__idealYaw + self.__oscillator.deviation.x
     if stabilizationOn:
         l_curPitch = l_curPitch + self.__oscillator.deviation.y
     else:
         l_curPitch = self.__idealPitch + self.__oscillator.deviation.y
     l_curYaw, l_newCurPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     if not stabilizationOn:
         globalDelta = l_newCurPitch - self.__idealPitch
         l_curPitch = l_newCurPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     currentGunMat = AimingSystems.getPlayerGunMat(l_curYaw, l_curPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     return 0.0
Exemplo n.º 3
0
 def update(self, deltaTime):
     if self.__forceFullStabilization:
         self.__oscillator.constraints = SniperAimingSystem.__STABILIZED_CONSTRAINTS
     else:
         self.__oscillator.constraints = mathUtils.matrixScale(self.__yprDeviationConstraints, SniperAimingSystem.__CONSTRAINTS_MULTIPLIERS)
     curTurretYaw, curGunPitch = self.__worldYawPitchToTurret(self.__worldYaw, self.__worldPitch)
     yprDelta = Vector3(curTurretYaw - self.__idealTurretYaw, curGunPitch - self.__idealGunPitch, 0.0)
     self.__oscillator.deviation = yprDelta
     self.__oscillator.update(deltaTime)
     curTurretYaw = self.__idealTurretYaw + self.__oscillator.deviation.x
     curGunPitch = self.__idealGunPitch + self.__oscillator.deviation.y
     if self.__returningOscillator.deviation.y <= 0.0:
         self.__returningOscillator.reset()
     pitchOutOfBounds = self.__calcPitchExcess(curTurretYaw, curGunPitch)
     if pitchOutOfBounds != 0.0:
         self.__timeBeyondLimits += deltaTime
         self.__adjustPitchLimitExtension(abs(pitchOutOfBounds))
         if self.__timeBeyondLimits > SniperAimingSystem.__BEYOND_LIMITS_DELAY:
             self.__returningOscillator.update(deltaTime)
     else:
         self.__returningOscillator.reset()
         self.__timeBeyondLimits = 0.0
     curTurretYaw, curGunPitch = self.__clampToLimits(curTurretYaw, curGunPitch)
     yprDelta = Vector3(curTurretYaw - self.__idealTurretYaw, curGunPitch - self.__idealGunPitch, 0.0)
     self.__oscillator.deviation = yprDelta
     currentGunMat = self.__getPlayerGunMat(curTurretYaw, curGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
Exemplo n.º 4
0
 def update(self, deltaTime):
     self.__oscillator.constraints = mathUtils.matrixScale(
         self.__yprDeviationConstraints,
         SniperAimingSystem.__CONSTRAINTS_MULTIPLIERS)
     vehicleMat = Matrix(self.__vehicleMProv)
     curTurretYaw, curGunPitch = self.__worldYawPitchToTurret(
         self.__worldYaw, self.__worldPitch)
     yprDelta = Vector3(curTurretYaw - self.__idealTurretYaw,
                        curGunPitch - self.__idealGunPitch, 0)
     self.__oscillator.deviation = yprDelta
     self.__oscillator.update(deltaTime)
     curTurretYaw = self.__idealTurretYaw + self.__oscillator.deviation.x
     curGunPitch = self.__idealGunPitch + self.__oscillator.deviation.y
     curTurretYaw, curGunPitch = self.__clampToLimits(
         curTurretYaw, curGunPitch)
     yprDelta = Vector3(curTurretYaw - self.__idealTurretYaw,
                        curGunPitch - self.__idealGunPitch, 0)
     self.__oscillator.deviation = yprDelta
     currentGunMat = AimingSystems.getPlayerGunMat(curTurretYaw,
                                                   curGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__vehiclePrevMat = vehicleMat
     return 0.0
Exemplo n.º 5
0
def RandomNoiseOscillatorSpherical(mass,
                                   stiffness,
                                   drag,
                                   scaleCoeff=Vector3(1.0, 1.0, 1.0),
                                   restEpsilon=0.01):
    randomFunc = lambda deviation, generator: matrixScale(
        mathUtils.RandomVectors.random3(deviation, generator), scaleCoeff)
    return RandomNoiseOscillator(mass, stiffness, drag, randomFunc,
                                 restEpsilon)
Exemplo n.º 6
0
 def update(self, deltaTime):
     self.__oscillator.constraints = mathUtils.matrixScale(self.__yprDeviationConstraints, SniperAimingSystem.__CONSTRAINTS_MULTIPLIERS)
     vehicleMat = Matrix(self.__vehicleMProv)
     curTurretYaw, curGunPitch = self.__worldYawPitchToTurret(self.__worldYaw, self.__worldPitch)
     yprDelta = Vector3(curTurretYaw - self.__idealTurretYaw, curGunPitch - self.__idealGunPitch, 0.0)
     self.__oscillator.deviation = yprDelta
     self.__oscillator.update(deltaTime)
     curTurretYaw = self.__idealTurretYaw + self.__oscillator.deviation.x
     curGunPitch = self.__idealGunPitch + self.__oscillator.deviation.y
     curTurretYaw, curGunPitch = self.__clampToLimits(curTurretYaw, curGunPitch)
     yprDelta = Vector3(curTurretYaw - self.__idealTurretYaw, curGunPitch - self.__idealGunPitch, 0.0)
     self.__oscillator.deviation = yprDelta
     currentGunMat = AimingSystems.getPlayerGunMat(curTurretYaw, curGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__vehiclePrevMat = vehicleMat
     return 0.0
Exemplo n.º 7
0
 def __calcForce(self):
     return self.externalForce - matrixScale(self.deviation, self.stiffness) - matrixScale(self.velocity, self.drag)
Exemplo n.º 8
0
def RandomNoiseOscillatorSpherical(mass, stiffness, drag, scaleCoeff = Vector3(1.0, 1.0, 1.0), restEpsilon = 0.01):
    randomFunc = lambda deviation, generator: matrixScale(mathUtils.RandomVectors.random3(deviation, generator), scaleCoeff)
    return RandomNoiseOscillator(mass, stiffness, drag, randomFunc, restEpsilon)
Exemplo n.º 9
0
 def __calcForce(self):
     return self.externalForce - matrixScale(self.deviation,
                                             self.stiffness) - matrixScale(
                                                 self.velocity, self.drag)
Exemplo n.º 10
0
 def update(self, deltaTime):
     self.__oscillator.constraints = mathUtils.matrixScale(self.__yprDeviationConstraints, SniperAimingSystem.__CONSTRAINTS_MULTIPLIERS)
     l_curYaw, l_curPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__g_curPitch)
     if self.__dInputYaw != 0.0 or self.__dInputPitch != 0.0:
         if SniperAimingSystem.__FILTER_ENABLED:
             wasInLimit, _ = self.__inLimit(l_curYaw, l_curPitch, True)
             self.__g_curYaw += self.__dInputYaw
             g_newPitch = self.__g_curPitch + self.__dInputPitch
             l_newYaw, l_newPitch = self.__worldYawPitchToTurret(self.__g_curYaw, g_newPitch)
             if self.__dInputYaw != 0.0:
                 self.__idealYaw, l_limPitch = self.__clampToLimits(l_newYaw, l_newPitch, True)
                 l_curYaw = self.__idealYaw
                 if math.fabs(l_limPitch - l_newPitch) > 1e-05:
                     self.__dInputPitch = l_limPitch - l_curPitch
                     g_newPitch = self.__g_curPitch + self.__dInputPitch
                     l_newPitch = l_limPitch
                 self.__idealPitch = l_limPitch
             if self.__dInputPitch != 0.0:
                 inLimit, limPitch = self.__inLimit(self.__idealYaw, l_newPitch, True)
                 if not wasInLimit and not inLimit and math.fabs(l_newPitch) >= math.fabs(l_curPitch):
                     self.__pitchfilter.resetTimer()
                 else:
                     if wasInLimit and not inLimit:
                         self.__g_curPitch += limPitch - l_curPitch
                         l_curPitch = self.__idealPitch = limPitch
                     else:
                         self.__g_curPitch = g_newPitch
                         l_curPitch = self.__idealPitch = l_newPitch
                     if inLimit:
                         self.__pitchfilter.reset(self.__g_curPitch)
         else:
             self.__idealYaw, self.__idealPitch = self.__clampToLimits(l_curYaw + self.__dInputYaw, l_curPitch + self.__dInputPitch)
             l_curYaw = self.__idealYaw
             currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, self.__idealPitch)
             self.__g_curYaw = currentGunMat.yaw
             self.__g_curPitch = currentGunMat.pitch
         self.__oscillator.velocity = Vector3(0.0, 0.0, 0.0)
         self.__dInputYaw = 0.0
         self.__dInputPitch = 0.0
         l_curNewPitch = self.__idealPitch
     elif SniperAimingSystem.__FILTER_ENABLED:
         l_curYaw, l_curNewPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     else:
         l_curNewPitch = l_curPitch
     if SniperAimingSystem.__FILTER_ENABLED:
         new__g_curPitch = self.__g_curPitch + (l_curNewPitch - l_curPitch)
         new__g_curPitch = self.__pitchfilter.update(new__g_curPitch, deltaTime)
         globalDelta = new__g_curPitch - self.__g_curPitch
     else:
         globalDelta = l_curNewPitch - self.__idealPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     self.__oscillator.update(deltaTime)
     l_curYaw = self.__idealYaw + self.__oscillator.deviation.x
     if SniperAimingSystem.__FILTER_ENABLED:
         l_curPitch = l_curPitch + self.__oscillator.deviation.y
     else:
         l_curPitch = self.__idealPitch + self.__oscillator.deviation.y
     l_curYaw, l_newCurPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     if not SniperAimingSystem.__FILTER_ENABLED:
         globalDelta = l_newCurPitch - self.__idealPitch
         l_curPitch = l_newCurPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     currentGunMat = AimingSystems.getPlayerGunMat(l_curYaw, l_curPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     return 0.0
Exemplo n.º 11
0
 def update(self, deltaTime):
     self.__oscillator.constraints = mathUtils.matrixScale(
         self.__yprDeviationConstraints,
         SniperAimingSystem.__CONSTRAINTS_MULTIPLIERS)
     l_curYaw, l_curPitch = self.__worldYawPitchToTurret(
         self.__g_curYaw, self.__g_curPitch)
     if self.__dInputYaw != 0.0 or self.__dInputPitch != 0.0:
         if SniperAimingSystem.__FILTER_ENABLED:
             wasInLimit, _ = self.__inLimit(l_curYaw, l_curPitch, True)
             self.__g_curYaw += self.__dInputYaw
             g_newPitch = self.__g_curPitch + self.__dInputPitch
             l_newYaw, l_newPitch = self.__worldYawPitchToTurret(
                 self.__g_curYaw, g_newPitch)
             if self.__dInputYaw != 0.0:
                 self.__idealYaw, l_limPitch = self.__clampToLimits(
                     l_newYaw, l_newPitch, True)
                 l_curYaw = self.__idealYaw
                 if math.fabs(l_limPitch - l_newPitch) > 1e-05:
                     self.__dInputPitch = l_limPitch - l_curPitch
                     g_newPitch = self.__g_curPitch + self.__dInputPitch
                     l_newPitch = l_limPitch
                 self.__idealPitch = l_limPitch
             if self.__dInputPitch != 0.0:
                 inLimit, limPitch = self.__inLimit(self.__idealYaw,
                                                    l_newPitch, True)
                 if not wasInLimit and not inLimit and math.fabs(
                         l_newPitch) >= math.fabs(l_curPitch):
                     self.__pitchfilter.resetTimer()
                 else:
                     if wasInLimit and not inLimit:
                         self.__g_curPitch += limPitch - l_curPitch
                         l_curPitch = self.__idealPitch = limPitch
                     else:
                         self.__g_curPitch = g_newPitch
                         l_curPitch = self.__idealPitch = l_newPitch
                     if inLimit:
                         self.__pitchfilter.reset(self.__g_curPitch)
         else:
             self.__idealYaw, self.__idealPitch = self.__clampToLimits(
                 l_curYaw + self.__dInputYaw,
                 l_curPitch + self.__dInputPitch)
             l_curYaw = self.__idealYaw
             currentGunMat = AimingSystems.getPlayerGunMat(
                 self.__idealYaw, self.__idealPitch)
             self.__g_curYaw = currentGunMat.yaw
             self.__g_curPitch = currentGunMat.pitch
         self.__oscillator.velocity = Vector3(0.0, 0.0, 0.0)
         self.__dInputYaw = 0.0
         self.__dInputPitch = 0.0
         l_curNewPitch = self.__idealPitch
     elif SniperAimingSystem.__FILTER_ENABLED:
         l_curYaw, l_curNewPitch = self.__clampToLimits(
             l_curYaw, l_curPitch)
     else:
         l_curNewPitch = l_curPitch
     if SniperAimingSystem.__FILTER_ENABLED:
         new__g_curPitch = self.__g_curPitch + (l_curNewPitch - l_curPitch)
         new__g_curPitch = self.__pitchfilter.update(
             new__g_curPitch, deltaTime)
         globalDelta = new__g_curPitch - self.__g_curPitch
     else:
         globalDelta = l_curNewPitch - self.__idealPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     self.__oscillator.update(deltaTime)
     l_curYaw = self.__idealYaw + self.__oscillator.deviation.x
     if SniperAimingSystem.__FILTER_ENABLED:
         l_curPitch = l_curPitch + self.__oscillator.deviation.y
     else:
         l_curPitch = self.__idealPitch + self.__oscillator.deviation.y
     l_curYaw, l_newCurPitch = self.__clampToLimits(l_curYaw, l_curPitch)
     if not SniperAimingSystem.__FILTER_ENABLED:
         globalDelta = l_newCurPitch - self.__idealPitch
         l_curPitch = l_newCurPitch
     yprDelta = Vector3(l_curYaw - self.__idealYaw, globalDelta, 0.0)
     self.__oscillator.deviation = yprDelta
     currentGunMat = AimingSystems.getPlayerGunMat(l_curYaw, l_curPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     return 0.0