def readLeveredSuspension(xmlCtx, section, cache): leveredSection = section['leveredSuspension'] if leveredSection is None: return else: levers = [] for sname, subsection in _xml.getChildren(xmlCtx, section, 'leveredSuspension'): if sname != 'lever': continue ctx = (xmlCtx, 'leveredSuspension/lever') limits = _xml.readVector2(ctx, subsection, 'limits') lever = chassis_components.SuspensionLever( startNodeName=intern( _xml.readNonEmptyString(ctx, subsection, 'startNode')), jointNodeName=intern( _xml.readNonEmptyString(ctx, subsection, 'jointNode')), trackNodeName=intern( _xml.readNonEmptyString(ctx, subsection, 'trackNode')), minAngle=math.radians(limits.x), maxAngle=math.radians(limits.y)) levers.append(lever) ctx = (xmlCtx, 'leveredSuspension') leveredSuspensionConfig = chassis_components.LeveredSuspensionConfig( levers=levers, interpolationSpeedMul=_xml.readFloat(ctx, leveredSection, 'interpolationSpeedMul', 10.0), lodSettings=shared_readers.readLodSettings(ctx, leveredSection, cache)) return leveredSuspensionConfig
def readGroundNodesAndGroups(xmlCtx, section, cache): if section['groundNodes'] is None: return (component_constants.EMPTY_TUPLE, component_constants.EMPTY_TUPLE, False, None) else: groundGroups = [] groundNodes = [] for sname, subsection in _xml.getChildren(xmlCtx, section, 'groundNodes'): if sname == 'group': ctx = (xmlCtx, 'groundNodes/group') group = chassis_components.GroundNodeGroup(isLeft=_xml.readBool(ctx, subsection, 'isLeft'), minOffset=_xml.readFloat(ctx, subsection, 'minOffset'), maxOffset=_xml.readFloat(ctx, subsection, 'maxOffset'), nodesTemplate=intern(_xml.readNonEmptyString(ctx, subsection, 'template')), affectedWheelsTemplate=_xml.readStringOrNone(ctx, subsection, 'affectedWheelsTemplate'), nodesCount=_xml.readInt(ctx, subsection, 'count', 1), startIndex=subsection.readInt('startIndex', 0), collisionSamplesCount=subsection.readInt('collisionSamplesCount', 1), hasLiftMode=_xml.readBool(ctx, subsection, 'hasLiftMode', False)) groundGroups.append(group) if sname == 'node': ctx = (xmlCtx, 'groundNodes/node') groundNode = chassis_components.GroundNode(nodeName=intern(_xml.readNonEmptyString(ctx, subsection, 'name')), affectedWheelName=_xml.readStringOrEmpty(ctx, subsection, 'affectedWheelName'), isLeft=_xml.readBool(ctx, subsection, 'isLeft'), minOffset=_xml.readFloat(ctx, subsection, 'minOffset'), maxOffset=_xml.readFloat(ctx, subsection, 'maxOffset'), collisionSamplesCount=_xml.readInt(ctx, subsection, 'collisionSamplesCount', 1), hasLiftMode=_xml.readBool(ctx, subsection, 'hasLiftMode', False)) groundNodes.append(groundNode) activePostmortem = _xml.readBool(xmlCtx, section, 'groundNodes/activePostmortem', False) lodSettingsSection = section['groundNodes/lodSettings'] if lodSettingsSection is not None: lodSettings = shared_readers.readLodSettings(xmlCtx, section['groundNodes'], cache) else: lodSettings = None return (tuple(groundGroups), tuple(groundNodes), activePostmortem, lodSettings)
def readLeveredSuspension(xmlCtx, section, cache): leveredSection = section['leveredSuspension'] if leveredSection is None: return else: levers = [] for sname, subsection in _xml.getChildren(xmlCtx, section, 'leveredSuspension'): if sname != 'lever': continue ctx = (xmlCtx, 'leveredSuspension/lever') limits = _xml.readVector2(ctx, subsection, 'limits') lever = chassis_components.SuspensionLever( startNodeName=intern( _xml.readNonEmptyString(ctx, subsection, 'startNode')), jointNodeName=intern( _xml.readNonEmptyString(ctx, subsection, 'jointNode')), trackNodeName=intern( _xml.readNonEmptyString(ctx, subsection, 'trackNode')), minAngle=math.radians(limits.x), maxAngle=math.radians(limits.y), collisionSamplesCount=subsection.readInt( 'collisionSamplesCount', 1), hasLiftMode=_xml.readBool(ctx, subsection, 'hasLiftMode', False), affectedWheelName=_xml.readStringOrEmpty( ctx, subsection, 'affectedWheelName')) levers.append(lever) ctx = (xmlCtx, 'leveredSuspension') leveredSuspensionConfig = chassis_components.LeveredSuspensionConfig( levers=levers, interpolationSpeedMul=_xml.readFloat(ctx, leveredSection, 'interpolationSpeedMul', 10.0), lodSettings=shared_readers.readLodSettings(ctx, leveredSection, cache), activePostmortem=_xml.readBool(ctx, leveredSection, 'activePostmortem', False)) return leveredSuspensionConfig
def readLeveredSuspension(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 SuspensionLever for levered suspension or None. """ leveredSection = section['leveredSuspension'] if leveredSection is None: return else: levers = [] for sname, subsection in _xml.getChildren(xmlCtx, section, 'leveredSuspension'): if sname != 'lever': continue ctx = (xmlCtx, 'leveredSuspension/lever') limits = _xml.readVector2(ctx, subsection, 'limits') lever = chassis_components.SuspensionLever( startNodeName=_xml.readNonEmptyString(ctx, subsection, 'startNode'), jointNodeName=_xml.readNonEmptyString(ctx, subsection, 'jointNode'), trackNodeName=_xml.readNonEmptyString(ctx, subsection, 'trackNode'), minAngle=math.radians(limits.x), maxAngle=math.radians(limits.y)) levers.append(lever) ctx = (xmlCtx, 'leveredSuspension') leveredSuspensionConfig = chassis_components.LeveredSuspensionConfig( levers=levers, interpolationSpeedMul=leveredSection.readFloat( 'interpolationSpeedMul', 10.0), lodSettings=shared_readers.readLodSettings(ctx, leveredSection, cache)) return leveredSuspensionConfig