示例#1
0
 def __readCfg(self, dataSec):
     if not dataSec:
         LOG_WARNING('Invalid section <sniperMode/camera> in avatar_input_handler.xml')
     self.__baseCfg = dict()
     bcfg = self.__baseCfg
     bcfg['keySensitivity'] = readFloat(dataSec, 'keySensitivity', 0, 10, 0.005)
     bcfg['sensitivity'] = readFloat(dataSec, 'sensitivity', 0, 10, 0.005)
     bcfg['scrollSensitivity'] = readFloat(dataSec, 'scrollSensitivity', 0, 10, 0.005)
     zooms = dataSec.readString('zooms', '2 4 8 16 25')
     bcfg['zooms'] = [ float(x) for x in zooms.split() ]
     ds = Settings.g_instance.userPrefs[Settings.KEY_CONTROL_MODE]
     if ds is not None:
         ds = ds['sniperMode/camera']
     self.__userCfg = dict()
     ucfg = self.__userCfg
     ucfg['horzInvert'] = g_settingsCore.getSetting('mouseHorzInvert')
     ucfg['vertInvert'] = g_settingsCore.getSetting('mouseVertInvert')
     ucfg['increasedZoom'] = g_settingsCore.getSetting('increasedZoom')
     maxZoom = bcfg['zooms'][-1] if ucfg['increasedZoom'] else bcfg['zooms'][:3][-1]
     ucfg['zoom'] = readFloat(ds, 'zoom', 0.0, maxZoom, bcfg['zooms'][0])
     ucfg['sniperModeByShift'] = g_settingsCore.getSetting('sniperModeByShift')
     ucfg['keySensitivity'] = readFloat(ds, 'keySensitivity', 0.0, 10.0, 1.0)
     ucfg['sensitivity'] = readFloat(ds, 'sensitivity', 0.0, 10.0, 1.0)
     ucfg['scrollSensitivity'] = readFloat(ds, 'scrollSensitivity', 0.0, 10.0, 1.0)
     self.__cfg = dict()
     cfg = self.__cfg
     cfg['keySensitivity'] = bcfg['keySensitivity']
     cfg['sensitivity'] = bcfg['sensitivity']
     cfg['scrollSensitivity'] = bcfg['scrollSensitivity']
     cfg['zooms'] = bcfg['zooms']
     cfg['keySensitivity'] *= ucfg['keySensitivity']
     cfg['sensitivity'] *= ucfg['sensitivity']
     cfg['scrollSensitivity'] *= ucfg['scrollSensitivity']
     cfg['horzInvert'] = ucfg['horzInvert']
     cfg['vertInvert'] = ucfg['vertInvert']
     cfg['zoom'] = ucfg['zoom']
     cfg['increasedZoom'] = ucfg['increasedZoom']
     cfg['sniperModeByShift'] = ucfg['sniperModeByShift']
     dynamicsSection = dataSec['dynamics']
     self.__impulseOscillator = createOscillatorFromSection(dynamicsSection['impulseOscillator'])
     self.__movementOscillator = createOscillatorFromSection(dynamicsSection['movementOscillator'])
     self.__noiseOscillator = createOscillatorFromSection(dynamicsSection['randomNoiseOscillatorSpherical'])
     self.__dynamicCfg.readImpulsesConfig(dynamicsSection)
     self.__dynamicCfg['accelerationSensitivity'] = readVec3(dynamicsSection, 'accelerationSensitivity', (-1000, -1000, -1000), (1000, 1000, 1000), (0.5, 0.5, 0.5))
     accelerationThreshold = readFloat(dynamicsSection, 'accelerationThreshold', 0.0, 1000.0, 0.1)
     self.__dynamicCfg['accelerationThreshold'] = accelerationThreshold
     self.__dynamicCfg['accelerationMax'] = readFloat(dynamicsSection, 'accelerationMax', 0.0, 1000.0, 0.1)
     self.__dynamicCfg['maxShotImpulseDistance'] = readFloat(dynamicsSection, 'maxShotImpulseDistance', 0.0, 1000.0, 10.0)
     self.__dynamicCfg['maxExplosionImpulseDistance'] = readFloat(dynamicsSection, 'maxExplosionImpulseDistance', 0.0, 1000.0, 10.0)
     self.__dynamicCfg['impulsePartToRoll'] = readFloat(dynamicsSection, 'impulsePartToRoll', 0.0, 1000.0, 0.3)
     self.__dynamicCfg['pivotShift'] = Vector3(0, readFloat(dynamicsSection, 'pivotShift', -1000, 1000, -0.5), 0)
     self.__dynamicCfg['aimMarkerDistance'] = readFloat(dynamicsSection, 'aimMarkerDistance', -1000, 1000, 1.0)
     rawZoomExposure = dynamicsSection.readString('zoomExposure', '0.6 0.5 0.4 0.3 0.2')
     self.__dynamicCfg['zoomExposure'] = [ float(x) for x in rawZoomExposure.split() ]
     accelerationFilter = mathUtils.RangeFilter(self.__dynamicCfg['accelerationThreshold'], self.__dynamicCfg['accelerationMax'], 100, mathUtils.SMAFilter(SniperCamera._FILTER_LENGTH))
     maxAccelerationDuration = readFloat(dynamicsSection, 'maxAccelerationDuration', 0.0, 10000.0, SniperCamera._DEFAULT_MAX_ACCELERATION_DURATION)
     self.__accelerationSmoother = AccelerationSmoother(accelerationFilter, maxAccelerationDuration)
     return
示例#2
0
 def __readCfg(self, dataSec):
     if not dataSec:
         LOG_WARNING('Invalid section <strategicMode/camera> in avatar_input_handler.xml')
     self.__baseCfg = dict()
     bcfg = self.__baseCfg
     bcfg['keySensitivity'] = readFloat(dataSec, 'keySensitivity', 0.005, 10, 0.025)
     bcfg['sensitivity'] = readFloat(dataSec, 'sensitivity', 0.005, 10, 0.025)
     bcfg['scrollSensitivity'] = readFloat(dataSec, 'scrollSensitivity', 0.005, 10, 0.025)
     bcfg['distRange'] = readVec2(dataSec, 'distRange', (1, 1), (10000, 10000), (2, 30))
     ds = Settings.g_instance.userPrefs[Settings.KEY_CONTROL_MODE]
     if ds is not None:
         ds = ds['strategicMode/camera']
     self.__userCfg = dict()
     ucfg = self.__userCfg
     from account_helpers.settings_core.SettingsCore import g_settingsCore
     ucfg['horzInvert'] = g_settingsCore.getSetting('mouseHorzInvert')
     ucfg['vertInvert'] = g_settingsCore.getSetting('mouseVertInvert')
     ucfg['keySensitivity'] = readFloat(ds, 'keySensitivity', 0.0, 10.0, 1.0)
     ucfg['sensitivity'] = readFloat(ds, 'sensitivity', 0.0, 10.0, 1.0)
     ucfg['scrollSensitivity'] = readFloat(ds, 'scrollSensitivity', 0.0, 10.0, 1.0)
     ucfg['camDist'] = readFloat(ds, 'camDist', 0.0, 60.0, 0)
     self.__cfg = dict()
     cfg = self.__cfg
     cfg['keySensitivity'] = bcfg['keySensitivity']
     cfg['sensitivity'] = bcfg['sensitivity']
     cfg['scrollSensitivity'] = bcfg['scrollSensitivity']
     cfg['distRange'] = bcfg['distRange']
     cfg['camDist'] = ucfg['camDist']
     cfg['keySensitivity'] *= ucfg['keySensitivity']
     cfg['sensitivity'] *= ucfg['sensitivity']
     cfg['scrollSensitivity'] *= ucfg['scrollSensitivity']
     cfg['horzInvert'] = ucfg['horzInvert']
     cfg['vertInvert'] = ucfg['vertInvert']
     dynamicsSection = dataSec['dynamics']
     self.__dynamicCfg.readImpulsesConfig(dynamicsSection)
     self.__positionOscillator = createOscillatorFromSection(dynamicsSection['oscillator'], False)
     self.__positionNoiseOscillator = createOscillatorFromSection(dynamicsSection['randomNoiseOscillatorFlat'], False)
示例#3
0
 def __readCfg(self, dataSec):
     if dataSec is None:
         LOG_WARNING('Invalid section <arcadeMode/camera> in avatar_input_handler.xml')
     self.__baseCfg = dict()
     bcfg = self.__baseCfg
     bcfg['keySensitivity'] = readFloat(dataSec, 'keySensitivity', 0, 10, 0.01)
     bcfg['sensitivity'] = readFloat(dataSec, 'sensitivity', 0, 10, 0.01)
     bcfg['scrollSensitivity'] = readFloat(dataSec, 'scrollSensitivity', 0, 10, 0.01)
     bcfg['angleRange'] = readVec2(dataSec, 'angleRange', (0, 0), (180, 180), (10, 110))
     distRangeVec = readVec2(dataSec, 'distRange', (1, 1), (100, 100), (2, 20))
     bcfg['distRange'] = MinMax(distRangeVec.x, distRangeVec.y)
     bcfg['minStartDist'] = readFloat(dataSec, 'minStartDist', bcfg['distRange'][0], bcfg['distRange'][1], bcfg['distRange'][0])
     bcfg['optimalStartDist'] = readFloat(dataSec, 'optimalStartDist', bcfg['distRange'][0], bcfg['distRange'][1], bcfg['distRange'][0])
     bcfg['angleRange'][0] = math.radians(bcfg['angleRange'][0]) - math.pi * 0.5
     bcfg['angleRange'][1] = math.radians(bcfg['angleRange'][1]) - math.pi * 0.5
     bcfg['fovMultMinMaxDist'] = MinMax(readFloat(dataSec, 'fovMultMinDist', 0.1, 100, 1.0), readFloat(dataSec, 'fovMultMaxDist', 0.1, 100, 1.0))
     ds = Settings.g_instance.userPrefs[Settings.KEY_CONTROL_MODE]
     if ds is not None:
         ds = ds['arcadeMode/camera']
     self.__userCfg = dict()
     ucfg = self.__userCfg
     from account_helpers.settings_core.SettingsCore import g_settingsCore
     ucfg['horzInvert'] = g_settingsCore.getSetting('mouseHorzInvert')
     ucfg['vertInvert'] = g_settingsCore.getSetting('mouseVertInvert')
     ucfg['sniperModeByShift'] = g_settingsCore.getSetting('sniperModeByShift')
     ucfg['keySensitivity'] = readFloat(ds, 'keySensitivity', 0.0, 10.0, 1.0)
     ucfg['sensitivity'] = readFloat(ds, 'sensitivity', 0.0, 10.0, 1.0)
     ucfg['scrollSensitivity'] = readFloat(ds, 'scrollSensitivity', 0.0, 10.0, 1.0)
     ucfg['startDist'] = readFloat(ds, 'startDist', bcfg['distRange'][0], 500, bcfg['optimalStartDist'])
     if ucfg['startDist'] < bcfg['minStartDist']:
         ucfg['startDist'] = bcfg['optimalStartDist']
     ucfg['startAngle'] = readFloat(ds, 'startAngle', 5, 180, 60)
     ucfg['startAngle'] = math.radians(ucfg['startAngle']) - math.pi * 0.5
     ucfg['fovMultMinMaxDist'] = MinMax(readFloat(ds, 'fovMultMinDist', 0.1, 100, bcfg['fovMultMinMaxDist'].min), readFloat(ds, 'fovMultMaxDist', 0.1, 100, bcfg['fovMultMinMaxDist'].max))
     self.__cfg = dict()
     cfg = self.__cfg
     cfg['keySensitivity'] = bcfg['keySensitivity']
     cfg['sensitivity'] = bcfg['sensitivity']
     cfg['scrollSensitivity'] = bcfg['scrollSensitivity']
     cfg['angleRange'] = bcfg['angleRange']
     cfg['distRange'] = bcfg['distRange']
     cfg['minStartDist'] = bcfg['minStartDist']
     cfg['horzInvert'] = ucfg['horzInvert']
     cfg['vertInvert'] = ucfg['vertInvert']
     cfg['keySensitivity'] *= ucfg['keySensitivity']
     cfg['sensitivity'] *= ucfg['sensitivity']
     cfg['scrollSensitivity'] *= ucfg['scrollSensitivity']
     cfg['startDist'] = ucfg['startDist']
     cfg['startAngle'] = ucfg['startAngle']
     cfg['fovMultMinMaxDist'] = ucfg['fovMultMinMaxDist']
     cfg['sniperModeByShift'] = ucfg['sniperModeByShift']
     enableShift = dataSec.readBool('shift', False)
     if enableShift:
         movementMappings = dict()
         movementMappings[Keys.KEY_A] = Math.Vector3(-1, 0, 0)
         movementMappings[Keys.KEY_D] = Math.Vector3(1, 0, 0)
         movementMappings[Keys.KEY_Q] = Math.Vector3(0, 1, 0)
         movementMappings[Keys.KEY_E] = Math.Vector3(0, -1, 0)
         movementMappings[Keys.KEY_W] = Math.Vector3(0, 0, 1)
         movementMappings[Keys.KEY_S] = Math.Vector3(0, 0, -1)
         shiftSensitivity = dataSec.readFloat('shiftSensitivity', 0.5)
         self.__shiftKeySensor = KeySensor(movementMappings, shiftSensitivity)
         self.__shiftKeySensor.reset(Math.Vector3())
     dynamicsSection = dataSec['dynamics']
     self.__impulseOscillator = createOscillatorFromSection(dynamicsSection['impulseOscillator'], False)
     self.__movementOscillator = createOscillatorFromSection(dynamicsSection['movementOscillator'], False)
     self.__movementOscillator = CompoundOscillator(self.__movementOscillator, Oscillator(1.0, Vector3(50), Vector3(20), Vector3(0.01, 0.0, 0.01)))
     self.__noiseOscillator = createOscillatorFromSection(dynamicsSection['randomNoiseOscillatorSpherical'])
     self.__dynamicCfg.readImpulsesConfig(dynamicsSection)
     self.__dynamicCfg['accelerationSensitivity'] = readFloat(dynamicsSection, 'accelerationSensitivity', -1000, 1000, 0.1)
     self.__dynamicCfg['frontImpulseToPitchRatio'] = math.radians(readFloat(dynamicsSection, 'frontImpulseToPitchRatio', -1000, 1000, 0.1))
     self.__dynamicCfg['sideImpulseToRollRatio'] = math.radians(readFloat(dynamicsSection, 'sideImpulseToRollRatio', -1000, 1000, 0.1))
     self.__dynamicCfg['sideImpulseToYawRatio'] = math.radians(readFloat(dynamicsSection, 'sideImpulseToYawRatio', -1000, 1000, 0.1))
     accelerationThreshold = readFloat(dynamicsSection, 'accelerationThreshold', 0.0, 1000.0, 0.1)
     self.__dynamicCfg['accelerationThreshold'] = accelerationThreshold
     self.__dynamicCfg['accelerationMax'] = readFloat(dynamicsSection, 'accelerationMax', 0.0, 1000.0, 0.1)
     self.__dynamicCfg['maxShotImpulseDistance'] = readFloat(dynamicsSection, 'maxShotImpulseDistance', 0.0, 1000.0, 10.0)
     self.__dynamicCfg['maxExplosionImpulseDistance'] = readFloat(dynamicsSection, 'maxExplosionImpulseDistance', 0.0, 1000.0, 10.0)
     self.__dynamicCfg['zoomExposure'] = readFloat(dynamicsSection, 'zoomExposure', 0.0, 1000.0, 0.25)
     accelerationFilter = mathUtils.RangeFilter(self.__dynamicCfg['accelerationThreshold'], self.__dynamicCfg['accelerationMax'], 100, mathUtils.SMAFilter(ArcadeCamera._FILTER_LENGTH))
     maxAccelerationDuration = readFloat(dynamicsSection, 'maxAccelerationDuration', 0.0, 10000.0, ArcadeCamera._DEFAULT_MAX_ACCELERATION_DURATION)
     self.__accelerationSmoother = AccelerationSmoother(accelerationFilter, maxAccelerationDuration)
     self.__inputInertia = _InputInertia(self.__cfg['fovMultMinMaxDist'], 0.0)
     advancedCollision = dataSec['advancedCollision']
     if advancedCollision is None:
         LOG_ERROR('<advancedCollision> dataSection is not found!')
     else:
         BigWorld.setAdvancedColliderConstants(AdvancedColliderConstants.fromSection(advancedCollision), cfg['distRange'][0])
     return