예제 #1
0
def convertBabylonMultiExporterData():
    log = ""
    root = getSceneRootNode()
    print("Converting")
    if userprop.getUserProp(root,"babylonjs_ExportItemListBackup") is None: # Only convert if we didn't before
        exportItemList = userprop.getUserPropList(root, "babylonjs_ExportItemList")
        rawExportItemList = userprop.getUserProp(root, "babylonjs_ExportItemList")
        if exportItemList is not None:
            for exportItem in exportItemList:
                try:
                    itemProp = userprop.getUserProp(root, exportItem)
                    itemProp = str(itemProp).replace(";;", ";-;")
                    item = userprop.parseUserPropAsList(itemProp)
                    if (item is not None):
                        expPath = item[1]
                        serialLayers = item[3]
                        print(serialLayers)
                        layerNames = [x for x in item[3].split("~")]
                        absPath = convertRelativePathToAbsolute(expPath, rt.maxfilepath)
                        relPath = convertAbsolutePathToRelative(absPath, rt.pathConfig.getCurrentProjectFolder())
                        presetName = os.path.splitext(os.path.split(relPath)[1])[0]
                        presetUtils.createNewPreset(presetName, None, relPath, layerNames)
                        log += "{0}\n".format(presetName)
                except Exception as error:
                    log += "Couldn't convert " + exportItem + " of the path because " + error
                    print(error)
            # Uncomment if you want to destroy the original Babylon Preset
            userprop.setUserProp(root, "babylonjs_ExportItemListBackup", rawExportItemList)
            # userprop.removeUserProp(root, "babylonjs_ExportItemList")
    return log
예제 #2
0
def checkSavedMaxFilePath():  # UNUSED
    sceneRoot = getSceneRootNode()
    if rt.maxFilePath == "" or rt.maxFilePath is None:
        qtUtils.popup(title="Scene File is not saved.",
                      text="You need to save your Max scene to use the exporter.")
        return False
    savedFilePath = userprop.getUserProp(
        sceneRoot, constants.PROP_SAVED_MAXFILE_PATH)
    if (savedFilePath is None):
        userprop.setUserProp(
            sceneRoot, constants.PROP_SAVED_MAXFILE_PATH, rt.maxFilePath)
        return True
    else:
        if (savedFilePath != rt.maxFilePath):
            qtUtils.popup(
                title="Max File path changed",
                text="The scene .max file path changed since last time you used the Multi-Exporter.\n\n"
                "If you changed the path of your Max file please make sure all the export path in the Multi-Exporter are still correct.\n\n"
                "NOTE : This can be caused by having different workspaces working on the same file, "
                "it will not be a problem if the .max file didn't change relative to the project.\n\n"
                "If you didn't change the Max file path please ignore this message."
            )
            userprop.setUserProp(
                sceneRoot, constants.PROP_SAVED_MAXFILE_PATH, rt.maxFilePath)
            return True
        else:
            return True
예제 #3
0
    def saveSettings(self):
        sceneRoot = sceneUtils.getSceneRootNode()
        newSettings = dict()
        currentPresetIndex = self.comboOptionPreset.currentIndex()
        for widget in self.widgetToProperty.keys():
            prop = self.widgetToProperty[widget]
            if (isinstance(widget, QCheckBox)):
                state = True if widget.checkState() == Qt.Checked else False
            elif (isinstance(widget, QGroupBox)):
                state = widget.isChecked()
            elif (isinstance(widget, QComboBox)):
                state = widget.currentIndex()
            elif (isinstance(widget, QLineEdit)):
                state = widget.text()
            if currentPresetIndex == 0:
                userprop.setUserProp(sceneRoot, prop, str(state))
            newSettings[prop] = state
        for special in self.specialWidgetToProperty.keys():
            prop = self.specialWidgetToProperty[special]
            if (isinstance(special, QComboBox)):
                state = special.currentText()
            if (isinstance(special, QLineEdit)):
                state = special.text()
            if currentPresetIndex == 0:
                userprop.setUserProp(sceneRoot, prop, state)
            newSettings[prop] = state

        self.comboOptionPreset.updatePreset(currentPresetIndex, newSettings)
        self.btnSave.setText(APPLY_UPTODATE)
        self.madeChanges = False
        self.onModifiedData.emit()
예제 #4
0
    def onUseAlphaStateChanged(self):
        state = int(self.useAlpha_chb.isChecked())
        userprop.setUserProp(
            rt.rootNode, "FlightSim_ConvertTextureToMesh_useMaterialAlpha",
            state)


#~ w = ConvertTextureToMeshWindow()
#~ w.show()
예제 #5
0
    def loadTexture(self):
        if self.texturePath and self.texturePath != "":
            self.texturePath = os.path.basename(self.texturePath)
        else:
            self.texturePath = rt.maxFilePath

        self.texturePath, _ = QtWidgets.QFileDialog.getOpenFileName(
            self, self.tr("Load Image"), self.tr(self.texturePath))
        if self.texturePath and self.texturePath != "":
            userprop.setUserProp(rt.rootNode, "FlightSim_ConvertTextureToMesh",
                                 self.texturePath)
        self.path_lbl.setText(self.texturePath)
예제 #6
0
def updateObsoleteExportPath():
    log = ""
    roots = getAllRoots(getAllObjects())
    for r in roots:
        oldPath = userprop.getUserProp(r, constants.PROP_OLD_EXPORT_PATH)
        newPath = userprop.getUserProp(r, constants.PROP_EXPORT_PATH)
        if oldPath is not None and newPath is None:
            newPath = convertRelativePathToAbsolute(
                oldPath, rt.maxFilePath)
            newPath = convertAbsolutePathToRelative(
                newPath, rt.pathConfig.getCurrentProjectFolder())
            userprop.setUserProp(r, constants.PROP_EXPORT_PATH, newPath)
            log += "{0}\n".format(r.name)
    return log
예제 #7
0
 def _write(self):
     sceneRoot = sceneUtils.getSceneRootNode()
     propList = userprop.getUserPropList(sceneRoot, self.listStorage)
     if (propList is None):
         presetList = list()
     else:
         presetList = propList
     if self.name is None:
         newPreset = self.defaultName
     else:
         newPreset = self.name
     if self.identifier not in presetList:
         presetList.append(self.identifier)
     userprop.setUserProp(sceneRoot, self.identifier, newPreset)
     userprop.setUserPropList(sceneRoot, self.listStorage, presetList)
예제 #8
0
 def _clickedSetLODValues(self):
     lods = self.treeLODs.getSelectedRootList()
     for lod in lods:
         lodValueChoice = self.lodValue.text()
         if(lodValueChoice != "-"):
             validValue = qtUtils.validateFloatLineEdit(lodValueChoice)
             if(validValue):
                 userprop.setUserProp(
                     lod, constants.PROP_LOD_VALUE, validValue)
             
         keepInstances = self.cbKeepInstances.checkState()
         if (keepInstances != Qt.PartiallyChecked):
             keepInst = True if keepInstances == Qt.Checked else False
             userprop.setUserProp(lod, constants.PROP_KEEP_INSTANCES, keepInst)
             
     self.refreshTool()
예제 #9
0
def writeDefaultBabylonParametersInRootNode():
    sceneRoot = getSceneRootNode()
    for prop in propertyToDefault.keys():
        value = userprop.getUserProp(
            sceneRoot, prop, propertyToDefault[prop])
        userprop.setUserProp(sceneRoot, prop, value)