def __init__(self):
        super(QuixelSurface, self).__init__()

        record = InfoRecord(NCInfo.TexturesAtlas)
        record.setValueBool(False)

        self._infoGroupTextures = InfoRecordGroup()
        self._infoGroupTextures.name = NCInfo.GroupTextures
        self._infoGroupTextures.addRecord(record)
    def _collecVendorInfo(self):

        super(QuixelSurface, self)._collecVendorInfo()

        if not self._assetVendorData: return

        for item in self._assetVendorData["meta"]:
            if item["key"] == "tileable":
                try:
                    record = InfoRecord(NCInfo.TexturesTileable)
                    record.setValueBool(item["value"])
                    self._infoGroupTextures.addRecord(record)
                    break
                except:
                    break

        for item in self._assetVendorData["components"]:
            if item["type"] == "displacement":
                try:
                    record = InfoRecord(NCInfo.TexturesDispRange)
                    min = item["minIntensity"] / 256
                    max = item["maxIntensity"] / 256
                    record.setValueRangeFloat((min, max))
                    self._infoGroupTextures.addRecord(record)
                    break
                except:
                    break
 def setName(self, name=""):
     record = InfoRecord(NCInfo.GlobalName)
     record.setValueString(name)
     self._infoGroupGlobal.changeRecord(NCInfo.GlobalName, record)
 def setSets(self, sets=[""]):
     record = InfoRecord(NCInfo.GlobalSet)
     record.setValueStringList(sets)
     self._infoGroupGlobal.changeRecord(NCInfo.GlobalSet, record)
 def setGroups(self, groups=[""]):
     record = InfoRecord(NCInfo.GlobalGroup)
     record.setValueStringList(groups)
     self._infoGroupGlobal.changeRecord(NCInfo.GlobalGroup, record)
 def setCategories(self, categories=[""]):
     record = InfoRecord(NCInfo.GlobalCategory)
     record.setValueStringList(categories)
     self._infoGroupGlobal.changeRecord(NCInfo.GlobalCategory, record)
    def _initAsset(self, path):

        # setup default parameters

        self._assetFileArchive = path
        self._assetFileName = os.path.basename(path)
        self._assetFileName = os.path.splitext(self._assetFileName)[0]
        self._archiveManager.archiveFile = path

        # load asset .json info file

        self._archiveManager.open()

        try:
            name = self._archiveManager.content(["json"])[0]
            self._archiveManager.extractMember(directory=tempfile.gettempdir(),
                                               name=name)

            filepath = os.path.join(tempfile.gettempdir(), name)

            self._assetVendorData = self._commonFunc.loadFromJSON(filepath)
            os.remove(filepath)

            self._archiveManager.close()
            self._collecVendorInfo()
        except:
            print(self.__class__.__name__ + ": Asset" + path +
                  "has not .json info file",
                  file=sys.stderr)

        self._archiveManager.close()

        # parse categories and group info from asset name

        sepnames = self._assetFileName.split("_")

        record = InfoRecord(NCInfo.GlobalCategory)
        record.setValueStringList([sepnames[0]])
        self._infoGroupGlobal.addRecord(record)

        if len(sepnames) > 5:
            record = InfoRecord(NCInfo.GlobalGroup)
            record.setValueStringList([sepnames[1]])
            self._infoGroupGlobal.addRecord(record)

        record = InfoRecord(NCInfo.GlobalName)
        record.setValueString("")
        self._infoGroupGlobal.addRecord(record)

        # parse asset type

        for asset_type in self._quixelAssetTypes:
            t = "_" + asset_type
            if t in self._assetFileName:
                self._assetType = asset_type
                break
    def _collecVendorInfo(self):
        try:
            info = self._assetVendorData["tags"]
            record = InfoRecord(NCInfo.GlobalTags)
            record.setValueStringList([info])
            self._infoGroupGlobal.addRecord(record)
        except:
            pass

        try:
            info = self._assetVendorData["environment"]["biome"].replace(
                "-", " ")
            record = InfoRecord(NCInfo.GlobalSet)
            record.setValueStringList([info])
            self._infoGroupGlobal.addRecord(record)
        except:
            pass

        try:
            info = self._assetVendorData["averageColor"]
            record = InfoRecord(NCInfo.ColorAvg)
            record.setValueColor(info)
            self._infoGroupColor.addRecord(record)
        except:
            pass

        try:
            info = self._assetVendorData["environment"]["region"]
            record = InfoRecord(NCInfo.RegionLocation)
            record.setValueString(info)
            self._infoGroupRegion.addRecord(record)
        except:
            pass

        if self._assetType == QuiexelAssetTypes.Surface:
            for item in self._assetVendorData["meta"]:
                if item["key"] == "tileable":
                    try:
                        record = InfoRecord(NCInfo.TexturesTileable)
                        record.setValueBool(item["value"])
                        self._infoGroupTextures.addRecord(record)
                        break
                    except:
                        break

            for item in self._assetVendorData["components"]:
                if item["type"] == "displacement":
                    try:
                        record = InfoRecord(NCInfo.TexturesDispRange)
                        min = item["minIntensity"] / 256
                        max = item["maxIntensity"] / 256
                        record.setValueRangeFloat((min, max))
                        self._infoGroupTextures.addRecord(record)
                        break
                    except:
                        break