Ejemplo n.º 1
0
    def storeJointVars(self, gameJointNames, parentJointNames, jointPositionX,
                       jointPositionY, jointPositionZ, jointRotateOrder,
                       blueprintJointNames, jointOrientX, jointOrientY,
                       jointOrientZ, containerName):
        # Define the file name and path
        userName = userUtils.getUser()[0]
        outFileSuffix = '_gameJntInfo.csv'
        outFile = (userName + outFileSuffix)
        """ Define the artPath """
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()
        artPath = dirExt.artPath

        filePath = artPath + "/character/GEPPETTO/Data/"

        finalPath = (filePath + outFile)

        for index in range(len(gameJointNames)):
            int = str(index)

            value = (gameJointNames[index], parentJointNames[index],
                     jointPositionX[index], jointPositionY[index],
                     jointPositionZ[index], jointRotateOrder[index],
                     blueprintJointNames[index], jointOrientX[index],
                     jointOrientY[index], jointOrientZ[index])

            writer = csv.writer(open(finalPath, "a"))
            writer.writerow(value)
        """ I need to make sure the file closes here """
        # Close the file
        #file.close(finalPath)

        cmds.headsUpMessage("The temp data file has been saved to " +
                            finalPath)
Ejemplo n.º 2
0
    def storeJointVars(self, gameJointNames, parentJointNames, jointPositionX, jointPositionY, jointPositionZ, jointRotateOrder, blueprintJointNames, jointOrientX, jointOrientY, jointOrientZ, containerName):  
        # Define the file name and path        
        userName = userUtils.getUser()[0]
        outFileSuffix = '_gameJntInfo.csv'
        outFile = (userName + outFileSuffix )
        

        """ Define the artPath """
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()
        artPath = dirExt.artPath
            
        filePath = artPath + "/character/GEPPETTO/Data/" 
        
        finalPath = (filePath  + outFile)
             
        for index in range(len(gameJointNames)):
            int = str(index)

            value = (gameJointNames[index], parentJointNames[index], jointPositionX[index], jointPositionY[index], jointPositionZ[index], jointRotateOrder[index], blueprintJointNames[index], jointOrientX[index], jointOrientY[index], jointOrientZ[index])  
        
            writer = csv.writer(open(finalPath, "a"))                
            writer.writerow(value)

        """ I need to make sure the file closes here """            
        # Close the file
        #file.close(finalPath)
        
        cmds.headsUpMessage("The temp data file has been saved to " + finalPath)       
Ejemplo n.º 3
0
    def installProc(self, characterName, *args):
        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(self.characterName, create=False)       
        setupDir = projectDirs[1]
        xmlDir = projectDirs[2]
        rigDir = projectDirs[3]
        characterFileName = projectDirs[5]   
        setupFileName = projectDirs[6]        
        xmlFileName = projectDirs[7]
        meshDir = projectDirs[8]
        characterName = self.characterName
      
        """ use turbineUtils to find out the namespaces. """
        namespaces = turbineUtils.getCharacterNamespace(self.characterName)    
        characterNamespace = namespaces[0]        
        characterNameString = (characterNamespace + ":")
       
        """ Import the rig """
        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(self.characterName, create=False) 
        characterFileName = projectDirs[5]

        if cmds.namespace(exists=characterNamespace):
            print "Rig Installed"
        else:
            cmds.file(characterFileName, i=True, namespace=characterNamespace)
            cmds.namespace(set=characterNamespace)   
            
        cmds.namespace(setNamespace=":")  

        """ Unlock the character container """
        characterContainer = (characterNamespace + ":character_container")
        cmds.lockNode(characterContainer, lock=False, lockUnpublished=False)
        
        setupContainer = self.setupGameJoints(characterName, namespaces)

        """ Import the mesh if it exists """
        self.setupMesh(characterName, setupContainer)
        
        
        """ Lock the containers """
        cmds.lockNode(characterContainer, lock=True, lockUnpublished=True)
        cmds.lockNode(setupContainer, lock=True, lockUnpublished=True)
        
        """ Set namespace back to default """
        cmds.namespace(set=":")

        cmds.deleteUI(self.UIElements["window"])
        
                    
        """ Create all the necessary character directories if they do not exist """  
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()  
        dirExt.createAllDirs()
        dirExt.createBakDirs()
        
        """ Get the user name and inform of operation completion """       
        currentUser = getUser()        
        niceName = (currentUser)[1]
        cmds.headsUpMessage(self.characterName+ " has been installed " + niceName)
Ejemplo n.º 4
0
    def installProc(self, characterName, *args):
        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(self.characterName, create=False)
        setupDir = projectDirs[1]
        xmlDir = projectDirs[2]
        rigDir = projectDirs[3]
        characterFileName = projectDirs[5]
        setupFileName = projectDirs[6]
        xmlFileName = projectDirs[7]
        meshDir = projectDirs[8]
        characterName = self.characterName
        """ use turbineUtils to find out the namespaces. """
        namespaces = turbineUtils.getCharacterNamespace(self.characterName)
        characterNamespace = namespaces[0]
        characterNameString = (characterNamespace + ":")
        """ Import the rig """
        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(self.characterName, create=False)
        characterFileName = projectDirs[5]

        if cmds.namespace(exists=characterNamespace):
            print "Rig Installed"
        else:
            cmds.file(characterFileName, i=True, namespace=characterNamespace)
            cmds.namespace(set=characterNamespace)

        cmds.namespace(setNamespace=":")
        """ Unlock the character container """
        characterContainer = (characterNamespace + ":character_container")
        cmds.lockNode(characterContainer, lock=False, lockUnpublished=False)

        setupContainer = self.setupGameJoints(characterName, namespaces)
        """ Import the mesh if it exists """
        self.setupMesh(characterName, setupContainer)
        """ Lock the containers """
        cmds.lockNode(characterContainer, lock=True, lockUnpublished=True)
        cmds.lockNode(setupContainer, lock=True, lockUnpublished=True)
        """ Set namespace back to default """
        cmds.namespace(set=":")

        cmds.deleteUI(self.UIElements["window"])
        """ Create all the necessary character directories if they do not exist """
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()
        dirExt.createAllDirs()
        dirExt.createBakDirs()
        """ Get the user name and inform of operation completion """
        currentUser = getUser()
        niceName = (currentUser)[1]
        cmds.headsUpMessage(self.characterName + " has been installed " +
                            niceName)
Ejemplo n.º 5
0
    def saveSkinWeights(self, *args):
        ''' This next block is used to define the path where the weights will be saved.
        I plan on putting this in the __init__ once I am done testing '''
        print "saving weights"
        #import tsapi.core.maya.animation as annie
        #reload(annie)

        try:
            character = cmds.ls(sl=True)[0]
        except:
            cmds.headsUpMessage("Please Select Valid Geometry")
            return
        annie = annie.animation()

        # Define the file name and path
        characterName = self.characterName
        skinPath = turbineUtils.setupDirs(characterName, create=False)[4]
        outFileSuffix = '_skinWeight.csv'
        outFile = (character + outFileSuffix)
        finalPath = (skinPath + outFile)
        """ Delete the skin file if one already exists """
        if cmds.file(finalPath, q=True, ex=True):
            os.remove(finalPath)

        # Select the character here, then use GetValidSkinWeights to grab vert info.
        print " Annie used here"
        for char in annie.GetValidSkinWeights():
            vert = char[0]

            jointInfo = char[1]
            for each in jointInfo:
                joint = each[0]
                tmpWeight = each[1]

                weight = str("%.2f" % tmpWeight)
                weight = float(weight)

                value = (vert, joint, weight)

                writer = csv.writer(open(finalPath, "a"))
                writer.writerow(value)
        """ I need to make sure the file closes here """
        # Close the file
        #file.close(finalPath)

        # Get the user name and inform the user the weights have been saved
        currentUser = getUser()
        niceName = (currentUser)[1]
        cmds.headsUpMessage("The weight file has been saved to " + finalPath)
Ejemplo n.º 6
0
    def initCsvReader(self, characterName):

        self.characterName = characterName

        # Define the file name and path
        userName = userUtils.getUser()[0]
        outFileSuffix = '_gameJntInfo.csv'
        outFile = (characterName + outFileSuffix)
        """ Define the artPath """
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()
        artPath = dirExt.artPath

        filePath = artPath + "/character/GEPPETTO/Data/Character/"

        finalPath = (filePath + outFile)

        reader = csv.reader(open(finalPath, 'rb'), delimiter=',')

        return reader
Ejemplo n.º 7
0
    def initCsvReader(self, characterName):
        
        self.characterName = characterName

        # Define the file name and path        
        userName = userUtils.getUser()[0]
        outFileSuffix = '_gameJntInfo.csv'
        outFile = (characterName + outFileSuffix )

        """ Define the artPath """
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()
        artPath = dirExt.artPath
            
        filePath = artPath + "/character/GEPPETTO/Data/Character/" 
        
        finalPath = (filePath  + outFile)
        
        reader = csv.reader(open(finalPath, 'rb'), delimiter=',')
        
        return reader
Ejemplo n.º 8
0
    def saveDelCharFile(self, characterName):
        """ This process happens at character publish.  The temp .csv file will be saved to a new directory with the character name as prefix """
        self.characterName = characterName
        """ Write the csv with all the character info """
        """ Define the artPath """
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()
        artPath = dirExt.artPath

        # Define the file name and path
        userName = userUtils.getUser()[0]

        outFileSuffix = '_gameJntInfo.csv'
        outFileSuffixBU = '_gameJntInfo_BU.csv'

        outFileD = (userName + outFileSuffix)  # Delete this
        outFileS = (self.characterName + outFileSuffix)  # Save as this
        outFileBU = (self.characterName + outFileSuffixBU)  # Save as this

        filePath = artPath + "/character/GEPPETTO/Data/"
        filePathS = artPath + "/character/GEPPETTO/Data/Character/"
        filePathBU = artPath + "/character/GEPPETTO/Data/Character/BU/"

        finalPathD = (filePath + outFileD)
        finalPathS = (filePathS + outFileS)
        finalPathBU = (filePathBU + outFileBU)

        if cmds.file(finalPathS, q=True, ex=True):
            turbineUtils.archiveFile(finalPathS)

        if cmds.file(finalPathD, q=True, ex=True):
            import shutil
            shutil.copy(finalPathD, finalPathS)
            os.remove(finalPathD)
        else:
            cmds.headsUpMessage(
                "No character data file exists for publish.  Please lock a character."
            )
Ejemplo n.º 9
0
    def saveDelCharFile(self, characterName):
        """ This process happens at character publish.  The temp .csv file will be saved to a new directory with the character name as prefix """
        self.characterName = characterName
        """ Write the csv with all the character info """                
        """ Define the artPath """
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()
        artPath = dirExt.artPath

        # Define the file name and path        
        userName = userUtils.getUser()[0]
        
        outFileSuffix = '_gameJntInfo.csv'
        outFileSuffixBU = '_gameJntInfo_BU.csv'
        
        outFileD = (userName + outFileSuffix )# Delete this
        outFileS = (self.characterName + outFileSuffix )# Save as this
        outFileBU = (self.characterName + outFileSuffixBU )# Save as this
    
    
        filePath = artPath + "/character/GEPPETTO/Data/" 
        filePathS = artPath + "/character/GEPPETTO/Data/Character/" 
        filePathBU = artPath + "/character/GEPPETTO/Data/Character/BU/" 
        
        finalPathD = (filePath  + outFileD)
        finalPathS = (filePathS  + outFileS)
        finalPathBU = (filePathBU + outFileBU)
              
        if cmds.file(finalPathS, q=True, ex=True):
            turbineUtils.archiveFile(finalPathS)

        
        if cmds.file(finalPathD, q=True, ex=True):
            import shutil
            shutil.copy(finalPathD, finalPathS)
            os.remove(finalPathD)
        else:
            cmds.headsUpMessage("No character data file exists for publish.  Please lock a character.")
    def installProc(self, characterName, *args):

        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(self,
                                             self.characterName,
                                             create=False)
        setupDir = projectDirs[1]
        xmlDir = projectDirs[2]
        rigDir = projectDirs[3]
        characterFileName = projectDirs[5]
        setupFileName = projectDirs[6]
        xmlFileName = projectDirs[7]

        # use turbineUtils to find out the namespaces.
        namespaces = turbineUtils.getCharacterNamespace(
            self, self.characterName)

        characterNamespace = namespaces[0]
        exportNamespace = namespaces[1]
        try:
            cmds.namespace(add=exportNamespace)
        except:
            pass

        characterNameString = (characterNamespace + ":")

        # Import the rig
        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(self,
                                             self.characterName,
                                             create=False)
        characterFileName = projectDirs[5]
        print characterFileName
        if cmds.namespace(exists=characterNamespace):
            print "Rig Installed"
        else:
            cmds.file(characterFileName, i=True, namespace=characterNamespace)

        cmds.namespace(setNamespace=":")

        # Unlock
        characterContainer = (characterNamespace + ":character_container")
        cmds.lockNode(characterContainer, lock=False, lockUnpublished=False)
        """ Check to see if a setup file already exists."""
        """If a setup exists, delete it."""
        setupContainer = exportNamespace + ":Setup"
        if cmds.objExists(setupContainer):
            cmds.select(setupContainer)
            cmds.lockNode(lock=False, lu=False)
            cmds.delete(setupContainer)

        # Import the setup
        # If the setup file exists on disk, import it.  Else we should build the setup
        if cmds.file(setupFileName, q=True, ex=True):
            cmds.file(setupFileName, i=True)
            cmds.setAttr("Setup_grp.visibility", 0)
            constraints = utils.parentToBlueprint(xmlFileName,
                                                  characterNameString)
            parentConstraints = constraints[0]
            scaleConstraints = constraints[1]
            """ Create the setup container if it does not exist """
            try:
                cmds.container(n=setupContainer)
            except:
                pass
            """ Add the setup and geometry groups to the setup container """
            cmds.container(setupContainer,
                           edit=True,
                           addNode="Setup_grp",
                           ihb=True,
                           force=True)
            try:
                cmds.container(setupContainer,
                               edit=True,
                               addNode="Geometry",
                               ihb=True,
                               force=True)
            except:
                pass
            """ Add the game_joint_parentConstraints to the Setup container """
            for constraint in parentConstraints:
                cmds.container(setupContainer,
                               edit=True,
                               addNode=constraint,
                               ihb=True,
                               force=True)
            for constraint in scaleConstraints:
                cmds.container(setupContainer,
                               edit=True,
                               addNode=constraint,
                               ihb=True,
                               force=True)

        else:
            cmds.group(n="Setup_grp", empty=True)
            cmds.setAttr("Setup_grp.visibility", 0)
            try:
                cmds.namespace(add=exportNamespace)
            except:
                pass
            newSetupName = (exportNamespace + ":" + "Setup")

            cmds.select("Setup_grp")
            setupContents = cmds.listConnections("Setup_grp", type="joint")

            if setupContents != None and "game_joints" in (setupContents):
                constraints = utils.parentToBlueprint(xmlFileName,
                                                      characterNameString)
                parentConstraints = constraints[0]
                scaleConstraints = constraints[1]
                """ Add the game_joint_parentConstraints to the Setup container """
                for constraint in parentConstraints:
                    cmds.container(setupContainer,
                                   edit=True,
                                   addNode=constraint,
                                   ihb=True,
                                   force=True)
                for constraint in scaleConstraints:
                    cmds.container(setupContainer,
                                   edit=True,
                                   addNode=constraint,
                                   ihb=True,
                                   force=True)

            else:
                #Create the game joints and return the joint names
                cmds.select("Setup_grp")
                utilInfo = utils.importJointInfo(xmlFileName)
                listJoints = utilInfo

                # parent the joints into the setup group
                cmds.parent(listJoints, "Setup_grp")

                setupContainer = cmds.container(n="Setup",
                                                addNode="Setup_grp",
                                                inc=True,
                                                ihb=True,
                                                includeNetwork=True,
                                                force=True)

                utils.setJointAttrs(xmlFileName)
                constraints = utils.parentToBlueprint(xmlFileName,
                                                      characterNameString)
                parentConstraints = constraints[0]
                scaleConstraints = constraints[1]
                """ Add the game_joint_parentConstraints to the Setup container """
                for constraint in parentConstraints:
                    cmds.container(setupContainer,
                                   edit=True,
                                   addNode=constraint,
                                   ihb=True,
                                   force=True)
                for constraint in scaleConstraints:
                    cmds.container(setupContainer,
                                   edit=True,
                                   addNode=constraint,
                                   ihb=True,
                                   force=True)

                try:
                    cmds.namespace(add=exportNamespace)
                except:
                    pass

                newSetupName = (exportNamespace + ":" + "Setup")
                cmds.rename("Setup", newSetupName)

        newSetupName = (exportNamespace + ":" + "Setup")

        # Use turbineUtils to set bone marking and holding locations.
        turbineUtils.boneMarking()
        holdLocs = turbineUtils.loadHoldLocs()

        # add holding locs to the setup container
        cmds.container(newSetupName,
                       edit=True,
                       addNode=holdLocs,
                       inc=True,
                       ihb=True,
                       includeNetwork=True,
                       force=True)

        cmds.namespace(set=":")

        cmds.lockNode(characterContainer, lock=True, lockUnpublished=True)
        cmds.lockNode(newSetupName, lock=True, lockUnpublished=True)
        cmds.deleteUI(self.UIElements["window"])

        currentUser = getUser()

        niceName = (currentUser)[1]
        cmds.headsUpMessage(self.characterName + " has been installed " +
                            niceName)

        return (characterContainer, newSetupName)
Ejemplo n.º 11
0
    def setupInstallProc(self, characterName):
        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(characterName, create=False)
        setupDir = projectDirs[1]
        xmlDir = projectDirs[2]
        rigDir = projectDirs[3]
        characterFileName = projectDirs[5]
        xmlFileName = projectDirs[7]

        selItem = cmds.textScrollList(
            self.SaveTemplateUIElements["characterList"], q=True, si=True)

        setupFileName = (setupDir + selItem[0] + ".ma")

        # use turbineUtils to find out the namespaces.
        fullCharName = turbineUtils.getCharacterInfo()[2]

        characterNamespace = fullCharName
        exportNamespace = fullCharName.replace("Character", "Export")

        try:
            cmds.namespace(add=exportNamespace)
        except:
            pass

        characterNameString = (characterNamespace + ":")

        # Unlock
        characterContainer = (characterNamespace + ":character_container")
        cmds.lockNode(characterContainer, lock=False, lockUnpublished=False)
        """ Check to see if a setup container already exists."""
        """If a setup_grp exists, delete it."""

        setupContainer = turbineUtils.getCharacterInfo()[3]

        # Delete the contents of the setup container
        if cmds.objExists(setupContainer):
            cmds.select(setupContainer)
            cmds.lockNode(lock=False, lu=False)
            setupNodes = cmds.container(setupContainer, q=True, nl=True)
            cmds.delete(setupNodes)

        # Import the setup
        # If the setup file exists on disk, import it.  Else we should build the setup
        if cmds.file(setupFileName, q=True, ex=True):
            cmds.file(setupFileName, i=True)
            #Setup_grp vis to 0
            cmds.setAttr("Setup_grp.visibility", 0)
            """ Create the setup container if it does not exist """
            if cmds.objExists(setupContainer):
                pass
            else:
                cmds.container(n=setupContainer)
        """ Add the setup and geometry groups to the setup container """
        cmds.container(setupContainer,
                       edit=True,
                       addNode="Setup_grp",
                       ihb=True,
                       force=True)
        try:
            cmds.container(setupContainer,
                           edit=True,
                           addNode="Geometry",
                           ihb=True,
                           force=True)
        except:
            pass

        constraints = turbineUtils.parentToBlueprint(xmlFileName,
                                                     characterNameString)
        parentConstraints = constraints[0]
        scaleConstraints = constraints[1]
        """ Add the game_joint_parentConstraints to the Setup container """
        for constraint in parentConstraints:
            cmds.container(setupContainer,
                           edit=True,
                           addNode=constraint,
                           ihb=True,
                           force=True)
        for constraint in scaleConstraints:
            cmds.container(setupContainer,
                           edit=True,
                           addNode=constraint,
                           ihb=True,
                           force=True)

        # Use turbineUtils to set bone marking and holding locations.
        turbineUtils.boneMarking()

        holdLocs = turbineUtils.loadHoldLocs()

        # add holding locs to the setup container
        cmds.container(setupContainer,
                       edit=True,
                       addNode=holdLocs,
                       inc=True,
                       ihb=True,
                       includeNetwork=True,
                       force=True)

        cmds.namespace(set=":")

        cmds.lockNode(characterContainer, lock=True, lockUnpublished=True)
        cmds.lockNode(setupContainer, lock=True, lockUnpublished=True)
        cmds.deleteUI(self.SaveTemplateUIElements["window"])

        # Get the user name and inform the user
        currentUser = getUser()
        niceName = (currentUser)[1]
        cmds.headsUpMessage(self.characterName + " has been installed " +
                            niceName)

        return (characterContainer, setupContainer)