コード例 #1
0
def readCamouflage(xmlCtx, section, sectionName, default=None):
    tiling, mask, density, aoTextureSize = (None, None, None, None)
    tilingKey = sectionName + '/tiling'
    if section.has_key(tilingKey):
        readTiling = _xml.readTupleOfFloats(xmlCtx, section, tilingKey, 4)
        if readTiling[0] > 0 and readTiling[1] > 0:
            tiling = readTiling
    if tiling is None:
        if default is not None:
            tiling = default[0]
        else:
            _xml.raiseWrongSection(xmlCtx, tilingKey)
    maskKey = sectionName + '/exclusionMask'
    mask = section.readString(maskKey)
    if not mask and default is not None:
        mask = default[1]
    densityKey = sectionName + '/density'
    if section.has_key(densityKey):
        density = _xml.readTupleOfFloats(xmlCtx, section, densityKey, 2)
    if density is None and default is not None:
        density = default[2]
    aoTextureSizeKey = sectionName + '/aoTextureSize'
    if section.has_key(aoTextureSizeKey):
        aoTextureSize = _xml.readTupleOfFloats(xmlCtx, section,
                                               aoTextureSizeKey, 2)
    if aoTextureSize is None and default is not None:
        aoTextureSize = default[3]
    return shared_components.Camouflage(tiling, mask, density, aoTextureSize)
コード例 #2
0
def readCamouflage(xmlCtx, section, sectionName, default=None):
    tilingKey = sectionName + '/tiling'
    if default is None or section.has_key(tilingKey):
        tiling = _xml.readTupleOfFloats(xmlCtx, section, tilingKey, 4)
        if tiling[0] <= 0 or tiling[1] <= 0:
            if default is None:
                _xml.raiseWrongSection(xmlCtx, tilingKey)
            else:
                tiling = default[0]
    else:
        tiling = default[0]
    maskKey = sectionName + '/exclusionMask'
    mask = section.readString(maskKey)
    if not mask and default is not None:
        mask = default[1]
    return shared_components.Camouflage(tiling, mask)
コード例 #3
0
def readCamouflage(xmlCtx, section, sectionName, default = None):
    """Reads camouflage configuration of vehicle's item on client-side only.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :param sectionName:  string containing name of section.
    :param default: None or instance of Camouflage that is used as default.
    :return: instance of shared_components.Camouflage.
    """
    tilingKey = sectionName + '/tiling'
    if default is None or section.has_key(tilingKey):
        tiling = _xml.readTupleOfFloats(xmlCtx, section, tilingKey, 4)
        if tiling[0] <= 0 or tiling[1] <= 0:
            if default is None:
                _xml.raiseWrongSection(xmlCtx, tilingKey)
            else:
                tiling = default[0]
    else:
        tiling = default[0]
    maskKey = sectionName + '/exclusionMask'
    mask = section.readString(maskKey)
    if not mask and default is not None:
        mask = default[1]
    return shared_components.Camouflage(tiling, mask)