Esempio n. 1
0
def adjustFOV(diff):
    newFov = BigWorld.projection().fov + diff
    newFov = min(max(newFov, FOV_MIN), FOV_MAX)
    BigWorld.projection().rampFov(newFov, 0.1)
    BigWorld.player = lambda : g_fakeAvatar
    if WWISE.enabled:
        WWISE.WG_loadBanks('', False)
 def __calcPitchAngle(self, distanceFromFocus, dir):
     fov = BigWorld.projection().fov
     near = BigWorld.projection().nearPlane
     yLength = near * math.tan(fov * 0.5)
     alpha = -self.__aimMatrix.pitch
     a = distanceFromFocus
     b = dir.length
     A = 2.0 * a * math.cos(alpha)
     B = a * a - b * b
     D = A * A - 4.0 * B
     if D > 0.0:
         c1 = (A + math.sqrt(D)) * 0.5
         c2 = (A - math.sqrt(D)) * 0.5
         c = c1 if c1 > c2 else c2
         cosValue = (a * a + b * b - c * c) / (2.0 * a * b) if a * b != 0.0 else 2.0
         if cosValue < -1.0 or cosValue > 1.0:
             LOG_WARNING(
                 "Invalid arg for acos: %f; distanceFromFocus: %f, dir: %s" % (cosValue, distanceFromFocus, dir)
             )
             return -dir.pitch
         beta = math.acos(cosValue)
         eta = math.pi - beta
         return -dir.pitch - eta
     else:
         return -dir.pitch
Esempio n. 3
0
def getAimMatrix(x, y):
    fov = BigWorld.projection().fov
    near = BigWorld.projection().nearPlane
    aspect = getScreenAspectRatio()
    yLength = near * math.tan(fov * 0.5)
    xLength = yLength * aspect
    result = mathUtils.createRotationMatrix(Math.Vector3(math.atan2(xLength * x, near), math.atan2(yLength * y, near), 0))
    return result
Esempio n. 4
0
    def onStrategicCameraDisable(self, camera):
        BigWorld.projection().nearPlane = self._prevNearPlane
        BigWorld.projection().farPlane = self._prevFarPlane

        if self.enabled:
            camera._StrategicCamera__aimingSystem._StrategicAimingSystem__planePosition.x = camera._StrategicCamera__aimingSystem._matrix.translation.x
            camera._StrategicCamera__aimingSystem._StrategicAimingSystem__planePosition.y = 0.0
            camera._StrategicCamera__aimingSystem._StrategicAimingSystem__planePosition.z = camera._StrategicCamera__aimingSystem._matrix.translation.z
            self._lastModeWasSniper = False
            self.enabled = False
Esempio n. 5
0
 def setFovByMultiplier(self, multiplier, rampTime = None):
     self.__multiplier = multiplier
     if not self.__enabled:
         return
     defaultFov = self.actualDefaultVerticalFov
     finalFov = FovExtended.clampFov(defaultFov * self.__multiplier)
     if rampTime is None:
         BigWorld.projection().fov = finalFov
     else:
         BigWorld.projection().rampFov(finalFov, rampTime)
Esempio n. 6
0
def getWorldRayAndPoint(x, y):
    fov = BigWorld.projection().fov
    near = BigWorld.projection().nearPlane
    aspect = getScreenAspectRatio()
    yLength = near * math.tan(fov * 0.5)
    xLength = yLength * aspect
    point = Math.Vector3(xLength * x, yLength * y, near)
    inv = Math.Matrix(BigWorld.camera().invViewMatrix)
    ray = inv.applyVector(point)
    wPoint = inv.applyPoint(point)
    return (ray, wPoint)
Esempio n. 7
0
 def __update(self):
     prevPos = Math.Vector3(self.__position)
     delta = self.__calcCurrentDelta()
     self.__movementSensor.update(delta)
     self.__rotationSensor.update(delta)
     self.__zoomSensor.update(delta)
     self.__targetRadiusSensor.update(delta)
     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.__alignerToLand.enabled and abs(self.__velocity.y) > 0.1:
         self.__alignerToLand.enable(self.__position)
     self.__position = self.__alignerToLand.getAlignedPosition(self.__position)
     if self.__boundVehicleMProv is not None:
         self.__ypr = self.__getLookAtYPR(Matrix(self.__boundVehicleMProv).translation)
     self.__ypr[0] = math.fmod(self.__ypr[0], 2 * math.pi)
     self.__ypr[1] = max(-0.9 * math.pi / 2, min(0.9 * math.pi / 2, self.__ypr[1]))
     self.__ypr[2] = math.fmod(self.__ypr[2], 2 * math.pi)
     camMat = Math.Matrix()
     camMat.setRotateYPR(self.__ypr)
     if self.__rotateAroundPointEnabled:
         self.__position = self.__getAlignedToPointPosition(camMat)
     moveDir = self.__position - prevPos
     moveDir.normalise()
     collisionPointWithBorders = BigWorld.player().arena.collideWithSpaceBB(prevPos - moveDir, self.__position + moveDir)
     if collisionPointWithBorders is not None:
         self.__position = collisionPointWithBorders
     camMat.translation = self.__position
     camMat.invert()
     self.__cam.set(camMat)
     fov = BigWorld.projection().fov + self.__zoomSensor.currentVelocity
     if fov <= 0.1:
         fov = 0.1
     if fov >= math.pi - 0.1:
         fov = math.pi - 0.1
     BigWorld.projection().fov = fov
     self.__movementSensor.currentVelocity = Math.Vector3()
     self.__verticalMovementSensor.currentVelocity = 0.0
     self.__rotationSensor.currentVelocity = Math.Vector3()
     self.__zoomSensor.currentVelocity = 0.0
     self.__targetRadiusSensor.currentVelocity = 0.0
     return 0.0
def StrategicCamera__cameraUpdate( self, *args ):
    replayCtrl = BattleReplay.g_replayCtrl

    if not spgAim.enabled:
        srcMat = mathUtils.createRotationMatrix((0, -math.pi * 0.499, 0))
        self._StrategicCamera__cam.source = srcMat
        self._StrategicCamera__cam.target.b = self._StrategicCamera__aimingSystem.matrix

        BigWorld.projection().nearPlane = spgAim._prevNearPlane
        BigWorld.projection().farPlane = spgAim._prevFarPlane
        BigWorld.projection().fov = StrategicCamera.StrategicCamera.ABSOLUTE_VERTICAL_FOV
        return oldStrategicCamera__cameraUpdate( self )

    return spgAim.onStrategicCameraUpdate(self, *args)
Esempio n. 9
0
 def __init__(self, configDataSec):
     CallbackDelayer.__init__(self)
     TimeDeltaMeter.__init__(self)
     self.__cam = BigWorld.FreeCamera()
     self.__cam.invViewProvider = Math.MatrixProduct()
     self.__ypr = Math.Vector3()
     self.__position = Math.Vector3()
     self.__defaultFov = BigWorld.projection().fov
     self.__velocity = Math.Vector3()
     self.__isVerticalVelocitySeparated = False
     self.__yprVelocity = Math.Vector3()
     self.__zoomVelocity = 0.0
     self.__inertiaEnabled = False
     self.__movementInertia = None
     self.__rotationInertia = None
     self.__movementSensor = None
     self.__verticalMovementSensor = None
     self.__rotationSensor = None
     self.__zoomSensor = None
     self.__targetRadiusSensor = None
     self.__mouseSensitivity = 0.0
     self.__scrollSensitivity = 0.0
     self.__rotateAroundPointEnabled = False
     self.__rotationRadius = 40.0
     self.__alignerToLand = _AlignerToLand()
     self.__predefinedVelocities = {}
     self.__predefinedVerticalVelocities = {}
     self.__keySwitches = {}
     self.__readCfg(configDataSec)
     self.__aim = None
     self.__basisMProv = _VehicleBounder()
     self.__entityPicker = _VehiclePicker()
     return
Esempio n. 10
0
def launch(spaceName):
    global g_enablePostProcessing
    global g_offlineModeEnabled
    print 'Entering offline space', spaceName
    BigWorld.clearAllSpaces()
    BigWorld.worldDrawEnabled(False)
    _displayGUI(spaceName)
    spaceID = BigWorld.createSpace()
    BigWorld.addSpaceGeometryMapping(spaceID, None, spaceName)
    _loadCameraTransforms()
    camera = BigWorld.FreeCamera()
    camera.spaceID = spaceID
    BigWorld.camera(camera)
    _setCameraTransform(g_curCameraTransform)
    BigWorld.camera().fixed = True
    BigWorld.projection().fov = math.radians(75.0)
    BigWorld.setWatcher('Client Settings/Strafe Rate', 175.0)
    BigWorld.setWatcher('Client Settings/Camera Mass', 5.0)
    BigWorld.setCursor(GUI.mcursor())
    GUI.mcursor().visible = True
    GUI.mcursor().clipped = False
    g_offlineModeEnabled = True
    BigWorld.callback(1.0, _offlineLoadCheck)
    g_postProcessing.init()
    _enablePostProcessing(g_enablePostProcessing, 'arcade')
    return
Esempio n. 11
0
 def disable(self):
     self.stopCallback(self.__update)
     BigWorld.projection().fov = self.__defaultFov
     BigWorld.camera(None)
     self.__alignerToLand.disable()
     BigWorld.player().positionControl.followCamera(False)
     return
 def __onDistanceChanged(self, distance):
     farPlane = 1.0 / BigWorld.projection().farPlane
     offset = 2.5
     zNear = (distance - offset) * farPlane
     zFar = (distance + offset) * farPlane
     DepthOfFieldUnit.zNear.set(zNear, 0.1, True)
     DepthOfFieldUnit.zFar.set(zFar, 0.1, True)
Esempio n. 13
0
    def handleKeyEvent(self, key, isDown):
        if key is None:
            return False
        else:
            if isDown:
                if self.__keySwitches["keySwitchInertia"] == key:
                    self.__inertiaEnabled = not self.__inertiaEnabled
                    return True
                if self.__keySwitches["keySwitchRotateAroundPoint"] == key:
                    self.__rotateAroundPointEnabled = not self.__rotateAroundPointEnabled
                    return True
                if self.__keySwitches["keySwitchLandCamera"] == key:
                    if self.__alignerToLand.enabled or self.__basisMProv.isBound:
                        self.__alignerToLand.disable()
                    else:
                        self.__alignerToLand.enable(
                            self.__position, BigWorld.isKeyDown(Keys.KEY_LALT) or BigWorld.isKeyDown(Keys.KEY_RALT)
                        )
                    return True
                if self.__keySwitches["keySetDefaultFov"] == key:
                    BigWorld.projection().fov = self.__defaultFov
                    return True
                if self.__keySwitches["keySetDefaultRoll"] == key:
                    self.__ypr.z = 0.0
                    return True
                if self.__keySwitches["keyRevertVerticalVelocity"] == key:
                    self.__isVerticalVelocitySeparated = False
                    return True
                if self.__keySwitches["keyBindToVehicle"] == key:
                    self.__processBindToVehicleKey()
                    return True
                if BigWorld.isKeyDown(Keys.KEY_LSHIFT) or BigWorld.isKeyDown(Keys.KEY_RSHIFT):
                    if (
                        self.__verticalMovementSensor.handleKeyEvent(key, isDown)
                        and key not in self.__verticalMovementSensor.keyMappings
                    ):
                        self.__isVerticalVelocitySeparated = True
                        return True
                    for velocityKey, velocity in self.__predefinedVerticalVelocities.iteritems():
                        if velocityKey == key:
                            self.__verticalMovementSensor.sensitivity = velocity
                            self.__isVerticalVelocitySeparated = True
                            return True

                for velocityKey, velocity in self.__predefinedVelocities.iteritems():
                    if velocityKey == key:
                        self.__movementSensor.sensitivity = velocity
                        return True

            if key in self.__verticalMovementSensor.keyMappings:
                self.__verticalMovementSensor.handleKeyEvent(key, isDown)
            return (
                self.__movementSensor.handleKeyEvent(key, isDown)
                or self.__rotationSensor.handleKeyEvent(key, isDown)
                or self.__zoomSensor.handleKeyEvent(key, isDown)
                or self.__targetRadiusSensor.handleKeyEvent(key, isDown)
            )
Esempio n. 14
0
 def disable(self):
     self.stopCallback(self.__update)
     BigWorld.projection().fov = self.__defaultFov
     BigWorld.camera(None)
     self.__alignerToLand.disable()
     if isPlayerAvatar():
         BigWorld.player().positionControl.followCamera(False)
     self.__isModeOverride = False
     return
Esempio n. 15
0
    def enable(self, doEnable):
        if self.__isEnabled == doEnable:
            return
        from cameras import FovExtended
        if not doEnable:
            self.__isEnabled = False
            BigWorld.camera(self.__savedCamera)
            BigWorld.wg_enableSuperShot(False, False)
            for k, v in self.__savedWatchers.iteritems():
                BigWorld.setWatcher(k, v)

            FovExtended.instance().enabled = True
            LOG_DEBUG('Vertical screenshot camera is disabled')
            return
        self.__isEnabled = True
        self.__savedCamera = BigWorld.camera()
        FovExtended.instance().enabled = False
        arenaBB = BigWorld.wg_getSpaceBounds()
        centerXZ = Math.Vector2(0.5 * (arenaBB[0] + arenaBB[2]), 0.5 * (arenaBB[1] + arenaBB[3]))
        halfSizesXZ = Math.Vector2(0.5 * (arenaBB[2] - arenaBB[0]), 0.5 * (arenaBB[3] - arenaBB[1]))
        camFov = math.radians(15.0)
        camPos = Math.Vector3(centerXZ.x, 0, centerXZ.z)
        aspectRatio = 1.0
        if not BigWorld.isVideoWindowed():
            aspectRatio = BigWorld.getFullScreenAspectRatio()
        else:
            aspectRatio = BigWorld.screenWidth() / BigWorld.screenHeight()
        camPos.y = max(halfSizesXZ.x / math.sin(0.5 * camFov * aspectRatio), halfSizesXZ.y / math.sin(0.5 * camFov))
        camMatr = Math.Matrix()
        camMatr.setRotateYPR(Math.Vector3(0.0, math.pi * 0.5, 0.0))
        camMatr.translation = camPos
        camMatr.invert()
        self.__cam = BigWorld.FreeCamera()
        self.__cam.set(camMatr)
        BigWorld.camera(self.__cam)
        BigWorld.wg_enableSuperShot(True, False)
        self.__savedWatchers = {}
        for name in self.__watcherNames:
            try:
                self.__savedWatchers[name] = BigWorld.getWatcher(name)
                if name.startswith('Visibility'):
                    BigWorld.setWatcher(name, False)
            except TypeError:
                LOG_WARNING('Failed to get/set watcher', name)

        BigWorld.setWatcher('Client Settings/std fog/enabled', False)
        BigWorld.projection().fov = camFov
        BigWorld.setWatcher('Render/Fov', camFov)
        BigWorld.setWatcher('Render/Near Plane', max(0.1, camPos.y - 1000.0))
        BigWorld.setWatcher('Render/Far Plane', camPos.y + 1000.0)
        BigWorld.setWatcher('Render/Objects Far Plane/Enabled', False)
        BigWorld.setWatcher('Render/Shadows/qualityPreset', 7)
        BigWorld.setWatcher('Client Settings/Script tick', False)
        LOG_DEBUG('Vertical screenshot camera is enabled')
Esempio n. 16
0
def SniperAimingSystem_enable(self, targetPos, playerGunMatFunction=AimingSystems.getPlayerGunMat):
    global dataHor, dataVert, scaleHor, scaleVert, yHor, yVert, cameraMode
    verticalFov = BigWorld.projection().fov * 2
    horizontalFov = FovExtended.calcVerticalFov(verticalFov)
    yHor = 0
    yVert = 0
    scaleHor = screenWidth / horizontalFov if horizontalFov else screenWidth
    scaleVert = screenHeight / verticalFov if verticalFov else screenHeight
    dataHor, dataVert = coordinate(yaw, pitch)
    cameraMode = 'sn'
    as_event('ON_ANGLES_AIMING')
Esempio n. 17
0
    def handleKeyEvent(self, key, isDown):
        if key is None:
            return False
        else:
            if isDown:
                if self.__keySwitches['keySwitchInertia'] == key:
                    self.__inertiaEnabled = not self.__inertiaEnabled
                    return True
                if self.__keySwitches['keySwitchRotateAroundPoint'] == key:
                    self.__rotateAroundPointEnabled = not self.__rotateAroundPointEnabled
                    self.__boundVehicleMProv = None
                    return True
                if self.__keySwitches['keySwitchLandCamera'] == key:
                    if self.__alignerToLand.enabled:
                        self.__alignerToLand.disable()
                    else:
                        self.__alignerToLand.enable(self.__position)
                    return True
                if self.__keySwitches['keySetDefaultFov'] == key:
                    BigWorld.projection().fov = self.__defaultFov
                    return True
                if self.__keySwitches['keySetDefaultRoll'] == key:
                    self.__ypr.z = 0.0
                    return True
                if self.__keySwitches['keyRevertVerticalVelocity'] == key:
                    self.__isVerticalVelocitySeparated = False
                    return True
                if self.__keySwitches['keyBindToVehicle'] == key:
                    if BigWorld.isKeyDown(Keys.KEY_LSHIFT) or BigWorld.isKeyDown(Keys.KEY_RSHIFT):
                        self.__showAim(True if self.__aim is None else not self.__aim.isActive)
                    else:
                        self.__boundVehicleMProv = self.__pickVehicle()
                        self.__rotateAroundPointEnabled = False
                    return True
                if BigWorld.isKeyDown(Keys.KEY_LSHIFT) or BigWorld.isKeyDown(Keys.KEY_RSHIFT):
                    if self.__verticalMovementSensor.handleKeyEvent(key, isDown) and key not in self.__verticalMovementSensor.keyMappings:
                        self.__isVerticalVelocitySeparated = True
                        return True
                    for velocityKey, velocity in self.__predefinedVerticalVelocities.iteritems():
                        if velocityKey == key:
                            self.__verticalMovementSensor.sensitivity = velocity
                            self.__isVerticalVelocitySeparated = True
                            return True

                for velocityKey, velocity in self.__predefinedVelocities.iteritems():
                    if velocityKey == key:
                        self.__movementSensor.sensitivity = velocity
                        return True

            if key in self.__verticalMovementSensor.keyMappings:
                self.__verticalMovementSensor.handleKeyEvent(key, isDown)
            return self.__movementSensor.handleKeyEvent(key, isDown) or self.__rotationSensor.handleKeyEvent(key, isDown) or self.__zoomSensor.handleKeyEvent(key, isDown) or self.__targetRadiusSensor.handleKeyEvent(key, isDown)
Esempio n. 18
0
 def __update(self):
     from AvatarInputHandler.control_modes import getFocalPoint
     pos = getFocalPoint()
     if pos is None:
         pos = 0
     else:
         pos = (BigWorld.camera().position - pos).length
     farPlane = 1.0 / BigWorld.projection().farPlane
     offset = 2.5
     zNear = (pos - offset) * farPlane
     zFar = (pos + offset) * farPlane
     DepthOfField.zNear.set(zNear, self.__relaxTime, True)
     DepthOfField.zFar.set(zFar, self.__relaxTime, True)
Esempio n. 19
0
 def __calcAimOffset(self, oscillationsZoomMultiplier):
     fov = BigWorld.projection().fov
     aspect = cameras.getScreenAspectRatio()
     yTan = math.tan(fov * 0.5)
     xTan = yTan * aspect
     defaultX = self.__defaultAimOffset[0]
     defaultY = self.__defaultAimOffset[1]
     yawFromImpulse = self.__impulseOscillator.deviation.x * self.__dynamicCfg['sideImpulseToYawRatio']
     xImpulseDeviationTan = math.tan(-(yawFromImpulse + self.__noiseOscillator.deviation.x) * oscillationsZoomMultiplier)
     pitchFromImpulse = self.__impulseOscillator.deviation.z * self.__dynamicCfg['frontImpulseToPitchRatio']
     yImpulseDeviationTan = math.tan((pitchFromImpulse + self.__noiseOscillator.deviation.y) * oscillationsZoomMultiplier)
     totalOffset = Vector2((defaultX * xTan + xImpulseDeviationTan) / (xTan * (1 - defaultX * xTan * xImpulseDeviationTan)), (defaultY * yTan + yImpulseDeviationTan) / (yTan * (1 - defaultY * yTan * yImpulseDeviationTan)))
     return totalOffset
Esempio n. 20
0
 def locateCameraOnEmblem(self, onHull, emblemType, emblemIdx, relativeSize = 0.5):
     self.__selectedEmblemInfo = (onHull,
      emblemType,
      emblemIdx,
      relativeSize)
     targetPosDirEmblem = self.__vAppearance.getEmblemPos(onHull, emblemType, emblemIdx)
     if targetPosDirEmblem is None:
         return False
     targetPos, dir, emblemDesc = targetPosDirEmblem
     emblemSize = emblemDesc[3] * _CFG['v_scale']
     halfF = emblemSize / (2 * relativeSize)
     dist = halfF / math.tan(BigWorld.projection().fov / 2)
     self.setCameraLocation(targetPos, Math.Vector3(0, 0, 0), dir.yaw, -dir.pitch, dist, True)
     return True
Esempio n. 21
0
 def __init__(self, dataSec):
     self.__readCfg(dataSec)
     self.__cam = BigWorld.FreeCamera()
     self.__angles = [0.0, 0.0]
     self.__dxdydz = [0.0, 0.0, 0.0]
     self.__zoom = self.__cfg['zoom']
     self.__fov = BigWorld.projection().fov
     self.__curSense = 0
     self.__curScrollSense = 0
     self.__autoUpdate = False
     self.__autoUpdateCallbackId = None
     self.__waitVehicleCallbackId = None
     self.__onChangeControlMode = None
     self.__pitchCompensation = 0
     self.__pitchCompensationTimestamp = BigWorld.time()
     return
Esempio n. 22
0
 def enable(self, targetPos, saveZoom):
     player = BigWorld.player()
     if not saveZoom:
         self.__zoom = self.__cfg['zoom']
     self.__fov = BigWorld.projection().fov
     self.__dxdydz = [0, 0, 0]
     self.__applyFOV(self.__fov / self.__zoom)
     self.__setupCamera(targetPos)
     vehicle = BigWorld.entity(player.playerVehicleID)
     if vehicle is None:
         self.__whiteVehicleCallbackId = BigWorld.callback(0.1, self.__waitVehicle)
     else:
         self.__showVehicle(False)
     BigWorld.camera(self.__cam)
     self.__cameraUpdate()
     return
Esempio n. 23
0
 def enable(self, targetPos, saveDist):
     self.__prevTime = BigWorld.time()
     self.__aimingSystem.enable(targetPos)
     srcMat = mathUtils.createRotationMatrix((0.0, -math.pi * 0.499, 0.0))
     self.__cam.source = srcMat
     if not saveDist:
         self.__camDist = self.__cfg['camDist']
     self.__cam.pivotPosition = Math.Vector3(0.0, self.__camDist, 0.0)
     camTarget = Math.MatrixProduct()
     camTarget.b = self.__aimingSystem.matrix
     self.__cam.target = camTarget
     BigWorld.camera(self.__cam)
     BigWorld.player().positionControl.moveTo(self.__aimingSystem.matrix.translation)
     BigWorld.player().positionControl.followCamera(True)
     FovExtended.instance().enabled = False
     BigWorld.projection().fov = StrategicCamera.ABSOLUTE_VERTICAL_FOV
     self.__cameraUpdate()
     self.delayCallback(0.0, self.__cameraUpdate)
     self.__needReset = 1
Esempio n. 24
0
 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)
     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(mathUtils.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)
     self.__ypr = self.__clampYPR(self.__ypr)
     self.__position = self.__checkSpaceBounds(prevPos, self.__position)
     self.__cam.invViewProvider.a = mathUtils.createRTMatrix(self.__ypr, self.__position)
     self.__cam.invViewProvider.b = self.__basisMProv.matrix
     BigWorld.projection().fov = self.__calcFov()
     self.__resetSenses()
     return 0.0
Esempio n. 25
0
 def __init__(self, dataSec, aim, binoculars):
     CallbackDelayer.__init__(self)
     self.__impulseOscillator = None
     self.__movementOscillator = None
     self.__noiseOscillator = None
     self.__dynamicCfg = CameraDynamicConfig()
     self.__accelerationSmoother = None
     self.__readCfg(dataSec)
     self.__cam = BigWorld.FreeCamera()
     self.__zoom = self.__cfg['zoom']
     self.__fov = BigWorld.projection().fov
     self.__curSense = 0
     self.__curScrollSense = 0
     self.__waitVehicleCallbackId = None
     self.__onChangeControlMode = None
     self.__aimingSystem = SniperAimingSystem()
     self.__aim = weakref.proxy(aim)
     self.__binoculars = binoculars
     self.__defaultAimOffset = self.__aim.offset()
     self.__defaultAimOffset = (self.__defaultAimOffset[0], self.__defaultAimOffset[1])
     self.__crosshairMatrix = createCrosshairMatrix(offsetFromNearPlane=self.__dynamicCfg['aimMarkerDistance'])
     self.__prevTime = BigWorld.time()
     self.__autoUpdateDxDyDz = Vector3(0, 0, 0)
     return
Esempio n. 26
0
 def _getFov(self):
     if IS_CLIENT:
         return BigWorld.projection().fov
     else:
         import WorldEditor
         return WorldEditor.getCameraFOV()
Esempio n. 27
0
def StrategicCamera__cameraUpdate(self):
    replayCtrl = BattleReplay.g_replayCtrl

    global gSPGSniperEnabled
    if not gSPGSniperEnabled:
        srcMat = mathUtils.createRotationMatrix((0, -math.pi * 0.49, 0))
        self._StrategicCamera__cam.source = srcMat
        self._StrategicCamera__cam.target.b = self._StrategicCamera__aimingSystem.matrix

        if not replayCtrl.isPlaying:
            BigWorld.projection().nearPlane = self._prevNearPlane
            BigWorld.projection().farPlane = self._prevFarPlane
            BigWorld.projection(
            ).fov = StrategicCamera.StrategicCamera.ABSOLUTE_VERTICAL_FOV
        return oldStrategicCamera__cameraUpdate(self)

    distRange = self._StrategicCamera__cfg['distRange'][:]
    if distRange[0] < 20:
        distRange[0] = 20
    distRange[1] = 600

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

    shotEnd = self._StrategicCamera__aimingSystem.matrix.translation

    shellVelocity = Math.Vector3(
        self._StrategicCamera__aimingSystem._shellVelocity)
    shellVelocity.normalise()

    srcMat = Math.Matrix()
    srcMat.setRotateYPR((shellVelocity.yaw, -shellVelocity.pitch, 0))
    shift = srcMat.applyVector(
        Math.Vector3(self._StrategicCamera__dxdydz.x, 0,
                     -self._StrategicCamera__dxdydz.y)
    ) * self._StrategicCamera__curSense

    if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
        aimOffset = replayCtrl.getAimClipPosition()
    else:
        aimWorldPos = self._StrategicCamera__aimingSystem.matrix.applyPoint(
            Math.Vector3(0, 0, 0))
        aimOffset = cameras.projectPoint(aimWorldPos)
        if replayCtrl.isRecording:
            replayCtrl.setAimClipPosition(
                Math.Vector2(aimOffset.x, aimOffset.y))

    self._StrategicCamera__aim.offset((aimOffset.x, aimOffset.y))
    shotDescr = BigWorld.player().vehicleTypeDescriptor.shot
    BigWorld.wg_trajectory_drawer().setParams(
        shotDescr['maxDistance'], Math.Vector3(0, -shotDescr['gravity'], 0),
        self._StrategicCamera__aim.offset())
    curTime = BigWorld.time()
    deltaTime = curTime - self._StrategicCamera__prevTime
    self._StrategicCamera__prevTime = curTime

    if replayCtrl.isPlaying:
        if self._StrategicCamera__needReset != 0:
            if self._StrategicCamera__needReset > 1:
                player = BigWorld.player()
                if player.inputHandler.ctrl is not None:
                    player.inputHandler.ctrl.resetGunMarkers()

            self._StrategicCamera__needReset = 0
        else:
            self._StrategicCamera__needReset += 1

        if replayCtrl.isControllingCamera:
            self._StrategicCamera__aimingSystem.updateTargetPos(
                replayCtrl.getGunRotatorTargetPoint())
        else:
            self._StrategicCamera__aimingSystem.handleMovement(
                shift.x, shift.z)
            if shift.x != 0 and shift.z != 0 or self._StrategicCamera__dxdydz.z != 0:
                self._StrategicCamera__needReset = 2

    self._StrategicCamera__aimingSystem.handleMovement(shift.x, shift.z)
    self._StrategicCamera__camDist -= self._StrategicCamera__dxdydz.z * float(
        self._StrategicCamera__curSense)
    maxPivotHeight = (distRange[1] -
                      distRange[0]) / BigWorld._ba_config['spg']['zoomSpeed']
    self._StrategicCamera__camDist = mathUtils.clamp(
        0, maxPivotHeight, self._StrategicCamera__camDist)
    self._StrategicCamera__cfg['camDist'] = self._StrategicCamera__camDist
    if self._StrategicCamera__dxdydz.z != 0 and self._StrategicCamera__onChangeControlMode is not None and mathUtils.almostZero(
            self._StrategicCamera__camDist - maxPivotHeight):
        self._StrategicCamera__onChangeControlMode()
    self._StrategicCamera__updateOscillator(deltaTime)
    if not self._StrategicCamera__autoUpdatePosition:
        self._StrategicCamera__dxdydz = Math.Vector3(0, 0, 0)

    fov = min(6.0 * descr.gun['shotDispersionAngle'], math.pi * 0.5)
    zoomFactor = 1.0 / math.tan(fov * 0.5) / 5.0

    #old scheme
    #zoomDistance = ( self._StrategicCamera__camDist + distRange[0] ) * zoomFactor

    #new scheme
    zoomDistance = distRange[0] * zoomFactor
    fovFactor = self._StrategicCamera__camDist / maxPivotHeight
    fov = fov * (1.0 - fovFactor) + math.radians(20.0) * fovFactor

    cameraOffset = -shellVelocity.scale(zoomDistance)
    cameraPosition = shotEnd + cameraOffset

    collPoint = None
    collPoint = BigWorld.wg_collideSegment(
        player.spaceID, shotEnd -
        shellVelocity.scale(1.0 if shellVelocity.y > 0.0 else distRange[0] *
                            zoomFactor * 0.25), cameraPosition, 128)

    if collPoint is None:
        collPoint = player.arena.collideWithSpaceBB(shotEnd, cameraPosition)
        if collPoint is not None:
            collPoint += shellVelocity
    else:
        collPoint = collPoint[0]

    recalculateDist = False
    if collPoint is not None:
        cameraPosition = collPoint
        cameraOffset = cameraPosition - shotEnd
        recalculateDist = True

    if cameraOffset.length > 700.0:
        cameraOffset.normalise()
        cameraOffset = cameraOffset.scale(700.0)
        cameraPosition = shotEnd + cameraOffset
        recalculateDist = True

    #if recalculateDist:
    #    self._StrategicCamera__camDist = cameraOffset.length / zoomFactor - distRange[0]

    #bb = BigWorld.player().arena.arenaType.boundingBox
    #cameraPositionClamped = _clampPoint2DInBox2D(bb[0] - Math.Vector2( 50.0, 50.0 ), bb[1] + Math.Vector2( 50.0, 50.0 ), Math.Vector2(cameraPosition.x, cameraPosition.z))

    #if abs( cameraPositionClamped.x - cameraPosition.x ) > 0.1 or abs( cameraPositionClamped.y - cameraPosition.z ) > 0.1:
    #    clampFactor = min( ( cameraPositionClamped.x - shotEnd.x ) / cameraOffset.x if abs( cameraOffset.x ) > 0.001 else 1.0, ( cameraPositionClamped.y - shotEnd.z ) / cameraOffset.z if abs( cameraOffset.z ) > 0.001 else 1.0 )
    #else:
    #    clampFactor = 1.0

    #if clampFactor < 0.99:
    #    cameraOffset *= clampFactor
    #    cameraPosition = shotEnd + cameraOffset
    #    self._StrategicCamera__camDist = cameraOffset.length / zoomFactor - distRange[0]

    trgMat = Math.Matrix()
    trgMat.setTranslate(cameraPosition)

    self._StrategicCamera__cam.source = srcMat
    self._StrategicCamera__cam.target.b = trgMat
    self._StrategicCamera__cam.pivotPosition = Math.Vector3(0, 0, 0)

    delta = self._prevFarPlane - self._prevNearPlane

    BigWorld.projection().nearPlane = max(cameraOffset.length - delta * 0.5,
                                          1.0)
    BigWorld.projection().farPlane = max(cameraOffset.length + delta * 0.5,
                                         self._prevFarPlane)
    BigWorld.projection().fov = fov
    BigWorld.player().positionControl.moveTo(shotEnd)

    #LOG_ERROR( '{0} {1}'.format( cameraPosition, self._StrategicCamera__camDist ) )
    #FLUSH_LOG( )

    return 0
Esempio n. 28
0
def getProjectionMatrix():
    proj = BigWorld.projection()
    aspect = getScreenAspectRatio()
    result = Math.Matrix()
    result.perspectiveProjection(proj.fov, aspect, proj.nearPlane, proj.farPlane)
    return result
Esempio n. 29
0
def createCrosshairMatrix(offsetFromNearPlane):
    nearPlane = BigWorld.projection().nearPlane
    return mathUtils.createTranslationMatrix(Vector3(0, 0, nearPlane + offsetFromNearPlane))
Esempio n. 30
0
def adjustFOV(diff):
    newFov = BigWorld.projection().fov + diff
    newFov = min(max(newFov, FOV_MIN), FOV_MAX)
    BigWorld.projection().rampFov(newFov, 0.1)
    if WWISE.enabled:
        WWISE.WG_loadBanks('', False)
Esempio n. 31
0
def getMouseTargettingRay():
    mtm = Math.Matrix(BigWorld.MouseTargettingMatrix())
    src = mtm.applyToOrigin()
    far = BigWorld.projection().farPlane
    dst = src + mtm.applyToAxis(2).scale(far)
    return (src, dst)
Esempio n. 32
0
def StrategicCamera_disable(self):
    oldStrategicCamera_disable(self)
    spgAim.onStrategicCameraDisable(self)
    BigWorld.projection().nearPlane = spgAim._prevNearPlane
    BigWorld.projection().farPlane = spgAim._prevFarPlane
Esempio n. 33
0
def StrategicCamera_create(self, onChangeControlMode):
    spgAim._prevNearPlane = BigWorld.projection().nearPlane
    spgAim._prevFarPlane = BigWorld.projection().farPlane
    oldStrategicCamera_create(self, onChangeControlMode)
    spgAim.onStrategicCameraCreate(self)
Esempio n. 34
0
def onCameraChange(oldCamera):
    BigWorld.clearTextureStreamingViewpoints()
    BigWorld.registerTextureStreamingViewpoint(BigWorld.camera(), BigWorld.projection())
Esempio n. 35
0
def StrategicCamera_enable(self, targetPos, saveDist):
    spgAim._prevNearPlane = BigWorld.projection().nearPlane
    spgAim._prevFarPlane = BigWorld.projection().farPlane
    spgAim.onStrategicCameraEnable(self)
    oldStrategicCamera_enable(self, targetPos, saveDist)
Esempio n. 36
0
def onCameraChange(oldCamera):
    BigWorld.clearTextureStreamingViewpoints()
    BigWorld.registerTextureStreamingViewpoint(BigWorld.camera(), BigWorld.projection())
Esempio n. 37
0
def getProjectionMatrix():
    proj = BigWorld.projection()
    aspect = getScreenAspectRatio()
    result = Math.Matrix()
    result.perspectiveProjection(proj.fov, aspect, proj.nearPlane, proj.farPlane)
    return result
Esempio n. 38
0
 def locateCameraToStyleInfoPreview(self, forceLocate=False):
     if self.__hangarCameraManager is None or self.__hangarCameraManager.camera is None:
         return
     else:
         self.__savePitch()
         from gui.ClientHangarSpace import customizationHangarCFG, hangarCFG
         cfg = customizationHangarCFG()
         hangarConfig = hangarCFG()
         if self.__tankCentralPoint is None:
             self.__tankCentralPoint = self.__getTankCentralPoint()
         dist = cfg['cam_start_dist']
         targetPos = copy(self.__tankCentralPoint)
         distConstraints = copy(cfg['cam_dist_constr'])
         if self.vEntity is not None and self.vEntity.appearance is not None and self.vEntity.appearance.compoundModel is not None:
             appearance = self.vEntity.appearance
             mat = Math.Matrix()
             mat.setRotateYPR((_STYLE_INFO_YAW, -_STYLE_INFO_PITCH, 0.0))
             pivotDir = mat.applyVector(Math.Vector3(1, 0, 0))
             pivotDir = Math.Vector3(pivotDir.x, 0, pivotDir.z)
             pivotDir.normalise()
             hullAABB = appearance.collisions.getBoundingBox(
                 TankPartIndexes.HULL)
             width = hullAABB[1].x - hullAABB[0].x
             length = hullAABB[1].z - hullAABB[0].z
             height = hullAABB[1].y - hullAABB[0].y
             hullViewSpaceX = width * abs(math.cos(
                 _STYLE_INFO_YAW)) + length * abs(math.sin(_STYLE_INFO_YAW))
             hullViewSpaceZ = width * abs(math.sin(
                 _STYLE_INFO_YAW)) + length * abs(math.cos(_STYLE_INFO_YAW))
             aspect = BigWorld.getAspectRatio()
             halfFOVTan = math.tan(BigWorld.projection().fov * 0.5)
             distW = hullViewSpaceX / (_STYLE_INFO_MAX_VEHICLE_WIDTH * 2 *
                                       halfFOVTan * aspect)
             distH = height / (_STYLE_INFO_MAX_VEHICLE_HEIGHT * 2 *
                               halfFOVTan) + hullViewSpaceZ * 0.5
             dist = max(distH, distW)
             distConstraints.y = _STYLE_INFO_MAX_CAMERA_DIST
             halfHeight = dist * halfFOVTan
             halfWidth = halfHeight * aspect
             targetPos += pivotDir * halfWidth * _STYLE_INFO_VEHICLE_SCREEN_X_SHIFT
             futureCamDir = mat.applyVector(Math.Vector3(0, 0, 1))
             futureCamPos = targetPos - futureCamDir * dist
             paramsDOF = None
             if isRendererPipelineDeferred():
                 paramsDOF = self.__getStyleInfoDOFParams(futureCamPos)
             self.__ctx.events.onUpdateStyleInfoDOF(paramsDOF)
         self._setCameraLocation(targetPos=targetPos,
                                 pivotPos=-Math.Vector3(0, 0, 0),
                                 yaw=_STYLE_INFO_YAW,
                                 pitch=_STYLE_INFO_PITCH,
                                 dist=dist,
                                 camConstraints=[
                                     hangarConfig['cam_pitch_constr'],
                                     hangarConfig['cam_yaw_constr'],
                                     distConstraints
                                 ],
                                 forceLocate=forceLocate,
                                 forceRotate=True)
         self.__currentMode = C11nCameraModes.STYLE_INFO
         self.enableMovementByMouse(enableRotation=False, enableZoom=False)
         return
Esempio n. 39
0
def getMouseTargettingRay():
    mtm = Math.Matrix(BigWorld.MouseTargettingMatrix())
    src = mtm.applyToOrigin()
    far = BigWorld.projection().farPlane
    dst = src + mtm.applyToAxis(2).scale(far)
    return (src, dst)
Esempio n. 40
0
    def onStrategicCameraUpdate(self, camera):
        replayCtrl = BattleReplay.g_replayCtrl

        distRange = camera._StrategicCamera__cfg['distRange'][:]
        if distRange[0] < 20:
            distRange[0] = 20
        distRange[1] = 600

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

        shotEnd = camera._StrategicCamera__aimingSystem.matrix.translation

        shellVelocity = Math.Vector3(self._shellVelocity)
        shellVelocity.normalise()

        srcMat = Math.Matrix()
        srcMat.setRotateYPR((shellVelocity.yaw, -shellVelocity.pitch, 0))
        shift = srcMat.applyVector(
            Math.Vector3(camera._StrategicCamera__dxdydz.x, 0,
                         -camera._StrategicCamera__dxdydz.y)
        ) * camera._StrategicCamera__curSense

        if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
            aimOffset = replayCtrl.getAimClipPosition()
        else:
            aimWorldPos = camera._StrategicCamera__aimingSystem.matrix.translation
            aimOffset = cameras.projectPoint(aimWorldPos)
            if replayCtrl.isRecording:
                replayCtrl.setAimClipPosition(
                    Math.Vector2(aimOffset.x, aimOffset.y))

        camera._StrategicCamera__aimOffsetFunc((aimOffset.x, aimOffset.y))
        shotDescr = BigWorld.player().vehicleTypeDescriptor.shot
        BigWorld.wg_trajectory_drawer().setParams(
            shotDescr['maxDistance'], Math.Vector3(0, -shotDescr['gravity'],
                                                   0),
            camera._StrategicCamera__aimOffsetFunc())
        curTime = BigWorld.time()
        deltaTime = curTime - camera._StrategicCamera__prevTime
        camera._StrategicCamera__prevTime = curTime

        if replayCtrl.isPlaying:
            if camera._StrategicCamera__needReset != 0:
                if camera._StrategicCamera__needReset > 1:
                    player = BigWorld.player()
                    if player.inputHandler.ctrl is not None:
                        player.inputHandler.ctrl.resetGunMarkers()

                camera._StrategicCamera__needReset = 0
            else:
                camera._StrategicCamera__needReset += 1

            if replayCtrl.isControllingCamera:
                camera._StrategicCamera__aimingSystem.updateTargetPos(
                    replayCtrl.getGunRotatorTargetPoint())
            else:
                camera._StrategicCamera__aimingSystem.handleMovement(
                    shift.x, shift.z)
                if shift.x != 0 and shift.z != 0 or camera._StrategicCamera__dxdydz.z != 0:
                    self._StrategicCamera__needReset = 2

        camera._StrategicCamera__aimingSystem.handleMovement(shift.x, shift.z)
        camera._StrategicCamera__camDist -= camera._StrategicCamera__dxdydz.z * float(
            camera._StrategicCamera__curSense)
        maxPivotHeight = (distRange[1] - distRange[0]
                          ) / BigWorld._ba_config['spg']['zoomSpeed']
        camera._StrategicCamera__camDist = mathUtils.clamp(
            0, maxPivotHeight, camera._StrategicCamera__camDist)
        camera._StrategicCamera__cfg[
            'camDist'] = camera._StrategicCamera__camDist
        if camera._StrategicCamera__dxdydz.z != 0 and camera._StrategicCamera__onChangeControlMode is not None and mathUtils.almostZero(
                camera._StrategicCamera__camDist - maxPivotHeight):
            camera._StrategicCamera__onChangeControlMode()
        camera._StrategicCamera__updateOscillator(deltaTime)
        if not camera._StrategicCamera__autoUpdatePosition:
            camera._StrategicCamera__dxdydz = Math.Vector3(0, 0, 0)

        fov = min(6.0 * descr.gun['shotDispersionAngle'], math.pi * 0.5)
        zoomFactor = 1.0 / math.tan(fov * 0.5) / 5.0

        zoomDistance = distRange[0] * zoomFactor
        fovFactor = camera._StrategicCamera__camDist / maxPivotHeight
        fov = fov * (1.0 - fovFactor) + math.radians(20.0) * fovFactor

        cameraOffset = -shellVelocity.scale(zoomDistance)
        cameraPosition = shotEnd + cameraOffset

        collPoint = None if BigWorld._ba_config['spg'][
            'ignoreObstacles'] else BigWorld.wg_collideSegment(
                player.spaceID, shotEnd - shellVelocity.scale(
                    1.0 if shellVelocity.y > 0.0 else distRange[0] *
                    zoomFactor * 0.25), cameraPosition, 128)

        if collPoint is None:
            collPoint = player.arena.collideWithSpaceBB(
                shotEnd, cameraPosition)
            if collPoint is not None:
                collPoint += shellVelocity
        else:
            collPoint = collPoint[0]

        recalculateDist = False
        if collPoint is not None:
            cameraPosition = collPoint
            cameraOffset = cameraPosition - shotEnd
            recalculateDist = True

        if cameraOffset.length > 700.0:
            cameraOffset.normalise()
            cameraOffset = cameraOffset.scale(700.0)
            cameraPosition = shotEnd + cameraOffset
            recalculateDist = True

        trgMat = Math.Matrix()
        trgMat.setTranslate(cameraPosition)

        camera._StrategicCamera__cam.source = srcMat
        camera._StrategicCamera__cam.target.b = trgMat
        camera._StrategicCamera__cam.pivotPosition = Math.Vector3(0, 0, 0)

        delta = self._prevFarPlane - self._prevNearPlane

        BigWorld.projection().nearPlane = max(
            cameraOffset.length - delta * 0.5, 1.0)
        BigWorld.projection().farPlane = max(cameraOffset.length + delta * 0.5,
                                             self._prevFarPlane)
        BigWorld.projection().fov = fov
        BigWorld.player().positionControl.moveTo(shotEnd)

        if BigWorld._ba_config['spg'][
                'alwaysFollowProjectile'] or BigWorld.isKeyDown(
                    self._followProjectileKey):
            if self._trackProjectile:
                time = BigWorld.time() - self._trackProjectileStartTime
                if time > 0:
                    shotDescr = descr.shot
                    gravity = Math.Vector3(0.0, -shotDescr['gravity'], 0.0)
                    shellVelocity = self._trackProjectileVelocity + gravity.scale(
                        time)
                    srcMat.setRotateYPR(
                        (shellVelocity.yaw, -shellVelocity.pitch, 0))
                    camera._StrategicCamera__cam.source = srcMat
                    camera._StrategicCamera__cam.target.b.setTranslate(
                        self._trackProjectileStartPoint +
                        self._trackProjectileVelocity.scale(time) +
                        gravity.scale(time * time * 0.5))
                    BigWorld.projection().fov = math.pi * 0.4

            elif player._PlayerAvatar__projectileMover._ProjectileMover__projectiles.get(
                    self._projectileID):
                shellVelocity = Math.Matrix(self._projectileMP).applyVector(
                    Math.Vector3(0.0, 0.0, 1.0))
                srcMat.setRotateYPR(
                    (shellVelocity.yaw, -shellVelocity.pitch, 0))
                camera._StrategicCamera__cam.source = srcMat
                camera._StrategicCamera__cam.target.b = self._projectileMP
                BigWorld.projection().fov = math.pi * 0.4

        return 0
Esempio n. 41
0
 def __updateVisibleAxis(self):
     if not self._notControlledByUser and EntityStates.inState(BigWorld.player(), EntityStates.GAME):
         player = BigWorld.player()
         direction = self.__camDirection
         fmRotation = BigWorld.player().getRotation()
         rotation = Math.Quaternion(fmRotation)
         rotation.invert()
         norm = Math.Vector3(direction)
         norm.normalise()
         yawAngle = math.pi / 2.0 - math.acos(clamp(-1.0, fmRotation.getAxisX().dot(norm), 1.0))
         pitchAngle = math.pi / 2.0 - math.acos(clamp(-1.0, fmRotation.getAxisY().dot(norm), 1.0))
         mouseRoll = -sign(yawAngle) * clamp(-1.0, max(0.0, (abs(yawAngle) - math.radians(5.0)) / math.radians(5.0)), 1.0)
         hAxis = clamp(-1.0, yawAngle / math.radians(5.0) * 8.0, 1.0) * (1 - abs(self.__axisKeyBoard[HORIZONTAL_AXIS])) + self.__axisKeyBoard[HORIZONTAL_AXIS]
         vAxis = clamp(-1.0, pitchAngle / math.radians(10.0), 1.0) * (1 - abs(self.__axisKeyBoard[VERTICAL_AXIS])) + self.__axisKeyBoard[VERTICAL_AXIS]
         roll_cfc = bool(InputMapping.g_instance.mouseSettings.ROLL_SPEED_CFC) * max(0.25, 1.0 - (1.0 - InputMapping.g_instance.mouseSettings.ROLL_SPEED_CFC) ** 3)
         rAxis = roll_cfc * mouseRoll * (1 - abs(self.__axisKeyBoard[ROLL_AXIS])) + self.__axisKeyBoard[ROLL_AXIS]
         speedDirection = player.getWorldVector()
         speedDirection.normalise()
         dotX = clamp(-1.0, fmRotation.getAxisX().dot(speedDirection), 1.0)
         dotY = clamp(-1.0, fmRotation.getAxisY().dot(speedDirection), 1.0)
         angleX = abs(math.pi / 2.0 - math.acos(dotX)) / math.radians(10.0)
         angleY = abs(math.pi / 2.0 - math.acos(dotY)) / math.radians(35.0 / 2.0)
         signX = sign(dotX)
         signY = sign(dotY)
         hAxis = clamp(-1.0, hAxis - (1.0 - abs(hAxis)) * clamp(-1.0, signX * angleX, 1.0), 1.0)
         vAxis = clamp(-1.0, vAxis - (1.0 - abs(vAxis)) * clamp(-1.0, signY * angleY, 1.0), 1.0)
         mouseAngle = math.acos(clamp(-1.0, fmRotation.getAxisZ().dot(norm), 1.0))
         equalizerAngle = 0.5 * (0.3 + 0.7 * InputMapping.g_instance.mouseSettings.RADIUS_OF_CONDUCTING) * BigWorld.projection().fov * InputMapping.g_instance.mouseSettings.EQUALIZER_ZONE_SIZE
         equalizer = max(0.0, 1.0 - mouseAngle / equalizerAngle) * clamp(-1.0, InputMapping.g_instance.mouseSettings.EQUALIZER_FORCE * player.roll / player.rollRudderNorma, 1.0) if equalizerAngle else 0.0
         rAxis = clamp(-1.0, rAxis - (1.0 - abs(rAxis)) * equalizer, 1.0)
         self.__applyInputAxis(HORIZONTAL_AXIS, clamp(-1.0, hAxis, 1.0))
         self.__applyInputAxis(ROLL_AXIS, clamp(-1.0, rAxis, 1.0))
         self.__applyInputAxis(VERTICAL_AXIS, clamp(-1.0, vAxis, 1.0))
         self.__applyInputAxis(FORCE_AXIS, self.__lastKeyBoardAxis[FORCE_AXIS])
         automaticFlaps = False
         if InputMapping.g_instance.mouseSettings.AUTOMATIC_FLAPS:
             automaticFlaps = int(max(0.0, player.asymptoteVMaxPitch - abs(player.getRotationSpeed().y)) < 0.25 * player.asymptoteVMaxPitch)
         self.__applyInputAxis(FLAPS_AXIS, self.__axisKeyBoard[FLAPS_AXIS] or automaticFlaps)
Esempio n. 42
0
 def __calcFov(self):
     fov = BigWorld.projection().fov + self.__zoomSensor.currentVelocity
     return mathUtils.clamp(0.1, math.pi - 0.1, fov)
Esempio n. 43
0
    def handleKeyEvent(self, key, isDown):
        if key is None:
            return False
        else:
            if isDown:
                if self.__keySwitches['keySwitchInertia'] == key:
                    self.__inertiaEnabled = not self.__inertiaEnabled
                    return True
                if self.__keySwitches['keySwitchRotateAroundPoint'] == key:
                    self.__rotateAroundPointEnabled = not self.__rotateAroundPointEnabled
                    self.__boundVehicleMProv = None
                    return True
                if self.__keySwitches['keySwitchLandCamera'] == key:
                    if self.__alignerToLand.enabled:
                        self.__alignerToLand.disable()
                    else:
                        self.__alignerToLand.enable(self.__position)
                    return True
                if self.__keySwitches['keySetDefaultFov'] == key:
                    BigWorld.projection().fov = self.__defaultFov
                    return True
                if self.__keySwitches['keySetDefaultRoll'] == key:
                    self.__ypr.z = 0.0
                    return True
                if self.__keySwitches['keyRevertVerticalVelocity'] == key:
                    self.__isVerticalVelocitySeparated = False
                    return True
                if self.__keySwitches['keyBindToVehicle'] == key:
                    if BigWorld.isKeyDown(
                            Keys.KEY_LSHIFT) or BigWorld.isKeyDown(
                                Keys.KEY_RSHIFT):
                        self.__showAim(True if self.__aim is None else
                                       not self.__aim.isActive)
                    else:
                        self.__boundVehicleMProv = self.__pickVehicle()
                        self.__rotateAroundPointEnabled = False
                    return True
                if BigWorld.isKeyDown(Keys.KEY_LSHIFT) or BigWorld.isKeyDown(
                        Keys.KEY_RSHIFT):
                    if self.__verticalMovementSensor.handleKeyEvent(
                            key, isDown
                    ) and key not in self.__verticalMovementSensor.keyMappings:
                        self.__isVerticalVelocitySeparated = True
                        return True
                    for velocityKey, velocity in self.__predefinedVerticalVelocities.iteritems(
                    ):
                        if velocityKey == key:
                            self.__verticalMovementSensor.sensitivity = velocity
                            self.__isVerticalVelocitySeparated = True
                            return True

                for velocityKey, velocity in self.__predefinedVelocities.iteritems(
                ):
                    if velocityKey == key:
                        self.__movementSensor.sensitivity = velocity
                        return True

            if key in self.__verticalMovementSensor.keyMappings:
                self.__verticalMovementSensor.handleKeyEvent(key, isDown)
            return self.__movementSensor.handleKeyEvent(
                key, isDown) or self.__rotationSensor.handleKeyEvent(
                    key, isDown) or self.__zoomSensor.handleKeyEvent(
                        key,
                        isDown) or self.__targetRadiusSensor.handleKeyEvent(
                            key, isDown)
Esempio n. 44
0
 def __calcFov(self):
     fov = BigWorld.projection().fov + self.__zoomSensor.currentVelocity
     return mathUtils.clamp(0.1, math.pi - 0.1, fov)
Esempio n. 45
0
def createCrosshairMatrix(offsetFromNearPlane):
    nearPlane = BigWorld.projection().nearPlane
    return mathUtils.createTranslationMatrix(
        Vector3(0, 0, nearPlane + offsetFromNearPlane))