def __pickVehicle(self):
     if self.__boundVehicleMProv is not None:
         return
     else:
         x, y = GUI.mcursor().position
         from AvatarInputHandler import cameras
         dir, start = cameras.getWorldRayAndPoint(x, y)
         end = start + dir.scale(100000.0)
         pos, colldata = collideDynamicAndStatic(start, end, (), 0)
         vehicle = None
         if colldata is not None:
             entity = colldata[0]
             from Vehicle import Vehicle
             if isinstance(entity, Vehicle):
                 vehMatProv = entity.matrix
                 vehMatInv = Matrix(vehMatProv)
                 vehMatInv.invert()
                 localPos = vehMatInv.applyPoint(pos)
                 result = Math.MatrixProduct()
                 localTransMat = Matrix()
                 localTransMat.translation = localPos
                 result.a = localTransMat
                 result.b = vehMatProv
                 return result
         return
 def __cameraUpdate(self):
     curTime = BigWorld.time()
     deltaTime = curTime - self.__prevTime
     self.__prevTime = curTime
     if not self.__autoUpdateDxDyDz.x == self.__autoUpdateDxDyDz.y == self.__autoUpdateDxDyDz.z == 0.0:
         self.__rotateAndZoom(self.__autoUpdateDxDyDz.x, self.__autoUpdateDxDyDz.y, self.__autoUpdateDxDyDz.z)
     self.__aimingSystem.update(deltaTime)
     localTransform, impulseTransform = self.__updateOscillators(deltaTime)
     ownVehicle = BigWorld.entity(BigWorld.player().playerVehicleID)
     if ownVehicle is not None and ownVehicle.isStarted and ownVehicle.appearance.isUnderwater:
         self.__onChangeControlMode()
         return 0.0
     else:
         aimMatrix = cameras.getAimMatrix(*self.__defaultAimOffset)
         camMat = Matrix(aimMatrix)
         rodMat = mathUtils.createTranslationMatrix(-self.__dynamicCfg['pivotShift'])
         antiRodMat = mathUtils.createTranslationMatrix(self.__dynamicCfg['pivotShift'])
         camMat.postMultiply(rodMat)
         camMat.postMultiply(localTransform)
         camMat.postMultiply(antiRodMat)
         camMat.postMultiply(self.__aimingSystem.matrix)
         camMat.invert()
         self.__cam.set(camMat)
         replayCtrl = BattleReplay.g_replayCtrl
         if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
             aimOffset = replayCtrl.getAimClipPosition()
             binocularsOffset = aimOffset
         else:
             aimOffset = self.__calcAimOffset(impulseTransform)
             binocularsOffset = self.__calcAimOffset()
             if replayCtrl.isRecording:
                 replayCtrl.setAimClipPosition(aimOffset)
         self.__aim.offset((aimOffset.x, aimOffset.y))
         self.__binoculars.setMaskCenter(binocularsOffset.x, binocularsOffset.y)
         return 0.0
 def update(self, vehicle, deltaTime):
     try:
         curVelocity = vehicle.filter.velocity
         acceleration = vehicle.filter.acceleration
         acceleration = self.__accelerationFilter.add(acceleration)
         movementFlags = vehicle.engineMode[1]
         moveMask = 3
         self.__hasChangedDirection = movementFlags & moveMask ^ self.__prevMovementFlags & moveMask or curVelocity.dot(
             self.__prevVelocity) <= 0.01
         self.__prevMovementFlags = movementFlags
         self.__prevVelocity = curVelocity
         self.__timeLapsedSinceDirChange += deltaTime
         if self.__hasChangedDirection:
             self.__timeLapsedSinceDirChange = 0.0
         elif self.__timeLapsedSinceDirChange > self.__maxAccelerationDuration:
             invVehMat = Matrix(vehicle.matrix)
             invVehMat.invert()
             accelerationRelativeToVehicle = invVehMat.applyVector(
                 acceleration)
             accelerationRelativeToVehicle.x = 0.0
             accelerationRelativeToVehicle.z = 0.0
             acceleration = Matrix(
                 vehicle.matrix).applyVector(accelerationRelativeToVehicle)
         self.__acceleration = acceleration
         return acceleration
     except:
         return Math.Vector3(0.0, 0.0, 0.0)
Exemple #4
0
 def __cameraUpdate(self, allowModeChange = True):
     curTime = BigWorld.time()
     deltaTime = curTime - self.__prevTime
     self.__prevTime = curTime
     if not self.__autoUpdateDxDyDz.x == self.__autoUpdateDxDyDz.y == self.__autoUpdateDxDyDz.z == 0.0:
         self.__rotateAndZoom(self.__autoUpdateDxDyDz.x, self.__autoUpdateDxDyDz.y, self.__autoUpdateDxDyDz.z)
     self.__aimingSystem.update(deltaTime)
     localTransform, impulseTransform = self.__updateOscillators(deltaTime)
     aimMatrix = cameras.getAimMatrix(*self.__defaultAimOffset)
     camMat = Matrix(aimMatrix)
     rodMat = mathUtils.createTranslationMatrix(-self.__dynamicCfg['pivotShift'])
     antiRodMat = mathUtils.createTranslationMatrix(self.__dynamicCfg['pivotShift'])
     camMat.postMultiply(rodMat)
     camMat.postMultiply(localTransform)
     camMat.postMultiply(antiRodMat)
     camMat.postMultiply(self.__aimingSystem.matrix)
     camMat.invert()
     self.__cam.set(camMat)
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
         aimOffset = replayCtrl.getAimClipPosition()
         binocularsOffset = aimOffset
     else:
         aimOffset = self.__calcAimOffset(impulseTransform)
         binocularsOffset = self.__calcAimOffset()
         if replayCtrl.isRecording:
             replayCtrl.setAimClipPosition(aimOffset)
     self.__aim.offset(aimOffset)
     self.__binoculars.setMaskCenter(binocularsOffset.x, binocularsOffset.y)
     player = BigWorld.player()
     if allowModeChange and (self.__isPositionUnderwater(self.__aimingSystem.matrix.translation) or player.isGunLocked):
         self.__onChangeControlMode(False)
         return -1
     return 0.0
 def __update(self, dx, dy, dz, rotateMode = True, zoomMode = True, isCallback = False):
     prevPos = self.__inputInertia.calcWorldPos(self.__aimingSystem.matrix)
     distChanged = False
     if zoomMode and dz != 0:
         prevDist = self.__aimingSystem.distanceFromFocus
         distDelta = dz * float(self.__curScrollSense)
         distMinMax = self.__cfg['distRange']
         newDist = mathUtils.clamp(distMinMax.min, distMinMax.max, prevDist - distDelta)
         if abs(newDist - prevDist) > 0.001:
             self.__aimingSystem.distanceFromFocus = newDist
             self.__userCfg['startDist'] = newDist
             self.__inputInertia.glideFov(self.__calcRelativeDist())
             self.__aimingSystem.aimMatrix = self.__calcAimMatrix()
             distChanged = True
         changeControlMode = prevDist == newDist and mathUtils.almostZero(newDist - distMinMax.min)
         if changeControlMode and self.__onChangeControlMode is not None:
             self.__onChangeControlMode()
             return
     if rotateMode:
         self.__updateAngles(dx, dy)
     if ENABLE_INPUT_ROTATION_INERTIA and not distChanged:
         self.__aimingSystem.update(0.0)
     if ENABLE_INPUT_ROTATION_INERTIA or distChanged:
         worldDeltaPos = prevPos - self.__aimingSystem.matrix.translation
         matInv = Matrix(self.__aimingSystem.matrix)
         matInv.invert()
         self.__inputInertia.glide(matInv.applyVector(worldDeltaPos))
     return
Exemple #6
0
 def __update(self, dx, dy, dz, rotateMode = True, zoomMode = True, isCallback = False):
     prevPos = self.__inputInertia.calcWorldPos(self.__aimingSystem.matrix)
     distChanged = False
     if zoomMode and dz != 0:
         prevDist = self.__aimingSystem.distanceFromFocus
         distDelta = dz * float(self.__curScrollSense)
         distMinMax = self.__cfg['distRange']
         newDist = mathUtils.clamp(distMinMax.min, distMinMax.max, prevDist - distDelta)
         if abs(newDist - prevDist) > 0.001:
             self.__aimingSystem.distanceFromFocus = newDist
             self.__userCfg['startDist'] = newDist
             self.__inputInertia.glideFov(self.__calcRelativeDist())
             self.__aimingSystem.aimMatrix = self.__calcAimMatrix()
             distChanged = True
         changeControlMode = prevDist == newDist and mathUtils.almostZero(newDist - distMinMax.min)
         if changeControlMode and self.__onChangeControlMode is not None:
             self.__onChangeControlMode()
             return
     if rotateMode:
         self.__updateAngles(dx, dy)
     if ENABLE_INPUT_ROTATION_INERTIA and not distChanged:
         self.__aimingSystem.update(0.0)
     if ENABLE_INPUT_ROTATION_INERTIA or distChanged:
         worldDeltaPos = prevPos - self.__aimingSystem.matrix.translation
         matInv = Matrix(self.__aimingSystem.matrix)
         matInv.invert()
         self.__inputInertia.glide(matInv.applyVector(worldDeltaPos))
Exemple #7
0
 def __pickVehicle(self):
     if self.__boundVehicleMProv is not None:
         return
     else:
         x, y = GUI.mcursor().position
         from AvatarInputHandler import cameras
         dir, start = cameras.getWorldRayAndPoint(x, y)
         end = start + dir.scale(100000.0)
         pos, colldata = collideDynamicAndStatic(start, end, (), 0)
         vehicle = None
         if colldata is not None:
             entity = colldata[0]
             from Vehicle import Vehicle
             if isinstance(entity, Vehicle):
                 vehMatProv = entity.matrix
                 vehMatInv = Matrix(vehMatProv)
                 vehMatInv.invert()
                 localPos = vehMatInv.applyPoint(pos)
                 result = Math.MatrixProduct()
                 localTransMat = Matrix()
                 localTransMat.translation = localPos
                 result.a = localTransMat
                 result.b = vehMatProv
                 return result
         return
Exemple #8
0
 def __getLookAtYPR(self, lookAtPosition):
     lookDir = lookAtPosition - self.__position
     camMat = Matrix()
     camMat.lookAt(self.__position, lookDir, Vector3(0, 1, 0))
     camMat.invert()
     yaw = camMat.yaw
     pitch = camMat.pitch
     return Vector3(yaw, pitch, self.__ypr.z)
 def __getLookAtYPR(self, lookAtPosition):
     lookDir = lookAtPosition - self.__position
     camMat = Matrix()
     camMat.lookAt(self.__position, lookDir, Vector3(0, 1, 0))
     camMat.invert()
     yaw = camMat.yaw
     pitch = camMat.pitch
     return Vector3(yaw, pitch, self.__ypr.z)
Exemple #10
0
 def bind(self, vehicle, bindWorldPos = None):
     self.__vehicle = vehicle
     if vehicle is None:
         self.matrix = mathUtils.createIdentityMatrix()
         self.__lookAtProvider = None
         return
     toLocalMat = Matrix(vehicle.matrix)
     toLocalMat.invert()
     self.__boundLocalPos = None if bindWorldPos is None else toLocalMat.applyPoint(bindWorldPos)
     self.selectPlacement(_VehicleBounder.SELECT_CHASSIS)
Exemple #11
0
 def __switchBind(self):
     if self.__basisMProv.isBound:
         self.__basisMProv.bind(None)
     else:
         self.__basisMProv.bind(*self.__entityPicker.pick())
     localMat = Matrix(self.__cam.invViewMatrix)
     basisInv = Matrix(self.__basisMProv.matrix)
     basisInv.invert()
     localMat.postMultiply(basisInv)
     self.__position = localMat.translation
     self.__ypr.set(localMat.yaw, localMat.pitch, localMat.roll)
 def __switchBind(self):
     if self.__basisMProv.isBound:
         self.__basisMProv.bind(None)
     else:
         self.__basisMProv.bind(*self.__entityPicker.pick())
     localMat = Matrix(self._cam.invViewMatrix)
     basisInv = Matrix(self.__basisMProv.matrix)
     basisInv.invert()
     localMat.postMultiply(basisInv)
     self.__position = localMat.translation
     self.__ypr.set(localMat.yaw, localMat.pitch, localMat.roll)
     return
Exemple #13
0
 def bind(self, vehicle, bindWorldPos = None):
     self.__vehicle = vehicle
     if vehicle is None:
         self.matrix = mathUtils.createIdentityMatrix()
         self.__lookAtProvider = None
         return
     else:
         toLocalMat = Matrix(vehicle.matrix)
         toLocalMat.invert()
         self.__boundLocalPos = None if bindWorldPos is None else toLocalMat.applyPoint(bindWorldPos)
         self.selectPlacement(_VehicleBounder.SELECT_CHASSIS)
         return
Exemple #14
0
 def __processBindToVehicleKey(self):
     if BigWorld.isKeyDown(Keys.KEY_LSHIFT) or BigWorld.isKeyDown(Keys.KEY_RSHIFT):
         self.__toggleView()
     elif BigWorld.isKeyDown(Keys.KEY_LALT) or BigWorld.isKeyDown(Keys.KEY_RALT):
         worldMat = Math.Matrix(self.__cam.invViewProvider)
         self.__basisMProv.selectNextPlacement()
         boundMatrixInv = Matrix(self.__basisMProv.matrix)
         boundMatrixInv.invert()
         worldMat.postMultiply(boundMatrixInv)
         self.__position = worldMat.translation
         self.__ypr = Vector3(worldMat.yaw, worldMat.pitch, worldMat.roll)
     else:
         self.__switchBind()
Exemple #15
0
 def __processBindToVehicleKey(self):
     if BigWorld.isKeyDown(Keys.KEY_LSHIFT) or BigWorld.isKeyDown(Keys.KEY_RSHIFT):
         self.__toggleView()
     elif BigWorld.isKeyDown(Keys.KEY_LALT) or BigWorld.isKeyDown(Keys.KEY_RALT):
         worldMat = Math.Matrix(self.__cam.invViewProvider)
         self.__basisMProv.selectNextPlacement()
         boundMatrixInv = Matrix(self.__basisMProv.matrix)
         boundMatrixInv.invert()
         worldMat.postMultiply(boundMatrixInv)
         self.__position = worldMat.translation
         self.__ypr = Vector3(worldMat.yaw, worldMat.pitch, worldMat.roll)
     else:
         self.__switchBind()
 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)
Exemple #17
0
    def worldHitTest(self, start, stop, worldMatrix, value=0):
        worldToLocal = Matrix(worldMatrix)
        worldToLocal.invert()
        testRes = self.__getBspModel(value).collideSegment(
            worldToLocal.applyPoint(start), worldToLocal.applyPoint(stop))
        if testRes is None:
            return
        else:
            res = []
            for dist, normal, hitAngleCos, matKind in testRes:
                res.append((dist, worldMatrix.applyVector(normal), hitAngleCos,
                            matKind))

            return res
    def worldHitTest(self, start, stop, worldMatrix):
        worldToLocal = Matrix(worldMatrix)
        worldToLocal.invert()
        testRes = self.__bspModel.collideSegment(worldToLocal.applyPoint(start), worldToLocal.applyPoint(stop))
        if testRes is None:
            return
        res = []
        for dist, normal, hitAngleCos, matKind in testRes:
            res.append((dist,
             worldMatrix.applyVector(normal),
             hitAngleCos,
             matKind))

        return res
 def __cameraUpdate(self, allowModeChange=True):
     curTime = BigWorld.time()
     deltaTime = curTime - self.__prevTime
     self.__prevTime = curTime
     if not self.__autoUpdateDxDyDz.x == self.__autoUpdateDxDyDz.y == self.__autoUpdateDxDyDz.z == 0.0:
         self.__rotateAndZoom(self.__autoUpdateDxDyDz.x,
                              self.__autoUpdateDxDyDz.y,
                              self.__autoUpdateDxDyDz.z)
     self.__aimingSystem.update(deltaTime)
     localTransform, impulseTransform = self.__updateOscillators(deltaTime)
     zoom = self.__aimingSystem.overrideZoom(self.__zoom)
     aimMatrix = cameras.getAimMatrix(self.__defaultAimOffset.x,
                                      self.__defaultAimOffset.y)
     camMat = Matrix(aimMatrix)
     rodMat = mathUtils.createTranslationMatrix(
         -self.__dynamicCfg['pivotShift'])
     antiRodMat = mathUtils.createTranslationMatrix(
         self.__dynamicCfg['pivotShift'])
     camMat.postMultiply(rodMat)
     camMat.postMultiply(localTransform)
     camMat.postMultiply(antiRodMat)
     camMat.postMultiply(self.__aimingSystem.matrix)
     camMat.invert()
     self.__cam.set(camMat)
     if zoom != self.__zoom:
         self.__zoom = zoom
         self.__applyZoom(self.__zoom)
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
         aimOffset = replayCtrl.getAimClipPosition()
         binocularsOffset = aimOffset
         if not BigWorld.player().isForcedGuiControlMode() and GUI.mcursor(
         ).inFocus:
             GUI.mcursor().position = aimOffset
     else:
         aimOffset = self.__calcAimOffset(impulseTransform)
         binocularsOffset = self.__calcAimOffset()
         if replayCtrl.isRecording:
             replayCtrl.setAimClipPosition(aimOffset)
     self.__aimOffset = aimOffset
     self.__binoculars.setMaskCenter(binocularsOffset.x, binocularsOffset.y)
     player = BigWorld.player()
     if allowModeChange and (self.__isPositionUnderwater(
             self.__aimingSystem.matrix.translation) or player.isGunLocked
                             and not player.isObserverFPV):
         self.__onChangeControlMode(False)
         return -1
Exemple #20
0
    def collideSegment(self, startPoint, endPoint, skipGun = False):
        res = None
        filterMethod = getattr(self.filter, 'segmentMayHitEntity', lambda : True)
        if not filterMethod(startPoint, endPoint, 0):
            return res
        modelsToCheck = (self.model,) if skipGun else (self.model, self.__gunModel)
        for model, desc in zip(modelsToCheck, self.__componentsDesc):
            toModel = Matrix(model.matrix)
            toModel.invert()
            collisions = desc['hitTester'].localHitTest(toModel.applyPoint(startPoint), toModel.applyPoint(endPoint))
            if collisions is None:
                continue
            for dist, _, hitAngleCos, matKind in collisions:
                if res is None or res.dist >= dist:
                    matInfo = desc['materials'].get(matKind)
                    res = SegmentCollisionResult(dist, hitAngleCos, matInfo.armor if matInfo is not None else 0)

        return res
Exemple #21
0
    def checkTurretDetachment(self, worldPos):
        if self.__vehicle is None:
            return
        if self.__vehicle.isTurretDetached and not self.__placement == _VehicleBounder.SELECT_DETACHED_TURRET:
            turretFound = None
            for turret in DetachedTurret.allTurrets:
                if turret.vehicleID == self.__vehicle.id and turret.model.visible:
                    turretFound = turret
                    break

            if turretFound is None:
                return
            turretToGoalShift = worldPos - turretFound.position
            toTurretMat = Matrix(turretFound.matrix)
            toTurretMat.invert()
            turretToGoalShift = toTurretMat.applyVector(turretToGoalShift)
            self.matrix = turretFound.matrix
            self.__lookAtProvider = None
            self.__placement = _VehicleBounder.SELECT_DETACHED_TURRET
            return turretToGoalShift
Exemple #22
0
 def update(self, vehicle, deltaTime):
     curVelocity = vehicle.filter.velocity
     acceleration = vehicle.filter.acceleration
     acceleration = self.__accelerationFilter.add(acceleration)
     movementFlags = vehicle.engineMode[1]
     moveMask = 3
     self.__hasChangedDirection = movementFlags & moveMask ^ self.__prevMovementFlags & moveMask or curVelocity.dot(self.__prevVelocity) <= 0.01
     self.__prevMovementFlags = movementFlags
     self.__prevVelocity = curVelocity
     self.__timeLapsedSinceDirChange += deltaTime
     if self.__hasChangedDirection:
         self.__timeLapsedSinceDirChange = 0.0
     elif self.__timeLapsedSinceDirChange > self.__maxAccelerationDuration:
         invVehMat = Matrix(vehicle.matrix)
         invVehMat.invert()
         accelerationRelativeToVehicle = invVehMat.applyVector(acceleration)
         accelerationRelativeToVehicle.x = 0.0
         accelerationRelativeToVehicle.z = 0.0
         acceleration = Matrix(vehicle.matrix).applyVector(accelerationRelativeToVehicle)
     self.__acceleration = acceleration
     return acceleration
    def checkTurretDetachment(self, worldPos):
        if self.__vehicle is None:
            return
        elif self.__vehicle.isTurretDetached and not self.__placement == _VehicleBounder.SELECT_DETACHED_TURRET:
            turretFound = None
            for turret in DetachedTurret.allTurrets:
                if turret.vehicleID == self.__vehicle.id and turret.model.visible:
                    turretFound = turret
                    break

            if turretFound is None:
                return
            turretToGoalShift = worldPos - turretFound.position
            toTurretMat = Matrix(turretFound.matrix)
            toTurretMat.invert()
            turretToGoalShift = toTurretMat.applyVector(turretToGoalShift)
            self.matrix = turretFound.matrix
            self.__lookAtProvider = None
            self.__placement = _VehicleBounder.SELECT_DETACHED_TURRET
            return turretToGoalShift
        else:
            return
Exemple #24
0
    def collideSegment(self, startPoint, endPoint, skipGun=False):
        res = None
        filterMethod = getattr(self.filter, 'segmentMayHitEntity',
                               lambda: True)
        if not filterMethod(startPoint, endPoint, 0):
            return res
        modelsToCheck = (self.model, ) if skipGun else (self.model,
                                                        self.__gunModel)
        for model, desc in zip(modelsToCheck, self.__componentsDesc):
            toModel = Matrix(model.matrix)
            toModel.invert()
            collisions = desc['hitTester'].localHitTest(
                toModel.applyPoint(startPoint), toModel.applyPoint(endPoint))
            if collisions is None:
                continue
            for dist, _, hitAngleCos, matKind in collisions:
                if res is None or res.dist >= dist:
                    matInfo = desc['materials'].get(matKind)
                    res = SegmentCollisionResult(
                        dist, hitAngleCos,
                        matInfo.armor if matInfo is not None else 0)

        return res
 def __worldYawPitchToTurret(self, worldYaw, worldPitch):
     worldToTurret = Matrix(self.__vehicleMProv)
     worldToTurret.invert()
     worldToTurret.preMultiply(
         mathUtils.createRotationMatrix((worldYaw, worldPitch, 0.0)))
     return (worldToTurret.yaw, worldToTurret.pitch)
 def __worldYawPitchToTurret(self, worldYaw, worldPitch):
     worldToTurret = Matrix(self.__vehicleMProv)
     worldToTurret.invert()
     worldToTurret.preMultiply(mathUtils.createRotationMatrix((worldYaw, worldPitch, 0.0)))
     return (worldToTurret.yaw, worldToTurret.pitch)
Exemple #27
0
 def setViewMatrix(self, matrix):
     invMatrix = Matrix(matrix)
     invMatrix.invert()
     self.__position = invMatrix.translation
     self.__ypr = Vector3(invMatrix.yaw, invMatrix.pitch, invMatrix.roll)
Exemple #28
0
 def __cameraUpdate(self, allowModeChange=True):
     curTime = BigWorld.time()
     deltaTime = curTime - self.__prevTime
     self.__prevTime = curTime
     if not self.__autoUpdateDxDyDz.x == self.__autoUpdateDxDyDz.y == self.__autoUpdateDxDyDz.z == 0.0:
         self.__rotateAndZoom(self.__autoUpdateDxDyDz.x,
                              self.__autoUpdateDxDyDz.y,
                              self.__autoUpdateDxDyDz.z)
     self.__aimingSystem.update(deltaTime)
     localTransform, impulseTransform = self.__updateOscillators(deltaTime)
     player = BigWorld.player()
     vehicle = player.getVehicleAttached()
     zoom = self.__zoom
     if self.__isRemoteCamera and vehicle is not None:
         camMat = self.__getRemoteAim(allowModeChange)
         if camMat is None:
             return 0.0
         zoom = float(player.remoteCameraSniper.zoom)
     else:
         aimMatrix = cameras.getAimMatrix(self.__defaultAimOffset.x,
                                          self.__defaultAimOffset.y)
         camMat = Matrix(aimMatrix)
         rodMat = mathUtils.createTranslationMatrix(
             -self.__dynamicCfg['pivotShift'])
         antiRodMat = mathUtils.createTranslationMatrix(
             self.__dynamicCfg['pivotShift'])
         camMat.postMultiply(rodMat)
         camMat.postMultiply(localTransform)
         camMat.postMultiply(antiRodMat)
         camMat.postMultiply(self.__aimingSystem.matrix)
         camMat.invert()
     if not player.isObserver() and vehicle is not None:
         relTranslation = self.__cam.position - vehicle.position
         rot = Math.Vector3(camMat.yaw, camMat.pitch, camMat.roll)
         vehicle.setSniperCameraDataForObservers(relTranslation, rot, zoom)
     self.__cam.set(camMat)
     if zoom != self.__zoom:
         self.__zoom = zoom
         self.__applyZoom(self.__zoom)
     replayCtrl = BattleReplay.g_replayCtrl
     if replayCtrl.isPlaying and replayCtrl.isControllingCamera:
         aimOffset = replayCtrl.getAimClipPosition()
         binocularsOffset = aimOffset
         if not BigWorld.player().isForcedGuiControlMode() and GUI.mcursor(
         ).inFocus:
             GUI.mcursor().position = aimOffset
     else:
         aimOffset = self.__calcAimOffset(impulseTransform)
         binocularsOffset = self.__calcAimOffset()
         if replayCtrl.isRecording:
             replayCtrl.setAimClipPosition(aimOffset)
     self.__aimOffset = aimOffset
     self.__binoculars.setMaskCenter(binocularsOffset.x, binocularsOffset.y)
     if not self.__isRemoteCamera and allowModeChange and (
             self.__isPositionUnderwater(
                 self.__aimingSystem.matrix.translation)
             or player.isGunLocked):
         self.__onChangeControlMode(False)
         return -1
     else:
         return 0.0
 def setViewMatrix(self, matrix):
     invMatrix = Matrix(matrix)
     invMatrix.invert()
     self.__position = invMatrix.translation
     self.__ypr = Vector3(invMatrix.yaw, invMatrix.pitch, invMatrix.roll)