コード例 #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
コード例 #2
0
 def handleMovement(self, dx, dy):
     self.__idealYaw, self.__idealPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__pitchfilter.value())
     newPitch = self.__idealPitch + dy
     newYaw = self.__idealYaw + dx
     self.__idealYaw, idealPitch, inLimit, pitchMin, dp = self.__inLimit(self.__idealYaw, newYaw, newPitch)
     newPitch += dp
     if not inLimit:
         d1 = pitchMin - self.__idealPitch
         d2 = pitchMin - newPitch
         if math.fabs(d1) >= math.fabs(d2):
             self.__idealPitch = idealPitch
         currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, self.__idealPitch)
         self.__pitchfilter.adjust(currentGunMat.pitch - self.__pitchfilter.value())
     else:
         currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, idealPitch)
         self.__pitchfilter.reset(currentGunMat.pitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__oscillator.velocity = Vector3(0.0, 0.0, 0.0)
     _, uncompensatedPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleTypeDescriptor, BigWorld.player().getOwnVehicleStabilisedMatrix(), self.getDesiredShotPoint())
     if inLimit:
         self.__pitchCompensating = mathUtils.clamp(math.radians(-2.0), math.radians(2.0), idealPitch - uncompensatedPitch)
     else:
         self.__pitchCompensating = 0.0
コード例 #3
0
 def handleMovement(self, dx, dy):
     self.__idealYaw, self.__idealPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__pitchfilter.value())
     newPitch = self.__idealPitch + dy
     newYaw = self.__idealYaw + dx
     self.__idealYaw, idealPitch, inLimit, pitchMin, dp = self.__inLimit(self.__idealYaw, newYaw, newPitch)
     newPitch += dp
     if not inLimit:
         d1 = pitchMin - self.__idealPitch
         d2 = pitchMin - newPitch
         if math.fabs(d1) >= math.fabs(d2):
             self.__idealPitch = idealPitch
         currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, self.__idealPitch)
         self.__pitchfilter.adjust(currentGunMat.pitch - self.__pitchfilter.value())
     else:
         currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, idealPitch)
         self.__pitchfilter.reset(currentGunMat.pitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__oscillator.velocity = Vector3(0.0, 0.0, 0.0)
     _, uncompensatedPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleTypeDescriptor, BigWorld.player().getOwnVehicleStabilisedMatrix(), self.getDesiredShotPoint())
     if inLimit:
         self.__pitchCompensating = mathUtils.clamp(math.radians(-2.0), math.radians(2.0), idealPitch - uncompensatedPitch)
     else:
         self.__pitchCompensating = 0.0
コード例 #4
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
コード例 #5
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
コード例 #6
0
 def enable(self, targetPos):
     player = BigWorld.player()
     self.__vehicleTypeDescriptor = player.vehicleTypeDescriptor
     self.__vehicleMProv = player.getOwnVehicleStabilisedMatrix()
     self.__vehiclePrevMat = Matrix(self.__vehicleMProv)
     IAimingSystem.enable(self, targetPos)
     self.__yawLimits = self.__vehicleTypeDescriptor.gun['turretYawLimits']
     self.__pitchLimits = self.__vehicleTypeDescriptor.gun['pitchLimits']
     self.__idealYaw, self.__idealPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleTypeDescriptor, self.__vehicleMProv, targetPos, True)
     self.__idealYaw, self.__idealPitch = self.__clampToLimits(self.__idealYaw, self.__idealPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, self.__idealPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = (targetPos - currentGunMat.translation).pitch
     self._matrix.set(currentGunMat)
     self.__idealYaw, self.__idealPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__g_curPitch)
     self.__idealYaw, self.__idealPitch = self.__clampToLimits(self.__idealYaw, self.__idealPitch)
     self.__oscillator.reset()
     self.__pitchfilter.reset(currentGunMat.pitch)
     SniperAimingSystem.__activeSystem = self
     vehicle = player.getVehicleAttached()
     if vehicle is not None:
         if not vehicle.filter.placingOnGround:
             vehicle.filter.calcPlacedMatrix(True)
             self.__baseMatrix = vehicle.filter.placingMatrix
         else:
             self.__baseMatrix = vehicle.matrix
     return
コード例 #7
0
 def enable(self, targetPos):
     player = BigWorld.player()
     self.__vehicleTypeDescriptor = player.vehicleTypeDescriptor
     self.__vehicleMProv = player.getOwnVehicleMatrix()
     self.__vehiclePrevMat = Matrix(self.__vehicleMProv)
     IAimingSystem.enable(self, targetPos)
     self.__yawLimits = self.__vehicleTypeDescriptor.gun['turretYawLimits']
     self.__pitchLimits = self.__vehicleTypeDescriptor.gun['pitchLimits']
     self.__idealYaw, self.__idealPitch = getShotAngles(
         self.__vehicleTypeDescriptor, player.getOwnVehicleMatrix(),
         (0.0, 0.0), targetPos, False)
     self.__idealYaw, self.__idealPitch = self.__clampToLimits(
         self.__idealYaw, self.__idealPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw,
                                                   self.__idealPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = (targetPos - currentGunMat.translation).pitch
     self._matrix.set(currentGunMat)
     self.__idealYaw, self.__idealPitch = self.__worldYawPitchToTurret(
         self.__g_curYaw, self.__g_curPitch)
     self.__idealYaw, self.__idealPitch = self.__clampToLimits(
         self.__idealYaw, self.__idealPitch)
     self.__oscillator.reset()
     self.__pitchfilter.reset(currentGunMat.pitch)
     SniperAimingSystem.__activeSystem = self
コード例 #8
0
 def enable(self, targetPos):
     player = BigWorld.player()
     self.__vehicleTypeDescriptor = player.vehicleTypeDescriptor
     self.__vehicleMProv = player.getOwnVehicleStabilisedMatrix()
     self.__vehiclePrevMat = Matrix(self.__vehicleMProv)
     IAimingSystem.enable(self, targetPos)
     self.__yawLimits = self.__vehicleTypeDescriptor.gun['turretYawLimits']
     self.__pitchLimits = self.__vehicleTypeDescriptor.gun['pitchLimits']
     self.__idealYaw, self.__idealPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleTypeDescriptor, self.__vehicleMProv, targetPos, True)
     self.__idealYaw, self.__idealPitch = self.__clampToLimits(self.__idealYaw, self.__idealPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealYaw, self.__idealPitch)
     self.__g_curYaw = currentGunMat.yaw
     self.__g_curPitch = (targetPos - currentGunMat.translation).pitch
     self._matrix.set(currentGunMat)
     self.__idealYaw, self.__idealPitch = self.__worldYawPitchToTurret(self.__g_curYaw, self.__g_curPitch)
     self.__idealYaw, self.__idealPitch = self.__clampToLimits(self.__idealYaw, self.__idealPitch)
     self.__oscillator.reset()
     self.__pitchfilter.reset(currentGunMat.pitch)
     SniperAimingSystem.__activeSystem = self
     vehicle = player.getVehicleAttached()
     if vehicle is not None:
         if hasattr(vehicle.filter, 'placingOnGround') and not vehicle.filter.placingOnGround:
             vehicle.filter.calcPlacedMatrix(True)
             self.__baseMatrix = vehicle.filter.placingMatrix
         else:
             self.__baseMatrix = vehicle.matrix
     return
コード例 #9
0
 def handleMovement(self, dx, dy):
     self.__idealTurretYaw, self.__idealGunPitch = self.__worldYawPitchToTurret(self.__worldYaw, self.__worldPitch)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(self.__idealTurretYaw + dx, self.__idealGunPitch + dy)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealTurretYaw, self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__oscillator.velocity = Vector3(0.0, 0.0, 0.0)
     _, uncompensatedPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleTypeDescriptor, BigWorld.player().getOwnVehicleMatrix(), self.getDesiredShotPoint())
     self.__pitchCompensating = mathUtils.clamp(math.radians(-2.0), math.radians(2.0), self.__idealGunPitch - uncompensatedPitch)
コード例 #10
0
ファイル: sniperaimingsystem.py プロジェクト: webiumsk/WoT
 def handleMovement(self, dx, dy):
     self.resetIdealDirection()
     self.__idealTurretYaw += dx
     self.__idealGunPitch += dy
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(self.__idealTurretYaw, self.__idealGunPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealTurretYaw, self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__oscillator.velocity = Vector3(0, 0, 0)
コード例 #11
0
    def calcTrajectoryProperties(self, aimPoint):
        player = BigWorld.player( )
        descr = player.vehicleTypeDescriptor

        finalPathTurretYaw, finalPathGunPitch = getShotAngles(descr, player.getOwnVehicleMatrix(), (0, 0), aimPoint, True )
        currentGunMat = AimingSystems.getPlayerGunMat(finalPathTurretYaw, finalPathGunPitch)
        clientShotStart = currentGunMat.translation
        clientShotVec = currentGunMat.applyVector(Math.Vector3(0, 0, descr.shot['speed']))

        self._finalPathPoint, self._finalPathShellVelocity, finalPathFlightTime = self._getGunMarkerPosition( clientShotStart, clientShotVec, aimPoint.y if BigWorld._ba_config['spg']['ignoreObstacles'] else None )
コード例 #12
0
    def predictProjectile(self):
        player = BigWorld.player( )
        if not self.enabled or self._projectileID in player._PlayerAvatar__projectileMover._ProjectileMover__projectiles:
            return
        descr = player.vehicleTypeDescriptor
        self._trackProjectile = True
        self._trackProjectileStartTime = BigWorld.time() + 2 * SERVER_TICK_LENGTH

        finalPathTurretYaw, finalPathGunPitch = getShotAngles(descr, player.getOwnVehicleStabilisedMatrix(), (0, 0), self._lastShotPoint, True)
        currentGunMat = AimingSystems.getPlayerGunMat(finalPathTurretYaw, finalPathGunPitch)
        self._trackProjectileStartPoint = currentGunMat.translation
        self._trackProjectileVelocity = currentGunMat.applyVector(Math.Vector3(0, 0, descr.shot['speed']))
コード例 #13
0
 def handleMovement(self, dx, dy):
     self.__idealTurretYaw, self.__idealGunPitch = self.__worldYawPitchToTurret(
         self.__worldYaw, self.__worldPitch)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(
         self.__idealTurretYaw, self.__idealGunPitch)
     self.__idealTurretYaw += dx
     self.__idealGunPitch += dy
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(
         self.__idealTurretYaw, self.__idealGunPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealTurretYaw,
                                                   self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = currentGunMat.pitch
     self._matrix.set(currentGunMat)
     self.__oscillator.velocity = Vector3(0, 0, 0)
コード例 #14
0
    def calcTrajectoryProperties(self, aimPoint):
        player = BigWorld.player()
        descr = player.vehicleTypeDescriptor

        finalPathTurretYaw, finalPathGunPitch = getShotAngles(
            descr, player.getOwnVehicleStabilisedMatrix(), (0, 0), aimPoint,
            True)
        currentGunMat = AimingSystems.getPlayerGunMat(finalPathTurretYaw,
                                                      finalPathGunPitch)
        clientShotStart = currentGunMat.translation
        clientShotVec = currentGunMat.applyVector(
            Math.Vector3(0, 0, descr.shot['speed']))

        self._finalPathPoint, self._finalPathShellVelocity, finalPathFlightTime = self._getGunMarkerPosition(
            clientShotStart, clientShotVec, aimPoint.y
            if BigWorld._ba_config['spg']['ignoreObstacles'] else None)
コード例 #15
0
    def predictProjectile(self):
        player = BigWorld.player()
        if not self.enabled or self._projectileID in player._PlayerAvatar__projectileMover._ProjectileMover__projectiles:
            return
        descr = player.vehicleTypeDescriptor
        self._trackProjectile = True
        self._trackProjectileStartTime = BigWorld.time(
        ) + 2 * SERVER_TICK_LENGTH

        finalPathTurretYaw, finalPathGunPitch = getShotAngles(
            descr, player.getOwnVehicleStabilisedMatrix(), (0, 0),
            self._lastShotPoint, True)
        currentGunMat = AimingSystems.getPlayerGunMat(finalPathTurretYaw,
                                                      finalPathGunPitch)
        self._trackProjectileStartPoint = currentGunMat.translation
        self._trackProjectileVelocity = currentGunMat.applyVector(
            Math.Vector3(0, 0, descr.shot['speed']))
コード例 #16
0
 def enable(self, targetPos):
     player = BigWorld.player()
     self.__vehicleTypeDescriptor = player.vehicleTypeDescriptor
     self.__vehicleMProv = player.getOwnVehicleMatrix()
     self.__vehiclePrevMat = Matrix(self.__vehicleMProv)
     IAimingSystem.enable(self, targetPos)
     player = BigWorld.player()
     desc = player.vehicleTypeDescriptor
     self.__yawLimits = desc.gun['turretYawLimits']
     self.__idealTurretYaw, self.__idealGunPitch = getShotAngles(desc, player.getOwnVehicleMatrix(), (0, 0), targetPos, False)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(self.__idealTurretYaw, self.__idealGunPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealTurretYaw, self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = (targetPos - currentGunMat.translation).pitch
     self._matrix.set(currentGunMat)
     self.__idealTurretYaw, self.__idealGunPitch = self.__worldYawPitchToTurret(self.__worldYaw, self.__worldPitch)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(self.__idealTurretYaw, self.__idealGunPitch)
     self.__oscillator.reset()
コード例 #17
0
 def enable(self, targetPos):
     player = BigWorld.player()
     self.__vehicleTypeDescriptor = player.vehicleTypeDescriptor
     self.__vehicleMProv = player.getOwnVehicleMatrix()
     self.__vehiclePrevMat = Matrix(self.__vehicleMProv)
     IAimingSystem.enable(self, targetPos)
     self.__yawLimits = self.__vehicleTypeDescriptor.gun['turretYawLimits']
     self.__pitchLimits = self.__vehicleTypeDescriptor.gun['pitchLimits']
     self.__idealTurretYaw, self.__idealGunPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleTypeDescriptor, player.getOwnVehicleMatrix(), targetPos, True)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(self.__idealTurretYaw, self.__idealGunPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealTurretYaw, self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = (targetPos - currentGunMat.translation).pitch
     self._matrix.set(currentGunMat)
     self.__idealTurretYaw, self.__idealGunPitch = self.__worldYawPitchToTurret(self.__worldYaw, self.__worldPitch)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(self.__idealTurretYaw, self.__idealGunPitch)
     self.__oscillator.reset()
     SniperAimingSystem.__activeSystem = self
コード例 #18
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
コード例 #19
0
 def enable(self, targetPos):
     player = BigWorld.player()
     self.__vehicleTypeDescriptor = player.vehicleTypeDescriptor
     self.__vehicleMProv = player.getOwnVehicleMatrix()
     self.__vehiclePrevMat = Matrix(self.__vehicleMProv)
     IAimingSystem.enable(self, targetPos)
     player = BigWorld.player()
     desc = player.vehicleTypeDescriptor
     self.__yawLimits = desc.gun['turretYawLimits']
     self.__idealTurretYaw, self.__idealGunPitch = getShotAngles(
         desc, player.getOwnVehicleMatrix(), (0, 0), targetPos, False)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(
         self.__idealTurretYaw, self.__idealGunPitch)
     currentGunMat = AimingSystems.getPlayerGunMat(self.__idealTurretYaw,
                                                   self.__idealGunPitch)
     self.__worldYaw = currentGunMat.yaw
     self.__worldPitch = (targetPos - currentGunMat.translation).pitch
     self._matrix.set(currentGunMat)
     self.__idealTurretYaw, self.__idealGunPitch = self.__worldYawPitchToTurret(
         self.__worldYaw, self.__worldPitch)
     self.__idealTurretYaw, self.__idealGunPitch = self.__clampToLimits(
         self.__idealTurretYaw, self.__idealGunPitch)
     self.__oscillator.reset()
コード例 #20
0
def StrategicAimingSystem_updateMatrix(self, *args):
    player = BigWorld.player()
    descr = player.vehicleTypeDescriptor

    if not spgAim.enabled:
        if spgAim._lastModeWasSniper:
            if BigWorld._ba_config['spg']['ignoreObstacles']:
                turretYaw, gunPitch = getShotAngles(
                    descr, player.getOwnVehicleStabilisedMatrix(), (0, 0),
                    self._matrix.translation, True)
                currentGunMat = AimingSystems.getPlayerGunMat(
                    turretYaw, gunPitch)
                clientShotStart = currentGunMat.translation
                clientShotVec = currentGunMat.applyVector(
                    Math.Vector3(0, 0, descr.shot['speed']))
                self._matrix.translation, spgAim._shellVelocity, _ = spgAim._getGunMarkerPosition(
                    clientShotStart, clientShotVec, None)

            self._StrategicAimingSystem__planePosition = Math.Vector3(
                self._matrix.translation.x, 0.0, self._matrix.translation.z)

        oldStrategicAimingSystem_updateMatrix(self)
        spgAim._lastModeWasSniper = False

        collPoint = BigWorld.wg_collideSegment(
            BigWorld.player().spaceID,
            self._StrategicAimingSystem__planePosition +
            Math.Vector3(0, 1000.0, 0),
            self._StrategicAimingSystem__planePosition +
            Math.Vector3(0, -1000.0, 0), 3)
        aimPoint = Math.Vector3(self._StrategicAimingSystem__planePosition.x,
                                0.0 if collPoint is None else collPoint[0][1],
                                self._StrategicAimingSystem__planePosition.z)
        spgAim.calcTrajectoryProperties(aimPoint)
        return

    spgAim.onStrategicAimingSystemUpdateMatrix(self, *args)
コード例 #21
0
def StrategicAimingSystem_updateMatrix(self):
    player = BigWorld.player( )
    descr = player.vehicleTypeDescriptor

    if not spgAim.enabled:
        if spgAim._lastModeWasSniper:
            if BigWorld._ba_config['spg']['ignoreObstacles']:
                turretYaw, gunPitch = getShotAngles(descr, player.getOwnVehicleMatrix(), (0, 0), self._matrix.translation, True )
                currentGunMat = AimingSystems.getPlayerGunMat(turretYaw, gunPitch)
                clientShotStart = currentGunMat.translation
                clientShotVec = currentGunMat.applyVector(Math.Vector3(0, 0, descr.shot['speed']))
                self._matrix.translation, spgAim._shellVelocity, _ = spgAim._getGunMarkerPosition( clientShotStart, clientShotVec, None )

            self._StrategicAimingSystem__planePosition = Math.Vector3(self._matrix.translation.x, 0.0, self._matrix.translation.z)

        oldStrategicAimingSystem_updateMatrix( self )
        spgAim._lastModeWasSniper = False

        collPoint = BigWorld.wg_collideSegment(BigWorld.player().spaceID, self._StrategicAimingSystem__planePosition + Math.Vector3(0, 1000.0, 0), self._StrategicAimingSystem__planePosition + Math.Vector3(0, -1000.0, 0), 3)
        aimPoint = Math.Vector3( self._StrategicAimingSystem__planePosition.x, 0.0 if collPoint is None else collPoint[0][1], self._StrategicAimingSystem__planePosition.z )
        spgAim.calcTrajectoryProperties(aimPoint)
        return

    spgAim.onStrategicAimingSystemUpdateMatrix(self)
コード例 #22
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
コード例 #23
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
コード例 #24
0
 def _getCurrentShotInfo(self):
     gunMat = AimingSystems.getPlayerGunMat(self._gunRotator.turretYaw,
                                            self._gunRotator.gunPitch)
     position = gunMat.translation
     velocity = gunMat.applyVector(Math.Vector3(0, 0, self._shotSpeed))
     return (position, velocity, Math.Vector3(0, -self._shotGravity, 0))
コード例 #25
0
def StrategicAimingSystem_updateMatrix(self):
    global gSPGSniperEnabled
    if not gSPGSniperEnabled:
        if self._lastModeWasSniper:
            self._StrategicAimingSystem__planePosition.x = self._matrix.translation.x
            self._StrategicAimingSystem__planePosition.y = 0.0
            self._StrategicAimingSystem__planePosition.z = self._matrix.translation.z

        oldStrategicAimingSystem_updateMatrix(self)
        self._lastModeWasSniper = False
        return

    player = BigWorld.player()
    descr = player.vehicleTypeDescriptor

    bb = BigWorld.player().arena.arenaType.boundingBox
    pos2D = _clampPoint2DInBox2D(
        bb[0] - Math.Vector2(200.0, 200.0), bb[1] + Math.Vector2(200.0, 200.0),
        Math.Vector2(self._StrategicAimingSystem__planePosition.x,
                     self._StrategicAimingSystem__planePosition.z))
    self._StrategicAimingSystem__planePosition.x = pos2D[0]
    self._StrategicAimingSystem__planePosition.z = pos2D[1]

    playerPos = player.getOwnVehiclePosition()

    if not self._lastModeWasSniper:
        collPoint = BigWorld.wg_collideSegment(
            BigWorld.player().spaceID,
            self._StrategicAimingSystem__planePosition +
            Math.Vector3(0, 1000.0, 0),
            self._StrategicAimingSystem__planePosition +
            Math.Vector3(0, -1000.0, 0), 3)
        self._StrategicAimingSystem__planePosition.y = 0.0 if collPoint is None else collPoint[
            0][1]
        self._initialDistance = (Math.Vector3(
            self._StrategicAimingSystem__planePosition.x, playerPos.y,
            self._StrategicAimingSystem__planePosition.z) -
                                 playerPos).length + 0.01

    distance = (
        Math.Vector3(self._StrategicAimingSystem__planePosition.x, playerPos.y,
                     self._StrategicAimingSystem__planePosition.z) -
        playerPos).length + 0.01
    heightFactor = distance / self._initialDistance

    turretYaw, gunPitch = getShotAngles(
        descr, player.getOwnVehicleMatrix(), (0, 0),
        Math.Vector3(
            self._StrategicAimingSystem__planePosition.x,
            playerPos.y * (1.0 - heightFactor) +
            self._StrategicAimingSystem__planePosition.y * heightFactor,
            self._StrategicAimingSystem__planePosition.z), True)
    #gunPitchLimits = calcPitchLimitsFromDesc(turretYaw, descr.gun['pitchLimits'])
    currentGunMat = AimingSystems.getPlayerGunMat(turretYaw, gunPitch)
    clientShotStart = currentGunMat.translation
    clientShotVec = currentGunMat.applyVector(
        Math.Vector3(0, 0, descr.shot['speed']))

    self._matrix.translation, self._shellVelocity = _getGunMarkerPosition(
        clientShotStart, clientShotVec)
    self._lastModeWasSniper = True