Example #1
0
def DoFbxShadersGraphImport(silent, importMode, objNS, modelsMask):

    userChoise = 1  #importMode

    if not silent:
        userChoise = FBMessageBox('Shader Graph Importer',
                                  'Please choose an operation',
                                  'Apply to reference',
                                  'Apply to source scene', 'Cancel')

    if 1 == userChoise:

        # auto load for references

        filename = objNS.ReferenceFilePath

        base = os.path.splitext(filename)[0]
        xmlname = base + '.xml'

        # TODO: if description file is not exist, let's try to make it from fbx
        # TODO: xml will be update if it's out of date

        if os.path.isfile(filename):
            misc.RunCmdExtractXml(filename)

        #
        #
        if os.path.isfile(xmlname):

            # step 1 - load missing resources
            #   ?! promt if user wants to revert shaders properties values

            LoadShaderGraphResources(xmlname, xmlname, objNS, True,
                                     (importMode > 1))

            # step 2 - apply connections and modifications (on top of last user edits)

            LoadShaderGraphConnections(xmlname, xmlname, objNS, True)

        else:
            FBMessageBox('Shading Graph Importer',
                         'Shading Graph Description is not found !', 'Ok')

    elif 2 == userChoise:

        # we don't have reference namespace in a source scene

        filename = lApp.FBXFileName
        base = os.path.splitext(filename)[0]
        xmlname = base + '.xml'

        if os.path.isfile(xmlname):
            # apply changes to orig scene
            LoadShaderGraphResources(xmlname, xmlname, None, False, True)
            LoadShaderGraphConnections(xmlname, xmlname, None, False)
        else:
            FBMessageBox('Shading Graph Importer',
                         'Shading Graph Description is not found!', 'Ok')
Example #2
0
def DoFbxShadersGraphImport2(silent, importMode, objNS, modelsMask):

    userChoise = 1  #importMode

    if not silent:
        userChoise = FBMessageBox('Shader Graph Importer',
                                  'Please choose an operation',
                                  'Apply to reference',
                                  'Apply to source scene', 'Cancel')

    if 1 == userChoise:

        # auto load for references

        NS = objNS.LongName + ':'
        filename = objNS.ReferenceFilePath

        base = os.path.splitext(filename)[0]
        xmlname = base + '.xml'

        # DONE: if description file is not exist, let's try to make it from fbx
        # DONE: xml will be update if it's out of date

        if os.path.isfile(filename):
            misc.RunCmdExtractXml(filename)

        #
        #

        if os.path.isfile(xmlname):

            refEdits = ''
            #if objNS.GetContentModified( FBPlugModificationFlag.kFBContentAllModifiedMask ):
            #    refEdits = objNS.GetRefEdit()
            #    objNS.RevertRefEdit()

            # step 1 - load missing resources
            #   ?! promt if user wants to revert shaders properties values

            LoadShaderGraphResources(xmlname, xmlname, NS, True,
                                     (importMode > 1))

            # step 2 - apply connections and modifications (on top of last user edits)

            if len(refEdits) > 0:
                objNS.RevertRefEdit()
                objNS.ApplyRefEditPyScriptFromString(refEdits)
                LoadShaderGraphConnections(xmlname, xmlname, objNS, True)
                # restore missing connections, like when merging new objects
            else:
                userChoise = 1  #FBMessageBox('Shading Graph Importer', 'Do you want to restore shaders graph connections?', 'Ok', 'Cancel')
                if 1 == userChoise:
                    LoadShaderGraphConnections(xmlname, xmlname, objNS, True)

            #del(refEdits)

        else:
            FBMessageBox('Shading Graph Importer',
                         'Shading Graph Description is not found !', 'Ok')

    elif 2 == userChoise:

        # we don't have reference namespace in a source scene

        filename = lApp.FBXFileName
        base = os.path.splitext(filename)[0]
        xmlname = base + '.xml'

        if os.path.isfile(xmlname):
            # apply changes to orig scene
            LoadShaderGraphResources(xmlname, xmlname, None, False, True)
            LoadShaderGraphConnections(xmlname, xmlname, None, False)
        else:
            FBMessageBox('Shading Graph Importer',
                         'Shading Graph Description is not found!', 'Ok')