def writeWheelsAndGroups(wheelsConfig, section): wheelId = 0 groupId = 0 defSyncAngle = section.readFloat('wheels/leadingWheelSyncAngle', 60) for sname, subsection in _xml.getChildren(None, section, 'wheels'): if sname == 'group': group = wheelsConfig.groups[groupId] _xml.rewriteString(subsection, 'template', group.template) _xml.rewriteInt(subsection, 'count', group.count, 1) _xml.rewriteInt(subsection, 'startIndex', group.startIndex, 0) _xml.rewriteFloat(subsection, 'radius', group.radius) groupId += 1 if sname == 'wheel': from items.vehicles import _writeHitTester, _writeArmor index = _xml.readIntOrNone(None, subsection, 'index') if index is not None: wheelId = index wheel = wheelsConfig.wheels[wheelId] radiusKey = 'radius' if subsection.has_key('radius') else 'geometry/radius' _xml.rewriteInt(subsection, 'index', wheelId, createNew=False) _xml.rewriteFloat(subsection, radiusKey, wheel.radius) _xml.rewriteString(subsection, 'name', wheel.nodeName) _xml.rewriteBool(subsection, 'isLeading', wheel.isLeading) _xml.rewriteFloat(subsection, 'syncAngle', wheel.leadingSyncAngle, defSyncAngle) _xml.rewriteVector3(subsection, 'wheelPos', wheel.position, Vector3(0, 0, 0)) _writeHitTester(wheel.hitTester, None, subsection, 'hitTester') _writeArmor(wheel.materials, None, subsection, 'armor', optional=True, index=wheelId) wheelId += 1 return
def writeGroundNode(curGroup, curSection): _xml.rewriteString(curSection, 'template', curGroup.nodesTemplate) _xml.rewriteInt(curSection, 'startIndex', curGroup.startIndex) _xml.rewriteInt(curSection, 'count', curGroup.nodesCount) _xml.rewriteBool(curSection, 'isLeft', curGroup.isLeft) _xml.rewriteFloat(curSection, 'minOffset', curGroup.minOffset) _xml.rewriteFloat(curSection, 'maxOffset', curGroup.maxOffset)
def writeTraces(traces, section, cache): shared_writers.writeLodDist(traces.lodDist, section, 'traces/lodDist', cache) _xml.rewriteString(section, 'traces/bufferPrefs', traces.bufferPrefs) _xml.rewriteString(section, 'traces/textureSet', traces.textureSet) _xml.rewriteVector2(section, 'traces/size', traces.size) _xml.rewriteBool(section, 'traces/activePostmortem', traces.activePostmortem, defaultValue=False)
def writeTrackNode(curNode, curSection): _xml.rewriteBool(curSection, 'isLeft', curNode.isLeft) _xml.rewriteString(curSection, 'name', curNode.name) _xml.rewriteFloat(curSection, 'forwardElastK', curNode.forwardElasticityCoeff, defForwardElastK) _xml.rewriteFloat(curSection, 'backwardElastK', curNode.backwardElasticityCoeff, defBackwardElastK) _xml.rewriteFloat(curSection, 'offset', curNode.initialOffset, defOffset) if curNode.leftNodeName: _xml.rewriteString(curSection, 'leftSibling', curNode.leftNodeName) if curNode.rightNodeName: _xml.rewriteString(curSection, 'rightSibling', curNode.rightNodeName)
def writeEmblemSlots(slotDS, slot): slotDS.write('rayStart', slot.rayStart) slotDS.write('rayEnd', slot.rayEnd) slotDS.write('rayUp', slot.rayUp) if slot.type == 'insigniaOnGun': _xml.rewriteBool(slotDS, 'applyToFabric', slot.applyToFabric, True) else: _xml.rewriteBool(slotDS, 'isMirrored', slot.isMirrored, False) if slot.type in ('fixedEmblem', 'fixedInscription'): slotDS.write('emblemId', slot.emblemId) slotDS.write('size', slot.size) _xml.rewriteBool(slotDS, 'hideIfDamaged', slot.hideIfDamaged, False) _xml.rewriteBool(slotDS, 'isUVProportional', slot.isUVProportional, True) _xml.rewriteBool(slotDS, 'isMirrored', slot.isMirrored, False)
def writeTrackSplineParams(trackSplineParams, section): if trackSplineParams is None: return else: if not section.has_key('trackNodes'): section.createSection('trackNodes') _xml.rewriteFloat(section, 'trackThickness', trackSplineParams.thickness) _xml.rewriteBool(section, 'trackNodes/enable', trackSplineParams.editorData._enable) _xml.rewriteBool(section, 'trackNodes/linkBones', trackSplineParams.editorData.linkBones) _xml.rewriteFloat(section, 'trackNodes/maxAmplitude', trackSplineParams.maxAmplitude) _xml.rewriteFloat(section, 'trackNodes/maxOffset', trackSplineParams.maxOffset) _xml.rewriteFloat(section, 'trackNodes/gravity', trackSplineParams.gravity) _xml.rewriteFloat(section, 'trackNodes/elasticity', trackSplineParams.editorData.elasticity) _xml.rewriteFloat(section, 'trackNodes/damping', trackSplineParams.editorData.damping) return
def writeProjectionSlots(slotDS, slot): slotDS.write('compatibleModels', ' '.join(slot.compatibleModels)) slotDS.write('position', slot.position) slotDS.write('rotation', slot.rotation) slotDS.write('scale', slot.scale) slotDS.write('showOn', slot.showOn) if slot.type != 'fixedProjectionDecal': slotDS.write('verticalMirror', slot.canBeMirroredVertically) _xml.rewriteBool(slotDS, 'doubleSided', slot.doubleSided, False) _xml.rewriteBool(slotDS, 'hiddenForUser', slot.hiddenForUser, False) _xml.rewriteFloat(slotDS, 'clipAngle', slot.clipAngle, 0.0) if slot.type == 'projectionDecal': writeProjectionSlotsNotFixed(slotDS, slot) elif slot.type == 'fixedProjectionDecal': writeProjectionSlotsFixed(slotDS, slot)
def writeProjectionSlots(slotDS, slot): slotDS.write('compatibleModels', ' '.join(slot.compatibleModels)) slotDS.write('position', slot.position) slotDS.write('rotation', slot.rotation) slotDS.write('scale', slot.scale) slotDS.write('showOn', slot.showOn) slotDS.write('verticalMirror', slot.canBeMirroredVertically) _xml.rewriteBool(slotDS, 'doubleSided', slot.doubleSided, False) _xml.rewriteFloat(slotDS, 'clipAngle', slot.clipAngle, 0.0) if slot.attachedParts is not None and len(slot.attachedParts) != 0: if not isinstance(slot.attachedParts, set): partTypeToNames = slot.attachedParts.items() partTypeToName = ((pType, pName) for pType, pNames in partTypeToNames for pName in pNames) attachedParts = ' '.join((':'.join((str(pType), pName)) for pType, pName in partTypeToName)) if attachedParts: slotDS.write('attachedPart', attachedParts) if slot.type == 'projectionDecal': writeProjectionSlotsNotFixed(slotDS, slot) elif slot.type == 'fixedProjectionDecal': writeProjectionSlotsFixed(slotDS, slot) return
def writeEmblemSlots(slotDS, slot): if slot.type not in ('attachment', 'sequence', 'paint', 'camouflage', 'style', 'effect', 'projectionDecal', 'fixedProjectionDecal'): _xml.rewriteBool(slotDS, 'isMirrored', slot.isMirrored, False) slotDS.write('rayStart', slot.rayStart) slotDS.write('rayEnd', slot.rayEnd) slotDS.write('rayUp', slot.rayUp) if slot.type in ('fixedEmblem', 'fixedInscription'): slotDS.write('emblemId', slot.emblemId) if slot.type == 'insigniaOnGun': _xml.rewriteBool(slotDS, 'applyToFabric', slot.applyToFabric, True) slotDS.write('size', slot.size) _xml.rewriteBool(slotDS, 'hideIfDamaged', slot.hideIfDamaged, False) _xml.rewriteBool(slotDS, 'isUVProportional', slot.isUVProportional, None) return
def writeProjectionSlots(slotDS, slot): if slot.type == 'projectionDecal': slotDS.write('tags', ' '.join(slot.tags)) if len(slot.compatibleModels) == 1 and slot.compatibleModels[0] == 'default': slotDS.deleteSection('compatibleModels') else: slotDS.write('compatibleModels', ' '.join(slot.compatibleModels)) slotDS.write('position', slot.position) slotDS.write('rotation', slot.rotation) slotDS.write('scale', slot.scale) _xml.rewriteBool(slotDS, 'doubleSided', slot.doubleSided, False) _xml.rewriteBool(slotDS, 'hiddenForUser', slot.hiddenForUser, False) slotDS.write('showOn', slot.showOn) _xml.rewriteFloat(slotDS, 'clipAngle', slot.clipAngle, None) _xml.rewriteBool(slotDS, 'verticalMirror', slot.canBeMirroredVertically, False) if slot.type == 'projectionDecal': slotDS.write('anchorShift', slot.anchorShift) elif slot.type == 'fixedProjectionDecal': slotDS.write('itemId', slot.itemId) slotDS.write('options', slot.options) return