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))
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))
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 apply(vDesc, modelDesc, modelsSet): for key in chassis_params: obj = copy.deepcopy(modelDesc['chassis'][key]) if key == 'traces': obj['size'] = tuple(obj['size']) obj = cc.Traces(**obj) elif key == 'tracks': obj = cc.TrackBasicParams(**obj) elif key == 'wheels': obj = cc.WheelsConfig(groups=tuple(cc.WheelGroup(**d) for d in obj['groups']), wheels=tuple(cc.Wheel(**d) for d in obj['wheels'])) elif key == 'groundNodes': obj = NodesAndGroups(nodes=tuple(cc.GroundNode(**d) for d in obj['nodes']), groups=tuple(cc.GroundNodeGroup(**d) for d in obj['groups']), activePostmortem=obj['activePostmortem'], lodSettings=obj['lodSettings']) elif key == 'trackNodes': obj = NodesAndGroups(nodes=tuple(cc.TrackNode(**d) for d in obj['nodes']), groups=(), activePostmortem=obj['activePostmortem'], lodSettings=obj['lodSettings']) elif key == 'splineDesc': obj = cc.SplineConfig(({modelsSet: cc.SplineSegmentModelSet(**obj['segmentModelSets'])} or None), **{k: v for k, v in obj.items() if k != 'segmentModelSets'}) elif key == 'trackSplineParams': obj = cc.TrackSplineParams(**obj) elif key == 'leveredSuspension': if obj is not None: obj = cc.LeveredSuspensionConfig(([cc.SuspensionLever(**d) for d in obj['levers']] or None), **{k: v for k, v in obj.items() if k != 'levers'}) setattr(vDesc.chassis, key, obj) vDesc.chassis.chassisLodDistance = modelDesc['chassis']['chassisLodDistance'] vDesc.chassis.physicalTracks = {} if modelDesc['chassis']['AODecals']: AODecalsOffset = vDesc.chassis.hullPosition - Math.Vector3(*modelDesc['chassis']['hullPosition']) vDesc.chassis.AODecals = copy.deepcopy(modelDesc['chassis']['AODecals']) vDesc.chassis.AODecals[0].setElement(3, 1, AODecalsOffset.y) exclMask = modelDesc['common']['camouflage']['exclusionMask'] vDesc.type.camouflage = Camouflage( modelDesc['common']['camouflage']['tiling'] if exclMask else vDesc.type.camouflage.tiling, exclMask, None, None) for partName in TankPartNames.ALL: part = getattr(vDesc, partName) models = part.modelsSets[modelsSet] part.modelsSets[modelsSet] = ModelStatesPaths(modelDesc[partName]['undamaged'], models.destroyed, models.exploded) part.models = part.modelsSets['default'] part.emblemSlots = tuple(modelDesc[partName]['emblemSlots']) if partName == 'chassis': continue camoData = modelDesc[partName]['camouflage'] exclMask = camoData['exclusionMask'] if exclMask: part.camouflage = Camouflage(camoData['tiling'], exclMask, None, None) vDesc.gun.drivenJoints = modelDesc['gun']['drivenJoints'] exhaust = modelDesc['hull']['exhaust'] for effectDesc in vDesc.hull.customEffects: if exhaust['nodes']: effectDesc.nodes[:] = exhaust['nodes'] effectDesc._selectorDesc = g_cache._customEffects['exhaust'].get(exhaust['pixie'], effectDesc._selectorDesc) nationID = vDesc.type.id[0] for partName, cacheName, cacheIDs in ( ('chassis', 'chassis', 'chassisIDs'), ('engine', 'engines', 'engineIDs'), ('gun', 'guns', 'gunIDs')): soundID = modelDesc[partName].get('soundID') if soundID: part = getattr(vDesc, partName) pickFrom = getattr(g_cache, cacheName)(nationID).get(getattr(g_cache, cacheIDs)(nationID).get(soundID)) if pickFrom is not None: if partName != 'gun': part.sounds = pickFrom.sounds else: part.effects = pickFrom.effects part.reloadEffect = pickFrom.reloadEffect
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))