예제 #1
0
    def __exportModel(self, unityPath, skinnedModel):

        if not mc.objExists(self.RootMeshGroup):
            gui = dialog.ConfirmDialog2(
                **{'message': 'Can\'t find "%s"' % self.RootMeshGroup})
            gui.show()
            return

        assetPath = mc.file(q=True, sn=True).replace('\\', '/')
        tmp = assetPath.split('/')
        assetType = tmp[-2].lower()
        assetName = tmp[-1].lower().split('.')[0]

        for path in self._exportPaths:
            destPath = os.path.join(path, unityPath, assetType)

            if not os.path.exists(destPath):
                os.makedirs(destPath)

            # export fbx
            self._exportFBX('anim' if skinnedModel else 'model',
                            [self.RootMeshGroup],
                            os.path.join(destPath, assetName + '.fbx'))

            # export texture
            metaDatas = self._exportTextures(self.RootMeshGroup, destPath)

            self._exportMetaInfo(metaDatas, destPath, assetName)
예제 #2
0
    def lateInit(self, **kwargs):
        super(ExporterModel, self).lateInit(**kwargs)

        self.__exportFunction = {'tpose': self.__exportTPose,
                                 'anim': self.__exportAnim,
                                 'prop': self.__exportProp,
                                 'animedProp': self.__exportAnimedProp,
                                 'previewModel': self.__exportPreviewModel}

        self.__exportPaths = []

        # load pvz branch data
        self.__pvzBranchPath = main.getFile('pvz/pvzBranch.yaml')
        if os.path.exists(self.__pvzBranchPath):
            self.__pvzBranchData = yamlIO.read(self.__pvzBranchPath)
            self._sendMessage('branchPath', self.__pvzBranchData)
        else:
            gui = dialog.ConfirmDialog2(**{'message': 'Can\'t get pvz branch, please restart maya.'})
            gui.show()

        self.__exportConfig = main.getFile('pvz/exportConfig.yaml')
        if os.path.exists(self.__exportConfig):
            self.__exportConfigData = yamlIO.read(self.__exportConfig)
            self._sendMessage('exportConfigData', self.__exportConfigData)
        else:
            self.__exportConfigData = dict()
    def validation(self, *args):
        """
        Only work in animation file
        :return:
        """
        maya_file = mc.file(q=True, sn=True).lower().replace('\\', '/')
        if 'animation/character/wildlife' not in maya_file:
            return

        for reference in get_scene_references():
            maya_file = reference.resolved_name
            remote_files = msvP4.get_remote_files(maya_file)
            all_stats = msvP4.get_files_stats(remote_files)

            for f_stat in all_stats:
                have_rev = f_stat.get('haveRev')
                head_rev = f_stat.get('headRev')

                if have_rev != head_rev:
                    message = 'The rig file is not the latest one!\n Click "Confirm" to update!'
                    gui = dialog.ConfirmDialog2(
                        **{
                            'message': message,
                            'doConfirm': partial(self.update, maya_file)
                        })
                    gui.show()
예제 #4
0
    def exportTPose(self):
        if not self.__validateFile():
            return False

        # assetPath: F:/Projects/PVZCommando/ArtDev/art_source/characters/zombies/allstar/animations/[email protected]
        assetPath = mc.file(q=True, sn=True).replace('\\', '/')
        tmp = assetPath.split('/')

        # plants or zombies
        # F:/Projects/PVZCommando/ArtDev/art_source/characters/${zombies}$/allstar/animations/[email protected]
        assetType = tmp[-4].lower()

        # character name
        # F:/Projects/PVZCommando/ArtDev/art_source/characters/zombies/${allstar}$/animations/[email protected]
        assetName = tmp[-3].lower()

        gui = dialog.ConfirmDialog2(
            **{
                'message':
                'Character Type is: "%s"\nCharacter Name is: "%s"' %
                (assetType, assetName),
                'doConfirm':
                partial(self._exportTPose, assetType, assetName)
            })
        gui.show()
예제 #5
0
 def refresh(node, *args):
     if mc.objExists(node):
         dndLE = args[1]
         dndLE.setText(node)
         # self._sendMessage('select', path, groupName)
         # self.close()
     else:
         gui = dialog.ConfirmDialog2(
             **{'message': 'Can not find joint "%s" ' % node})
         gui.show()
예제 #6
0
    def __checkWrongShapeNode(self):
        errLog = ''
        for meshNode in mc.ls(type='mesh'):
            transformNode = mc.listRelatives(meshNode, p=True)[0]
            shapeNode = meshNode.split('|')[-1].split('Shape')[0]
            if transformNode != shapeNode:
                errLog += 'Transform node name "%s" doesn\'t match its shape node name "%s", ' \
                          '{$transformNode$}|{$transformNode$}Shape, please delete histroy!' % (transformNode, shapeNode)

        if errLog:
            gui = dialog.ConfirmDialog2(**{'message': errLog})
            gui.show()
예제 #7
0
    def __checkWrongTransformNode(self):
        errLog = ''
        characterName = os.path.basename(mc.file(q=True,
                                                 sn=True)).split('.')[0]
        for meshNode in mc.ls(type='mesh'):
            transformNode = mc.listRelatives(meshNode, p=True)[0]
            if not transformNode.startswith(characterName):
                errLog += '"%s" is a invalid name\n, it should start with "%s"' % (
                    transformNode, characterName)

        if errLog:
            gui = dialog.ConfirmDialog2(**{'message': errLog})
            gui.show()
예제 #8
0
    def __checkMeshWithDuplicationName(self):
        errLog = ''
        for meshNode in mc.ls(type='mesh'):
            transformNode = mc.listRelatives(meshNode, p=True)[0]
            try:
                mc.select(cl=True)
                mc.select(transformNode, r=True)
            except Exception as e:
                errLog += '%s\n' % e.args

        if errLog:
            gui = dialog.ConfirmDialog2(**{'message': errLog})
            gui.show()
예제 #9
0
    def __validateFile(self):
        if not mc.objExists(self.RootMeshGroup):
            gui = dialog.ConfirmDialog2(
                **{'message': 'Can\'t find "%s"' % self.RootMeshGroup})
            gui.show()
            return False
        else:
            try:
                mc.select(self.RootMeshGroup)
            except:
                gui = dialog.ConfirmDialog2(
                    **{
                        'message':
                        'More than one object matches name: %s' %
                        self.RootMeshGroup
                    })
                gui.show()
                return False

        if not mc.objExists(self.RootJoint):
            gui = dialog.ConfirmDialog2(
                **{'message': 'Can\'t find "%s"' % self.RootJoint})
            gui.show()
            return False
        else:
            try:
                mc.select(self.RootJoint)
            except:
                gui = dialog.ConfirmDialog2(
                    **{
                        'message':
                        'More than one object matches name: %s' %
                        self.RootJoint
                    })
                gui.show()
                return False

        return True
예제 #10
0
    def userInfo(self, name, password):
        branchData, encryptPassword = SetupEnvironmentModel.getUserInfoInterface(
            name, password)
        if branchData:
            self._config['user'] = name
            self._config['password'] = password
            yamlIO.write(self._configPath, self._config)

            self.__branchData = branchData
            yamlIO.write(self.__branchPath, self.__branchData)

            # refresh view data
            self._sendMessage('branchPath', self.__branchData)
        else:
            gui = dialog.ConfirmDialog2(
                **{'message': 'Can\'t get client info, please try again.'})
            gui.show()
예제 #11
0
    def lateInit(self):
        currentWorkspace = mc.workspace(q=True, rd=True)

        errorList = []
        for node in mc.ls(type='file'):
            path = mc.getAttr(node + '.ftn')

            if currentWorkspace not in path:
                errorList.append(
                    'Path "%s" didn\'t in the current workspace "%s".' %
                    (path, currentWorkspace))
            else:
                n = path.replace(currentWorkspace, '')
                mc.setAttr(node + '.ftn', n, typ='string')

        if errorList:
            msg = '\n\n'.join(errorList)
            gui = dialog.ConfirmDialog2(**{'message': msg})
            gui.show()
예제 #12
0
    def validation(self, *args):
        """
        Only work in model file
        :return:
        """
        mayaFile = mc.file(q=True, sn=True)
        arr = mayaFile.split('/')
        if arr[-2] != 'models':
            return

        characterType = arr[-1].split('_')[0]
        characterName = arr[-1].split('_')[1]

        materialStartString = '%s_%s' % (characterType, characterName)
        materialEndString = '_mat'

        materials = []
        for mesh in mc.ls(typ='mesh'):
            # Get the shader groups attached to this particular object
            shaderGroups = mc.listConnections(mc.listHistory(mesh))
            if shaderGroups is not None:
                # Get the material attached to the shader group
                _materials = [
                    x for x in mc.ls(mc.listConnections(shaderGroups),
                                     materials=True)
                ]

                for mat in _materials:
                    if mat not in materials:
                        materials.append(mat)

        errLog = ''
        for mat in materials:
            if not mat.startswith(materialStartString) or not mat.endswith(
                    materialEndString):
                errLog += '%s\n' % mat

        if errLog:
            message = """
            These materials\' name are wrong: \n%s\n The standard material\'s name should be: \"%s_xxx_mat\"!"
            """ % (errLog, materialStartString)
            gui = dialog.ConfirmDialog2(**{'message': message})
            gui.show()
    def validation(self, *args):
        """
        Only work in rig file
        :return:
        """
        maya_file = mc.file(q=True, sn=True)
        if '_rig' not in os.path.basename(maya_file).lower():
            return

        maya_file = mc.file(q=True, sn=True)
        remote_files = msvP4.get_remote_files(maya_file)
        all_stats = msvP4.get_files_stats(remote_files)

        for f_stat in all_stats:
            have_rev = f_stat.get('haveRev')
            head_rev = f_stat.get('headRev')

            if have_rev != head_rev:
                message = 'This rig file is not the latest one! Please update!'
                gui = dialog.ConfirmDialog2(**{'message': message})
                gui.show()
    def _exportTPose(self, *args):
        assetType = args[0]
        assetName = args[1]
        characterName = args[2]

        for path in self._exportPaths:
            # export whole avatar for preview
            previewDestPath = os.path.join(path,
                                           self.__exportCharacterPreviewPath,
                                           assetType, assetName + '_preview')
            if not os.path.exists(previewDestPath):
                os.makedirs(previewDestPath)

            if mc.objExists(self.RootJoint) and mc.objExists(
                    self.RootMeshGroup):
                fbxPreset = 'anim'
                fbxNodes = [self.RootJoint, self.RootMeshGroup]

            else:
                fbxPreset = 'model'
                rootNode = os.path.basename(mc.file(q=True,
                                                    sn=True)).split('.')[0]
                if not mc.objExists(rootNode):
                    gui = dialog.ConfirmDialog2(
                        **{'message': 'Can not find "%s"' % rootNode})
                    gui.show()
                else:
                    self.RootMeshGroup = rootNode
                fbxNodes = [self.RootMeshGroup]

            if fbxPreset and fbxNodes:
                self._exportFBX(
                    fbxPreset, fbxNodes,
                    os.path.join(previewDestPath, characterName + '.fbx'))

                # export texture
                metaDatas = self._exportTextures(self.RootMeshGroup,
                                                 previewDestPath)

                self._exportMetaInfo(metaDatas, previewDestPath, characterName)
예제 #15
0
        def do():
            startJoint = self._ui.startJointDNDLE.text()
            endJoint = self._ui.endJointDNDLE.text()

            errorMsg = ''
            if not mc.objExists(
                    startJoint) or mc.nodeType(startJoint) != 'joint':
                errorMsg += startJoint + ';\n'

            if not mc.objExists(endJoint) or mc.nodeType(endJoint) != 'joint':
                errorMsg += endJoint + ';\n'

            if not errorMsg:
                if startJoint == endJoint:
                    errorMsg += 'start joint and end joint can not be the same!'
            else:
                errorMsg = 'Can not find joint:\n %s' % errorMsg

            if not errorMsg:
                self._sendMessage('do', startJoint, endJoint)
            else:
                gui = dialog.ConfirmDialog2(**{'message': errorMsg})
                gui.show()