def __init__(self, deliveryPoint, dropAltitude, dropTime):
     CallbackDelayer.__init__(self)
     angle = random.random() * 2 * math.pi
     self.__flightYaw = angle
     rotationMatrix = math_utils.createRotationMatrix((angle, 0, 0))
     dropPoint = deliveryPoint + Math.Vector3(0, dropAltitude, 0)
     beginPosition = dropPoint - rotationMatrix.applyVector(
         self.ARRIVAL_TRAJECTORY_INCLINATION)
     flatFlyVelocity = rotationMatrix.applyToAxis(2) * self.FLIGHT_SPEED
     beginPointDesc = CurveControlPoint(
         beginPosition, flatFlyVelocity,
         dropTime - self.FLY_TIME_BEFORE_DROP)
     dropPointDesc = CurveControlPoint(dropPoint, flatFlyVelocity, dropTime)
     dropPlaneConfig = self.__dynamicObjectsCache.getConfig(
         self.__sessionProvider.arenaVisitor.getArenaGuiType(
         )).getDropPlane()
     spaceId = BigWorld.player().spaceID
     compoundName = 'dropPlaneModel'
     modelAssembler = BigWorld.CompoundAssembler(compoundName, spaceId)
     modelAssembler.addRootPart(dropPlaneConfig.model, 'root')
     animationBuilder = AnimationSequence.Loader(
         dropPlaneConfig.flyAnimation, spaceId)
     planeDesc = BomberDesc(modelAssembler, dropPlaneConfig.sound,
                            beginPointDesc, dropPointDesc, animationBuilder)
     self.dropPlane = CompoundBomber(planeDesc)
     endPosition = dropPoint + rotationMatrix.applyVector(
         self.DEPARTURE_TRAJECTORY_INCLINATION)
     self.dropPlane.addControlPoint(endPosition, flatFlyVelocity,
                                    dropTime + self.FLY_TIME_AFTER_DROP)
     delayTime = dropTime - BigWorld.time() - self.FLY_TIME_BEFORE_DROP
     self.delayCallback(delayTime, self.__openCargo)
     self.delayCallback(delayTime + self.UNLOAD_ANIMATION_TIME,
                        self.__closeCargo)
     self.prevTime = BigWorld.time()
 def __cameraUpdate(self):
     deltaTime = self.__updateTime()
     self.__aimOffset = self.__calculateAimOffset(
         self.__aimingSystem.aimPoint)
     self.__handleMovement()
     aimPoint = Vector3(self.__aimingSystem.aimPoint)
     self.__updateTrajectoryDrawer()
     rotation, desiredDistance, collisionDist = self.__calculateIdealState(
         deltaTime)
     self.__interpolateStates(deltaTime,
                              math_utils.createRotationMatrix(rotation),
                              desiredDistance, collisionDist)
     self.__camDist = aimPoint - self.__targetMatrix.translation
     self.__camDist = self.__camDist.length
     self.__cam.source = self.__sourceMatrix
     self.__cam.target.b = self.__targetMatrix
     self.__cam.pivotPosition = Vector3(0, 0, 0)
     if aimPoint.distSqrTo(self.__prevAimPoint) > 0.010000000000000002:
         BigWorld.player().positionControl.moveTo(aimPoint)
         self.__prevAimPoint = aimPoint
     self.__updateOscillator(deltaTime)
     self.__aimingSystem.update(deltaTime)
     if self.__onChangeControlMode is not None and self.__switchers.needToSwitch(
             self.__dxdydz.z, self.__desiredCamDist,
             self._cfg['distRange'][0], self._cfg['distRange'][1],
             self._cfg['transitionDist']):
         self.__onChangeControlMode(*self.__switchers.getSwitchParams())
     if not self.__transitionEnabled and self.__desiredCamDist - TRANSITION_DIST_HYSTERESIS <= self._cfg[
             'transitionDist']:
         self.__transitionEnabled = True
         self.__enableSwitchers(False)
     if not self.__autoUpdatePosition:
         self.__dxdydz = Vector3(0, 0, 0)
     return 0.01
示例#3
0
 def __init__(self, height, yaw):
     super(BaseStrategicAimingSystem, self).__init__()
     self._matrix = math_utils.createRotationMatrix((yaw, 0, 0))
     self._planePosition = Vector3(0, 0, 0)
     self.__camDist = 0.0
     self.__height = height
     self.__heightFromPlane = 0.0
 def applyImpulse(self, position, impulse, reason=ImpulseReason.ME_HIT):
     adjustedImpulse, noiseMagnitude = self.__dynamicCfg.adjustImpulse(impulse, reason)
     impulseFlatDir = Vector3(adjustedImpulse.x, 0, adjustedImpulse.z)
     impulseFlatDir.normalise()
     cameraYawMat = math_utils.createRotationMatrix(Vector3(-self.__cameraYaw, 0.0, 0.0))
     impulseLocal = cameraYawMat.applyVector(impulseFlatDir * (-1 * adjustedImpulse.length))
     self.__positionOscillator.applyImpulse(impulseLocal)
     self.__applyNoiseImpulse(noiseMagnitude)
 def applyImpulse(self, position, impulse, reason=ImpulseReason.ME_HIT):
     adjustedImpulse, noiseMagnitude = self.__dynamicCfg.adjustImpulse(
         impulse, reason)
     yawMat = math_utils.createRotationMatrix(
         (-self.__aimingSystem.yaw, 0, 0))
     impulseLocal = yawMat.applyVector(adjustedImpulse)
     self.__impulseOscillator.applyImpulse(impulseLocal)
     self.__applyNoiseImpulse(noiseMagnitude)
 def __getMovementDirections(self):
     m = math_utils.createRotationMatrix(self.__ypr)
     result = (m.applyVector(Vector3(1, 0, 0)), Vector3(0, 1, 0),
               m.applyVector(Vector3(0, 0, 1)))
     if self._alignerToLand.enabled:
         result[0].y = 0.0
         result[2].y = 0.0
     return result
示例#7
0
def getAimMatrix(x, y, fov=None):
    if fov is None:
        fov = BigWorld.projection().fov
    near = BigWorld.projection().nearPlane
    aspect = getScreenAspectRatio()
    yLength = near * math.tan(fov * 0.5)
    xLength = yLength * aspect
    result = math_utils.createRotationMatrix(Math.Vector3(math.atan2(xLength * x, near), math.atan2(yLength * y, near), 0))
    return result
 def _getTurretYawGunPitch(self, targetPos, compensateGravity=False):
     player = BigWorld.player()
     stabilisedMatrix = Math.Matrix(player.inputHandler.steadyVehicleMatrixCalculator.stabilisedMProv)
     turretYaw, gunPitch = AimingSystems.getTurretYawGunPitch(self._vehicleTypeDescriptor, stabilisedMatrix, targetPos, compensateGravity)
     rotation = math_utils.createRotationMatrix((turretYaw, gunPitch, 0.0))
     rotation.postMultiply(stabilisedMatrix)
     invertSteady = Math.Matrix(self._vehicleMProv)
     invertSteady.invert()
     rotation.postMultiply(invertSteady)
     return (rotation.yaw, rotation.pitch)
示例#9
0
 def rotateGunToDefault(self):
     if self.compoundModel is None:
         return False
     else:
         localGunMatrix = self.__getGunNode().local
         currentGunPitch = localGunMatrix.pitch
         gunPitchAngle = self._getGunPitch()
         if abs(currentGunPitch - gunPitchAngle) < 0.0001:
             return False
         gunPitchMatrix = math_utils.createRotationMatrix((0.0, gunPitchAngle, 0.0))
         self.__setGunMatrix(gunPitchMatrix)
         return True
    def __updateOscillators(self, deltaTime):
        if not SniperCamera.isCameraDynamic():
            self.__impulseOscillator.reset()
            self.__movementOscillator.reset()
            self.__noiseOscillator.reset()
            return (math_utils.createRotationMatrix(Vector3(0, 0, 0)),
                    math_utils.createRotationMatrix(Vector3(0, 0, 0)))
        oscillatorAcceleration = self.__calcCurOscillatorAcceleration(
            deltaTime)
        self.__movementOscillator.externalForce += oscillatorAcceleration
        self.__impulseOscillator.update(deltaTime)
        self.__movementOscillator.update(deltaTime)
        self.__noiseOscillator.update(deltaTime)
        noiseDeviation = Vector3(self.__noiseOscillator.deviation)
        deviation = self.__impulseOscillator.deviation + self.__movementOscillator.deviation + noiseDeviation
        oscVelocity = self.__impulseOscillator.velocity + self.__movementOscillator.velocity + self.__noiseOscillator.velocity
        if abs(deviation.x) < 1e-05 and abs(oscVelocity.x) < 0.0001:
            deviation.x = 0
        if abs(deviation.y) < 1e-05 and abs(oscVelocity.y) < 0.0001:
            deviation.y = 0
        if abs(deviation.z) < 1e-05 and abs(oscVelocity.z) < 0.0001:
            deviation.z = 0
        curZoomIdx = 0
        zooms = self._cfg['zooms']
        for idx in xrange(len(zooms)):
            if self.__zoom == zooms[idx]:
                curZoomIdx = idx
                break

        zoomExposure = self.__zoom * self.__dynamicCfg['zoomExposure'][
            curZoomIdx]
        deviation /= zoomExposure
        impulseDeviation = (self.__impulseOscillator.deviation +
                            noiseDeviation) / zoomExposure
        self.__impulseOscillator.externalForce = Vector3(0)
        self.__movementOscillator.externalForce = Vector3(0)
        self.__noiseOscillator.externalForce = Vector3(0)
        return (math_utils.createRotationMatrix(
            Vector3(deviation.x, deviation.y, deviation.z)),
                math_utils.createRotationMatrix(impulseDeviation))
示例#11
0
def computeTransform(confDict):
    matDict = {
        'preRotate': math_utils.createIdentityMatrix(),
        'postRotate': math_utils.createIdentityMatrix(),
        'vect': math_utils.createIdentityMatrix()
    }
    if any(
            isinstance(confDict[confKey][0], tuple)
            for confKey in matDict.keys()):
        for confKey in matDict.keys():
            if isinstance(confDict[confKey][0], tuple):
                keyframes = []
                for keyframe in confDict[confKey]:
                    timeStamp, value = keyframe
                    if 'vect' in confKey:
                        Mat = math_utils.createTranslationMatrix(value)
                    else:
                        Mat = math_utils.createRotationMatrix(value)
                    keyframes.append((timeStamp, Mat))
                MatAn = Math.MatrixAnimation()
                MatAn.keyframes = keyframes
                MatAn.time = 0.0
                MatAn.loop = True
            elif 'vect' in confKey:
                MatAn = math_utils.createTranslationMatrix(confDict[confKey])
            else:
                MatAn = math_utils.createRotationMatrix(confDict[confKey])
            matDict[confKey] = MatAn

        matProd = math_utils.MatrixProviders.product(matDict['vect'],
                                                     matDict['postRotate'])
        LightMat = math_utils.MatrixProviders.product(matDict['preRotate'],
                                                      matProd)
    else:
        preRotate = math_utils.createRotationMatrix(confDict['preRotate'])
        postRotate = math_utils.createRotationMatrix(confDict['postRotate'])
        LightMat = math_utils.createTranslationMatrix(confDict['vect'])
        LightMat.postMultiply(postRotate)
        LightMat.preMultiply(preRotate)
    return LightMat
 def _getTurretYawGunPitch(self, targetPos, compensateGravity=False):
     vehicleMatrix = Matrix(self._vehicleMProv)
     turretOffset = GunMatCalc.turretOffset(self._vehicleTypeDescriptor)
     gunShotOffset = GunMatCalc.gunShotOffset(self._vehicleTypeDescriptor, self.__gunIndex)
     speed = self._vehicleTypeDescriptor.shot.speed
     gravity = self._vehicleTypeDescriptor.shot.gravity if not compensateGravity else 0.0
     turretYaw, gunPitch = BigWorld.wg_getShotAngles(turretOffset, gunShotOffset, vehicleMatrix, speed, gravity, 0.0, 0.0, targetPos, False)
     rotation = math_utils.createRotationMatrix((turretYaw, gunPitch, 0.0))
     rotation.postMultiply(vehicleMatrix)
     invertSteady = Matrix(self._vehicleMProv)
     invertSteady.invert()
     rotation.postMultiply(invertSteady)
     return (rotation.yaw, rotation.pitch)
    def getDynamicPitchLimits(self, turretYaw=0.0):

        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

        typeDescr = self._vehicleTypeDescriptor
        gunLimits = typeDescr.gun.pitchLimits
        gunAngleMin = gunLimits['minPitch'][0][1]
        gunAngleMax = gunLimits['maxPitch'][0][1]
        hullAngleMin = typeDescr.type.hullAimingParams['pitch']['wheelsCorrectionAngles']['pitchMin']
        hullAngleMax = typeDescr.type.hullAimingParams['pitch']['wheelsCorrectionAngles']['pitchMax']
        isBackTurretSector = turretYaw < math.pi * -0.5 or turretYaw > math.pi * 0.5
        if isBackTurretSector:
            hullAngleMin, hullAngleMax = hullAngleMax, hullAngleMin
        hullMatrixAngleMin = math_utils.createRotationMatrix((0, hullAngleMin, 0))
        hullMatrixAngleMax = math_utils.createRotationMatrix((0, hullAngleMax, 0))
        maxPitch = _getCorrectGunPitch(hullMatrixAngleMax, turretYaw, gunAngleMax)
        minPitch = _getCorrectGunPitch(hullMatrixAngleMin, turretYaw, gunAngleMin)
        return {'absolute': (minPitch, maxPitch),
         'maxPitch': ((0.0, maxPitch), (math.pi * 2.0, maxPitch)),
         'minPitch': ((0.0, minPitch), (math.pi * 2.0, minPitch))}
 def _update(self):
     worldMatrix = Matrix(self._cam.invViewMatrix)
     desiredPosition = self.__basisMProv.checkTurretDetachment(
         worldMatrix.translation)
     if desiredPosition is not None:
         self.__position = desiredPosition
     prevPos = Math.Vector3(self.__position)
     delta = self.__calcCurrentDeltaAdjusted()
     self.__updateSenses(delta)
     if self._targetRadiusSensor:
         self.__rotationRadius += self._targetRadiusSensor.currentVelocity * delta
     if self.__isVerticalVelocitySeparated:
         self._verticalMovementSensor.update(delta)
     else:
         self._verticalMovementSensor.currentVelocity = self._movementSensor.currentVelocity.y
         self._verticalMovementSensor.sensitivity = self._movementSensor.sensitivity
     if self._inertiaEnabled:
         self.__inertialMovement(delta)
     else:
         self.__simpleMovement(delta)
     self.__ypr += self.__yprVelocity * delta
     self.__position += self.__velocity * delta
     if self.__rotateAroundPointEnabled:
         self.__position = self.__getAlignedToPointPosition(
             math_utils.createRotationMatrix(self.__ypr))
     if self._alignerToLand.enabled and not self.__basisMProv.isBound:
         if abs(self.__velocity.y) > 0.1:
             self._alignerToLand.enable(self.__position,
                                        self._alignerToLand.ignoreTerrain)
         self.__position = self._alignerToLand.getAlignedPosition(
             self.__position)
     lookAtPosition = self.__basisMProv.lookAtPosition
     if lookAtPosition is not None:
         self.__ypr = self.__getLookAtYPR(lookAtPosition)
     if BigWorld.camera(
     ) == self.__cameraTransition and self.__cameraTransition.isInTransition(
     ):
         self.__ypr = self.__clampPR(self.__ypr)
     else:
         self.__ypr = self.__clampYPR(self.__ypr)
     self.__position = self._checkSpaceBounds(prevPos, self.__position)
     self._cam.invViewProvider.a = math_utils.createRTMatrix(
         self.__ypr, self.__position)
     self._cam.invViewProvider.b = self.__basisMProv.matrix
     BigWorld.projection().fov = self.__calcFov()
     self.__resetSenses()
     return 0.0
示例#15
0
 def enable(self,
            targetPos,
            saveDist,
            switchToPos=None,
            switchToPlace=None):
     BigWorld.wg_trajectory_drawer().setStrategicMode(False)
     self.__prevTime = 0.0
     if switchToPlace == SwitchToPlaces.TO_TRANSITION_DIST:
         self.__camDist = math_utils.clamp(self._cfg['distRange'][0],
                                           self._cfg['distRange'][1],
                                           self._cfg['transitionDist'])
     elif switchToPlace == SwitchToPlaces.TO_RELATIVE_POS and switchToPos is not None:
         minDist, maxDist = self._cfg['distRange']
         self.__camDist = (maxDist - minDist) * switchToPos + minDist
     elif switchToPlace == SwitchToPlaces.TO_NEAR_POS and switchToPos is not None:
         minDist, maxDist = self._cfg['distRange']
         self.__camDist = math_utils.clamp(minDist, maxDist, switchToPos)
     elif self.settingsCore.getSetting(SPGAim.AUTO_CHANGE_AIM_MODE):
         self.__camDist = math_utils.clamp(self._cfg['distRange'][0],
                                           self._cfg['transitionDist'],
                                           self.__camDist)
     self.__desiredCamDist = self.__camDist
     self.__scrollSmoother.start(self.__desiredCamDist)
     self.__enableSwitchers()
     self.__aimingSystem.enable(targetPos)
     self.__positionHysteresis.update(Vector3(0.0, 0.0, 0.0))
     self.__timeHysteresis.update(BigWorld.timeExact())
     camTarget = MatrixProduct()
     self.__rotation = max(self.__aimingSystem.direction.pitch,
                           self._cfg['minimalPitch'])
     cameraDirection = self.__getCameraDirection()
     self.__targetMatrix.translation = self.aimingSystem.aimPoint - cameraDirection.scale(
         self.__camDist)
     self.__cam.target = camTarget
     self.__cam.target.b = self.__targetMatrix
     self.__sourceMatrix = math_utils.createRotationMatrix(
         (cameraDirection.yaw, -cameraDirection.pitch, 0.0))
     self.__cam.source = self.__sourceMatrix
     self.__cam.forceUpdate()
     BigWorld.camera(self.__cam)
     BigWorld.player().positionControl.moveTo(self.__aimingSystem.hitPoint)
     BigWorld.player().positionControl.followCamera(False)
     self.__cameraUpdate()
     self.delayCallback(0.01, self.__cameraUpdate)
     self.__needReset = 1
     return
 def __cameraUpdate(self):
     deltaTime = self.__updateTime()
     self.__handleMovement()
     aimPoint = Vector3(self.__aimingSystem.aimPoint)
     self.__aimOffset = self.__calculateAimOffset(aimPoint)
     self.__updateTrajectoryDrawer()
     translation, rotation = self.__calculateIdealState(deltaTime)
     self.__interpolateStates(deltaTime, translation,
                              math_utils.createRotationMatrix(rotation))
     self.__camDist = aimPoint - self.__targetMatrix.translation
     self.__camDist = self.__camDist.length
     self.__cam.source = self.__sourceMatrix
     self.__cam.target.b = self.__targetMatrix
     self.__cam.pivotPosition = Vector3(0, 0, 0)
     if aimPoint.distSqrTo(self.__prevAimPoint) > 0.010000000000000002:
         BigWorld.player().positionControl.moveTo(aimPoint)
         self.__prevAimPoint = aimPoint
     self.__updateOscillator(deltaTime)
     self.__aimingSystem.update(deltaTime)
     if not self.__autoUpdatePosition:
         self.__dxdydz = Vector3(0, 0, 0)
 def __calcCurOscillatorAcceleration(self, deltaTime):
     vehicle = BigWorld.player().getVehicleAttached()
     if vehicle is None:
         return Vector3(0, 0, 0)
     else:
         vehFilter = vehicle.filter
         curVelocity = getattr(vehFilter, 'velocity', Vector3(0.0))
         relativeSpeed = curVelocity.length / vehicle.typeDescriptor.physics[
             'speedLimits'][0]
         if relativeSpeed >= ArcadeCamera._MIN_REL_SPEED_ACC_SMOOTHING:
             self.__accelerationSmoother.maxAllowedAcceleration = self.__dynamicCfg[
                 'accelerationThreshold']
         else:
             self.__accelerationSmoother.maxAllowedAcceleration = self.__dynamicCfg[
                 'accelerationMax']
         acceleration = self.__accelerationSmoother.update(
             vehicle, deltaTime)
         yawMat = math_utils.createRotationMatrix(
             (-self.__aimingSystem.yaw, 0, 0))
         acceleration = yawMat.applyVector(-acceleration)
         oscillatorAcceleration = Vector3(acceleration.x, acceleration.y,
                                          acceleration.z)
         return oscillatorAcceleration * self.__dynamicCfg[
             'accelerationSensitivity']
    def __assembleModel(self):
        from vehicle_systems import model_assembler
        resources = self.__resources
        self.__vEntity.model = resources[self.__vDesc.name]
        if not self.__isVehicleDestroyed:
            self.__fashions = VehiclePartsTuple(BigWorld.WGVehicleFashion(),
                                                BigWorld.WGBaseFashion(),
                                                BigWorld.WGBaseFashion(),
                                                BigWorld.WGBaseFashion())
            model_assembler.setupTracksFashion(self.__vDesc,
                                               self.__fashions.chassis)
            self.__vEntity.model.setupFashions(self.__fashions)
            model_assembler.assembleCollisionObstaclesCollector(
                self, None, self.__vDesc,
                BigWorld.player().spaceID)
            model_assembler.assembleTessellationCollisionSensor(self, None)
            wheelsScroll = None
            wheelsSteering = None
            if self.__vDesc.chassis.generalWheelsAnimatorConfig is not None:
                scrollableWheelsCount = self.__vDesc.chassis.generalWheelsAnimatorConfig.getWheelsCount(
                )
                wheelsScroll = [(lambda: 0.0)
                                for _ in xrange(scrollableWheelsCount)]
                steerableWheelsCount = self.__vDesc.chassis.generalWheelsAnimatorConfig.getSteerableWheelsCount(
                )
                wheelsSteering = [(lambda: 0.0)
                                  for _ in xrange(steerableWheelsCount)]
            chassisFashion = self.__fashions.chassis
            splineTracksImpl = model_assembler.setupSplineTracks(
                chassisFashion, self.__vDesc, self.__vEntity.model,
                self.__resources, self.__outfit.modelsSet)
            self.wheelsAnimator = model_assembler.createWheelsAnimator(
                self, ColliderTypes.VEHICLE_COLLIDER, self.__vDesc, lambda: 0,
                wheelsScroll, wheelsSteering, splineTracksImpl)
            self.trackNodesAnimator = model_assembler.createTrackNodesAnimator(
                self, self.__vDesc)
            model_assembler.assembleTracks(self.__resources, self.__vDesc,
                                           self, splineTracksImpl, True)
            dirtEnabled = BigWorld.WG_dirtEnabled(
            ) and 'HD' in self.__vDesc.type.tags
            if dirtEnabled:
                dirtHandlers = [
                    BigWorld.PyDirtHandler(
                        True,
                        self.__vEntity.model.node(
                            TankPartNames.CHASSIS).position.y),
                    BigWorld.PyDirtHandler(
                        False,
                        self.__vEntity.model.node(
                            TankPartNames.HULL).position.y),
                    BigWorld.PyDirtHandler(
                        False,
                        self.__vEntity.model.node(
                            TankPartNames.TURRET).position.y),
                    BigWorld.PyDirtHandler(
                        False,
                        self.__vEntity.model.node(
                            TankPartNames.GUN).position.y)
                ]
                modelHeight, _ = self.computeVehicleHeight()
                self.dirtComponent = self.createComponent(
                    Vehicular.DirtComponent, dirtHandlers, modelHeight)
                for fashionIdx, _ in enumerate(TankPartNames.ALL):
                    self.__fashions[fashionIdx].addMaterialHandler(
                        dirtHandlers[fashionIdx])

                self.dirtComponent.setBase()
            outfitData = camouflages.getOutfitData(
                self, self.__outfit, self.__vDesc,
                self.__vState != 'undamaged')
            self.c11nComponent = self.createComponent(
                Vehicular.C11nEditComponent, self.__fashions,
                self.compoundModel, outfitData)
            self.__updateDecals(self.__outfit)
            self.__updateSequences(self.__outfit)
        else:
            self.__fashions = VehiclePartsTuple(BigWorld.WGVehicleFashion(),
                                                BigWorld.WGBaseFashion(),
                                                BigWorld.WGBaseFashion(),
                                                BigWorld.WGBaseFashion())
            self.__vEntity.model.setupFashions(self.__fashions)
            self.wheelsAnimator = None
            self.trackNodesAnimator = None
            self.dirtComponent = None
            self.flagComponent = None
        self.__staticTurretYaw = self.__vDesc.gun.staticTurretYaw
        self.__staticGunPitch = self.__vDesc.gun.staticPitch
        if not ('AT-SPG' in self.__vDesc.type.tags
                or 'SPG' in self.__vDesc.type.tags):
            if self.__staticTurretYaw is None:
                self.__staticTurretYaw = self._getTurretYaw()
                turretYawLimits = self.__vDesc.gun.turretYawLimits
                if turretYawLimits is not None:
                    self.__staticTurretYaw = math_utils.clamp(
                        turretYawLimits[0], turretYawLimits[1],
                        self.__staticTurretYaw)
            if self.__staticGunPitch is None:
                self.__staticGunPitch = self._getGunPitch()
                gunPitchLimits = self.__vDesc.gun.pitchLimits['absolute']
                self.__staticGunPitch = math_utils.clamp(
                    gunPitchLimits[0], gunPitchLimits[1],
                    self.__staticGunPitch)
        else:
            if self.__staticTurretYaw is None:
                self.__staticTurretYaw = 0.0
            if self.__staticGunPitch is None:
                self.__staticGunPitch = 0.0
        turretYawMatrix = math_utils.createRotationMatrix(
            (self.__staticTurretYaw, 0.0, 0.0))
        self.__vEntity.model.node(TankPartNames.TURRET, turretYawMatrix)
        gunPitchMatrix = math_utils.createRotationMatrix(
            (0.0, self.__staticGunPitch, 0.0))
        self.__setGunMatrix(gunPitchMatrix)
        return
示例#19
0
 def __init__(self, yaw, dropPoint, endPoint, descendTime):
     self.__matrix = math_utils.createRotationMatrix((yaw, 0, 0))
     self.easing = Easing.linearEasing(dropPoint, endPoint, descendTime)
     self.prevTime = BigWorld.time()
     self.tick()
 def __worldYawPitchToTurret(self, worldYaw, worldPitch):
     worldToTurret = Math.Matrix(self._vehicleMProv)
     worldToTurret.invert()
     worldToTurret.preMultiply(
         math_utils.createRotationMatrix((worldYaw, worldPitch, 0.0)))
     return (worldToTurret.yaw, worldToTurret.pitch)
示例#21
0
 def __updateCameraYaw(self):
     altModeEnabled = self.settingsCore.getSetting(settings_constants.SPGAim.SPG_STRATEGIC_CAM_MODE) == 1
     pitch = -math.pi * 0.499 if not altModeEnabled else math.radians(-88.0)
     self.__cameraYaw = round(self.aimingSystem.getCamYaw(), _CAM_YAW_ROUND)
     srcMat = math_utils.createRotationMatrix((self.__cameraYaw, pitch, 0.0))
     self.__cam.source = srcMat
 def __init__(self):
     BigWorld.UserDataObject.__init__(self)
     launchDir = math_utils.createRotationMatrix(
         (self.__dict__['yaw'], self.__dict__['pitch'], 0)).applyToAxis(2)
     launchDir.normalise()
     self.__launchVelocity = launchDir * self.speed
 def __updateTurretMatrix(self, yaw, time):
     m = math_utils.createRotationMatrix((yaw, 0.0, 0.0))
     self.__turretMatrixAnimator.update(m, time)
 def __cameraUpdate(self):
     if not (self.__autoUpdateDxDyDz.x == 0.0 and self.__autoUpdateDxDyDz.y
             == 0.0 and self.__autoUpdateDxDyDz.z == 0.0):
         self.__update(self.__autoUpdateDxDyDz.x, self.__autoUpdateDxDyDz.y,
                       self.__autoUpdateDxDyDz.z)
     inertDt = deltaTime = self.measureDeltaTime()
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying:
         repSpeed = replayCtrl.playbackSpeed
         if repSpeed == 0.0:
             inertDt = 0.01
             deltaTime = 0.0
         else:
             inertDt = deltaTime = deltaTime / repSpeed
     self.__aimingSystem.update(deltaTime)
     virginShotPoint = self.__aimingSystem.getThirdPersonShotPoint()
     delta = self.__inputInertia.positionDelta
     sign = delta.dot(Vector3(0, 0, 1))
     self.__inputInertia.update(inertDt)
     delta = (delta - self.__inputInertia.positionDelta).length
     if delta != 0.0:
         self.__cam.setScrollDelta(math.copysign(delta, sign))
     FovExtended.instance().setFovByMultiplier(
         self.__inputInertia.fovZoomMultiplier)
     unshakenPos = self.__inputInertia.calcWorldPos(
         self.__aimingSystem.matrix)
     vehMatrix = Math.Matrix(self.__aimingSystem.vehicleMProv)
     vehiclePos = vehMatrix.translation
     fromVehicleToUnshakedPos = unshakenPos - vehiclePos
     deviationBasis = math_utils.createRotationMatrix(
         Vector3(self.__aimingSystem.yaw, 0, 0))
     impulseDeviation, movementDeviation, oscillationsZoomMultiplier = self.__updateOscillators(
         deltaTime)
     relCamPosMatrix = math_utils.createTranslationMatrix(impulseDeviation +
                                                          movementDeviation)
     relCamPosMatrix.postMultiply(deviationBasis)
     relCamPosMatrix.translation += fromVehicleToUnshakedPos
     upRotMat = math_utils.createRotationMatrix(
         Vector3(
             0, 0, -impulseDeviation.x *
             self.__dynamicCfg['sideImpulseToRollRatio'] -
             self.__noiseOscillator.deviation.z))
     upRotMat.postMultiply(relCamPosMatrix)
     self.__cam.up = upRotMat.applyVector(Vector3(0, 1, 0))
     relTranslation = relCamPosMatrix.translation
     shotPoint = self.__calcFocalPoint(virginShotPoint, deltaTime)
     vehToShotPoint = shotPoint - vehiclePos
     self.__setCameraAimPoint(vehToShotPoint)
     self.__setCameraPosition(relTranslation)
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
         aimOffset = replayCtrl.getAimClipPosition()
         if not BigWorld.player().isForcedGuiControlMode() and GUI.mcursor(
         ).inFocus:
             GUI.mcursor().position = aimOffset
     else:
         aimOffset = self.__calcAimOffset(oscillationsZoomMultiplier)
         if replayCtrl.isRecording:
             replayCtrl.setAimClipPosition(aimOffset)
     self.__cam.aimPointClipCoords = aimOffset
     self.__aimOffset = aimOffset
     if self.__shiftKeySensor is not None:
         self.__shiftKeySensor.update(1.0)
         if self.__shiftKeySensor.currentVelocity.lengthSquared > 0.0:
             self.shiftCamPos(self.__shiftKeySensor.currentVelocity)
             self.__shiftKeySensor.currentVelocity = Math.Vector3()
     return 0.0
 def setYaw(self, yaw):
     self._matrix = math_utils.createRotationMatrix((yaw, 0, 0))
     self._updateMatrix()