Example #1
0
def readSplineConfig(xmlCtx, section, cache):
    """Reads levered suspension section.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :param cache: instance of vehicles.Cache.
    :return: instance of SplineConfig or None.
    """
    if section['splineDesc'] is None:
        return
    else:
        return chassis_components.SplineConfig(
            segmentModelLeft=_xml.readNonEmptyString(
                xmlCtx, section, 'splineDesc/segmentModelLeft'),
            segmentModelRight=_xml.readNonEmptyString(
                xmlCtx, section, 'splineDesc/segmentModelRight'),
            segmentLength=_xml.readFloat(xmlCtx, section,
                                         'splineDesc/segmentLength'),
            leftDesc=_xml.readStringOrNone(xmlCtx, section, 'splineDesc/left'),
            rightDesc=_xml.readStringOrNone(xmlCtx, section,
                                            'splineDesc/right'),
            lodDist=shared_readers.readLodDist(xmlCtx, section,
                                               'splineDesc/lodDist', cache),
            segmentOffset=section.readFloat('splineDesc/segmentOffset', 0),
            segment2ModelLeft=_xml.readStringOrNone(
                xmlCtx, section, 'splineDesc/segment2ModelLeft'),
            segment2ModelRight=_xml.readStringOrNone(
                xmlCtx, section, 'splineDesc/segment2ModelRight'),
            segment2Offset=section.readFloat('splineDesc/segment2Offset', 0),
            atlasUTiles=section.readInt('splineDesc/atlas/UTiles', 1),
            atlasVTiles=section.readInt('splineDesc/atlas/VTiles', 1))
Example #2
0
def readRecoilEffect(xmlCtx, section, cache):
    effName = _xml.readStringOrNone(xmlCtx, section, 'recoil/recoilEffect')
    if effName is not None:
        recoilEff = cache.getGunRecoilEffects(effName)
        if recoilEff is not None:
            backoffTime = recoilEff[0]
            returnTime = recoilEff[1]
        else:
            backoffTime = component_constants.ZERO_FLOAT
            returnTime = component_constants.ZERO_FLOAT
    else:
        backoffTime = _xml.readNonNegativeFloat(xmlCtx, section,
                                                'recoil/backoffTime')
        returnTime = _xml.readNonNegativeFloat(xmlCtx, section,
                                               'recoil/returnTime')
    recoil = gun_components.RecoilEffect(
        lodDist=shared_readers.readLodDist(xmlCtx, section, 'recoil/lodDist',
                                           cache),
        amplitude=_xml.readNonNegativeFloat(xmlCtx, section,
                                            'recoil/amplitude'),
        backoffTime=backoffTime,
        returnTime=returnTime)
    if IS_EDITOR:
        recoil.effectName = effName
    return recoil
Example #3
0
def readRecoilEffect(xmlCtx, section, cache):
    """Reads configuration of gun recoil effect.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :param cache: instance of vehicles.Cache to get desired LoD distance by name.
    :return: instance of RecoilEffect.
    """
    effName = _xml.readStringOrNone(xmlCtx, section, 'recoil/recoilEffect')
    if effName is not None:
        recoilEff = cache.getGunRecoilEffects(effName)
        if recoilEff is not None:
            backoffTime = recoilEff[0]
            returnTime = recoilEff[1]
        else:
            backoffTime = component_constants.ZERO_FLOAT
            returnTime = component_constants.ZERO_FLOAT
    else:
        backoffTime = _xml.readNonNegativeFloat(xmlCtx, section,
                                                'recoil/backoffTime')
        returnTime = _xml.readNonNegativeFloat(xmlCtx, section,
                                               'recoil/returnTime')
    return gun_components.RecoilEffect(
        lodDist=shared_readers.readLodDist(xmlCtx, section, 'recoil/lodDist',
                                           cache),
        amplitude=_xml.readNonNegativeFloat(xmlCtx, section,
                                            'recoil/amplitude'),
        backoffTime=backoffTime,
        returnTime=returnTime)
Example #4
0
def readTrackMaterials(xmlCtx, section, cache):
    return chassis_components.TrackMaterials(
        lodDist=shared_readers.readLodDist(xmlCtx, section, 'tracks/lodDist',
                                           cache),
        leftMaterial=intern(
            _xml.readNonEmptyString(xmlCtx, section, 'tracks/leftMaterial')),
        rightMaterial=intern(
            _xml.readNonEmptyString(xmlCtx, section, 'tracks/rightMaterial')),
        textureScale=_xml.readFloat(xmlCtx, section, 'tracks/textureScale'))
Example #5
0
def readTraces(xmlCtx, section, centerOffset, cache):
    return chassis_components.Traces(
        lodDist=shared_readers.readLodDist(xmlCtx, section, 'traces/lodDist',
                                           cache),
        bufferPrefs=intern(
            _xml.readNonEmptyString(xmlCtx, section, 'traces/bufferPrefs')),
        textureSet=intern(
            _xml.readNonEmptyString(xmlCtx, section, 'traces/textureSet')),
        centerOffset=centerOffset,
        size=_xml.readPositiveVector2(xmlCtx, section, 'traces/size'))
def readTrackBasicParams(xmlCtx, section, cache):
    tracksSection = section['tracks']
    return None if tracksSection is None else chassis_components.TrackBasicParams(
        lodDist=shared_readers.readLodDist(xmlCtx, section, 'tracks/lodDist',
                                           cache),
        leftMaterial=intern(
            _xml.readNonEmptyString(xmlCtx, section, 'tracks/leftMaterial')),
        rightMaterial=intern(
            _xml.readNonEmptyString(xmlCtx, section, 'tracks/rightMaterial')),
        textureScale=_xml.readFloat(xmlCtx, section, 'tracks/textureScale'),
        pairsCount=section.readInt('tracks/pairsCount', 1))
Example #7
0
def readSplineConfig(xmlCtx, section, cache):
    if not section.has_key('splineDesc'):
        return None
    else:
        trackPairs = {}
        for sname, subsection in _xml.getChildren(xmlCtx, section, 'splineDesc'):
            if sname == 'trackPair':
                ctx = (xmlCtx, 'splineDesc/trackPair')
                desc = readSplineTrackPairDesc(ctx, subsection, cache)
                trackPairs[desc.trackPairIdx] = desc

        if not trackPairs:
            trackPairs[component_constants.MAIN_TRACK_PAIR_IDX] = readSplineTrackPairDesc((xmlCtx, 'splineDesc'), section['splineDesc'], cache)
        return chassis_components.SplineConfig(trackPairs, shared_readers.readLodDist(xmlCtx, section, 'splineDesc/lodDist', cache))
Example #8
0
def readTrackMaterials(xmlCtx, section, cache):
    """Reads section 'tracks' for each chassis to fetch configuration of materials.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :param cache: instance of vehicles.Cache.
    :return: instance of TrackMaterials.
    """
    return chassis_components.TrackMaterials(
        lodDist=shared_readers.readLodDist(xmlCtx, section, 'tracks/lodDist',
                                           cache),
        leftMaterial=_xml.readNonEmptyString(xmlCtx, section,
                                             'tracks/leftMaterial'),
        rightMaterial=_xml.readNonEmptyString(xmlCtx, section,
                                              'tracks/rightMaterial'),
        textureScale=_xml.readFloat(xmlCtx, section, 'tracks/textureScale'))
Example #9
0
def readTrackBasicParams(xmlCtx, section, cache):
    tracksSection = section['tracks']
    if tracksSection is None:
        return
    else:
        trackPairs = {}
        for sname, subsection in _xml.getChildren(xmlCtx, section, 'tracks'):
            if sname == 'trackPair':
                ctx = (xmlCtx, 'tracks/trackPair')
                idx = _xml.readInt(ctx, subsection, 'trackPairIdx')
                trackPairs[idx] = chassis_components.TrackPairParams(leftMaterial=intern(_xml.readNonEmptyString(ctx, subsection, 'leftMaterial')), rightMaterial=intern(_xml.readNonEmptyString(ctx, subsection, 'rightMaterial')), textureScale=_xml.readFloat(ctx, subsection, 'textureScale'), tracksDebris=__readDebrisParams(ctx, subsection, cache))

        if len(trackPairs) == 0:
            trackPairs[component_constants.MAIN_TRACK_PAIR_IDX] = chassis_components.TrackPairParams(leftMaterial=intern(_xml.readNonEmptyString(xmlCtx, section, 'tracks/leftMaterial')), rightMaterial=intern(_xml.readNonEmptyString(xmlCtx, section, 'tracks/rightMaterial')), textureScale=_xml.readFloat(xmlCtx, section, 'tracks/textureScale'), tracksDebris=__readDebrisParams(xmlCtx, section['tracks'], cache))
        return chassis_components.TrackBasicVisualParams(lodDist=shared_readers.readLodDist(xmlCtx, section, 'tracks/lodDist', cache), trackPairs=trackPairs)
def readHullAimingSound(xmlCtx, section, cache):
    if section['hullAiming'] is None:
        return
    else:
        try:
            lodDist = shared_readers.readLodDist(xmlCtx, section,
                                                 'hullAiming/audio/lodDist',
                                                 cache)
            angleLimit = math.radians(
                _xml.readFloat(xmlCtx, section,
                               'hullAiming/audio/angleLimitValue',
                               component_constants.ZERO_FLOAT))
            sounds = []
            for actionName, actionSection in _xml.getChildren(
                    xmlCtx, section, 'hullAiming/audio/sounds'):
                ctx = (xmlCtx, 'hullAiming/audio/sounds')
                underLimitSouns = sound_components.SoundPair(
                    PC=intern(
                        _xml.readNonEmptyString(ctx, actionSection,
                                                'underLimitSounds/wwsoundPC')),
                    NPC=intern(
                        _xml.readNonEmptyString(
                            ctx, actionSection,
                            'underLimitSounds/wwsoundNPC')))
                overLimitSounds = sound_components.SoundPair(
                    PC=intern(
                        _xml.readNonEmptyString(ctx, actionSection,
                                                'overLimitSounds/wwsoundPC')),
                    NPC=intern(
                        _xml.readNonEmptyString(ctx, actionSection,
                                                'overLimitSounds/wwsoundNPC')))
                sound = sound_components.StatedSounds(
                    state=actionName,
                    underLimitSounds=underLimitSouns,
                    overLimitSounds=overLimitSounds)
                sounds.append(sound)

            hullAimingSound = sound_components.HullAimingSound(
                lodDist=lodDist,
                angleLimitValue=_xml.cachedFloat(angleLimit),
                sounds=sounds)
            return hullAimingSound
        except:
            LOG_DEBUG('Incorrect hullAiming/audio section')
            return

        return
Example #11
0
def readTraces(xmlCtx, section, centerOffset, cache):
    """Reads section 'traces' for each chassis.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :param centerOffset: float containing offset by x coordinate.
    :param cache: instance of vehicles.Cache.
    :return: instance of Traces.
    """
    return chassis_components.Traces(
        lodDist=shared_readers.readLodDist(xmlCtx, section, 'traces/lodDist',
                                           cache),
        bufferPrefs=_xml.readNonEmptyString(xmlCtx, section,
                                            'traces/bufferPrefs'),
        textureSet=_xml.readNonEmptyString(xmlCtx, section,
                                           'traces/textureSet'),
        centerOffset=centerOffset,
        size=_xml.readPositiveVector2(xmlCtx, section, 'traces/size'))
Example #12
0
def readSplineConfig(xmlCtx, section, cache):
    return None if section[
        'splineDesc'] is None else chassis_components.SplineConfig(
            segmentModelLeft=_xml.readNonEmptyString(
                xmlCtx, section, 'splineDesc/segmentModelLeft'),
            segmentModelRight=_xml.readNonEmptyString(
                xmlCtx, section, 'splineDesc/segmentModelRight'),
            segmentLength=_xml.readFloat(xmlCtx, section,
                                         'splineDesc/segmentLength'),
            leftDesc=_xml.readStringOrNone(xmlCtx, section, 'splineDesc/left'),
            rightDesc=_xml.readStringOrNone(xmlCtx, section,
                                            'splineDesc/right'),
            lodDist=shared_readers.readLodDist(xmlCtx, section,
                                               'splineDesc/lodDist', cache),
            segmentOffset=_xml.readFloat(xmlCtx, section,
                                         'splineDesc/segmentOffset', 0),
            segment2ModelLeft=_xml.readStringOrNone(
                xmlCtx, section, 'splineDesc/segment2ModelLeft'),
            segment2ModelRight=_xml.readStringOrNone(
                xmlCtx, section, 'splineDesc/segment2ModelRight'),
            segment2Offset=_xml.readFloat(xmlCtx, section,
                                          'splineDesc/segment2Offset', 0),
            atlasUTiles=section.readInt('splineDesc/atlas/UTiles', 1),
            atlasVTiles=section.readInt('splineDesc/atlas/VTiles', 1))
def readSplineConfig(xmlCtx, section, cache):
    if not section.has_key('splineDesc'):
        return
    else:
        splineSegmentModelSets = {
            'default':
            chassis_components.SplineSegmentModelSet(
                left=_xml.readNonEmptyString(xmlCtx, section,
                                             'splineDesc/segmentModelLeft'),
                right=_xml.readNonEmptyString(xmlCtx, section,
                                              'splineDesc/segmentModelRight'),
                secondLeft=_xml.readStringOrNone(
                    xmlCtx, section, 'splineDesc/segment2ModelLeft') or '',
                secondRight=_xml.readStringOrNone(
                    xmlCtx, section, 'splineDesc/segment2ModelRight') or '')
        }
        modelSetsSection = section['splineDesc/modelSets']
        if modelSetsSection:
            for sname, subSection in modelSetsSection.items():
                splineSegmentModelSets[
                    sname] = chassis_components.SplineSegmentModelSet(
                        left=_xml.readNonEmptyString(xmlCtx, subSection,
                                                     'segmentModelLeft'),
                        right=_xml.readNonEmptyString(xmlCtx, subSection,
                                                      'segmentModelRight'),
                        secondLeft=_xml.readStringOrNone(
                            xmlCtx, subSection, 'segment2ModelLeft') or '',
                        secondRight=_xml.readStringOrNone(
                            xmlCtx, subSection, 'segment2ModelRight') or '')

        leftDescs = []
        rightDescs = []
        multipleTracks = section['splineDesc/multipleTracks']
        if multipleTracks is not None:
            for node in multipleTracks.items():
                desc = _xml.readNonEmptyString(xmlCtx, node[1], 'desc')
                pairIdx = _xml.readNonNegativeInt(xmlCtx, node[1],
                                                  'trackPairIdx')
                length = _xml.readFloat(xmlCtx, node[1], 'segmentLength')
                offset = _xml.readFloat(xmlCtx, node[1], 'segmentOffset', 0)
                offset2 = _xml.readFloat(xmlCtx, node[1], 'segment2Offset', 0)
                descList = [desc, pairIdx, length, offset, offset2]
                if node[0] == 'left':
                    leftDescs.append(descList)
                if node[0] == 'right':
                    rightDescs.append(descList)

        else:
            length = _xml.readFloat(xmlCtx, section,
                                    'splineDesc/segmentLength')
            offset = _xml.readFloat(xmlCtx, section,
                                    'splineDesc/segmentOffset', 0)
            offset2 = _xml.readFloat(xmlCtx, section,
                                     'splineDesc/segment2Offset', 0)
            leftTuple = [
                _xml.readStringOrNone(xmlCtx, section, 'splineDesc/left'), 0,
                length, offset, offset2
            ]
            rightTuple = [
                _xml.readStringOrNone(xmlCtx, section, 'splineDesc/right'), 0,
                length, offset, offset2
            ]
            leftDescs.append(leftTuple)
            rightDescs.append(rightTuple)
        return chassis_components.SplineConfig(
            segmentModelSets=splineSegmentModelSets,
            leftDesc=leftDescs,
            rightDesc=rightDescs,
            lodDist=shared_readers.readLodDist(xmlCtx, section,
                                               'splineDesc/lodDist', cache),
            atlasUTiles=section.readInt('splineDesc/atlas/UTiles', 1),
            atlasVTiles=section.readInt('splineDesc/atlas/VTiles', 1))