Esempio n. 1
0
 def getDesiredShotPoint(self, scanStart, scanDir):
     scanPos, isPointConvenient = self.__testMouseTargetPoint(scanStart, scanDir)
     if isPointConvenient:
         return scanPos
     planePos = self.__aimPlane.intersectRay(scanStart, scanDir)
     if scanStart.distSqrTo(planePos) < scanStart.distSqrTo(scanPos):
         return scanPos
     turretYaw, gunPitch = AimingSystems.getTurretYawGunPitch(self.__vehicleDesc, self.__vehicleMat, planePos, True)
     gunMat = AimingSystems.getGunJointMat(self.__vehicleDesc, self.__getTurretMat(turretYaw), gunPitch)
     aimDir = gunMat.applyVector(Vector3(0.0, 0.0, 1.0))
     return AimingSystems.getDesiredShotPoint(gunMat.translation, aimDir)
 def _getCorrectGunPitch(vehicleMatrix,
                         turretYaw,
                         gunPitch,
                         overrideTurretLocalZ=None):
     turretMat = AimingSystems.getTurretJointMat(
         self._vehicleTypeDescriptor, vehicleMatrix, turretYaw,
         overrideTurretLocalZ)
     gunMat = AimingSystems.getGunJointMat(self._vehicleTypeDescriptor,
                                           turretMat, gunPitch,
                                           overrideTurretLocalZ)
     return gunMat.pitch
Esempio n. 3
0
 def __isTurretTurnRequired(self, viewDir, turretYawOnPoint, targetPoint):
     turretMat = self.__getTurretMat(turretYawOnPoint)
     turretPos = turretMat.translation
     gunPos = AimingSystems.getGunJointMat(self.__vehicleDesc, turretMat, 0.0).translation
     dirFromTurretPos = targetPoint - turretPos
     dirFromSniperPos = targetPoint - gunPos
     viewDir = Math.Vector3(viewDir)
     viewDir.y = 0.0
     viewDir.normalise()
     dirFromSniperPos.y = 0.0
     dirFromTurretPos.y = 0.0
     return viewDir.dot(dirFromSniperPos) < 0.0 or viewDir.dot(dirFromTurretPos) < 0.0
Esempio n. 4
0
 def focusAtPos(self, scanStart, scanDir, yawPitch = None):
     scanPos, isPointConvenient = self.__testMouseTargetPoint(scanStart, scanDir)
     if not isPointConvenient:
         if yawPitch is not None:
             turretYaw, gunPitch = yawPitch
             gunMat = AimingSystems.getGunJointMat(self.__vehicleDesc, self.__getTurretMat(turretYaw), gunPitch)
             planePos = self.__aimPlane.intersectRay(gunMat.translation, gunMat.applyVector(Vector3(0, 0, 1)), False, False)
         else:
             planePos = self.__aimPlane.intersectRay(scanStart, scanDir, False)
         if scanStart.distSqrTo(planePos) < scanStart.distSqrTo(scanPos):
             return scanPos
         return planePos
     self.__aimPlane.init(scanStart, scanPos)
     return scanPos
Esempio n. 5
0
 def focusAtPos(self, scanStart, scanDir, yawPitch = None):
     scanPos, isPointConvenient = self.__testMouseTargetPoint(scanStart, scanDir)
     if not isPointConvenient:
         if yawPitch is not None:
             turretYaw, gunPitch = yawPitch
             gunMat = AimingSystems.getGunJointMat(self.__vehicleDesc, self.__getTurretMat(turretYaw), gunPitch)
             planePos = self.__aimPlane.intersectRay(gunMat.translation, gunMat.applyVector(Vector3(0, 0, 1)), False, False)
         else:
             planePos = self.__aimPlane.intersectRay(scanStart, scanDir, False)
         if scanStart.distSqrTo(planePos) < scanStart.distSqrTo(scanPos):
             return scanPos
         return planePos
     else:
         self.__aimPlane.init(scanStart, scanPos)
         return scanPos
 def __getStabilizedRoll(self, turretYaw = 0.0, gunPitch = 0.0):
     turretMat = AimingSystems.getTurretJointMat(self.__vehicleTypeDescriptor, self.__baseMatrix, turretYaw)
     return AimingSystems.getGunJointMat(self.__vehicleTypeDescriptor, turretMat, gunPitch).roll