Ejemplo n.º 1
0
 def connectModules(self):
     '''
     Connects a module to the character component.
     '''
     # Get modules selected from disList
     selList = self.disList.selectedItems()
     for module in selList:
         NodeUtility.connectNodes( self.charNode, 'modules', self.disMods[module.text()], 'characterRoot' )
         
     # Refresh the lists.
     self.updateLists()
Ejemplo n.º 2
0
    def makeGroups( self ):
        # Create character group.
        characterGroup = cmds.createNode( 'transform', name='character' )
        cmds.addAttr( characterGroup, longName='metaParent', dataType='string')
        NodeUtility.connectNodes( self.inNodeName, 'characterGroup', 'character', 'metaParent' )
                
        # Create frame group.
        frameGroup = cmds.createNode( 'transform', name='frame', parent='character' )     
        cmds.addAttr( frameGroup, longName='metaParent', dataType='string' )
        NodeUtility.connectNodes( self.inNodeName, 'frameGroup', 'frame', 'metaParent' )

        # Create rig group.
        rigGroup = cmds.createNode( 'transform', name='rig', parent='character' )
        cmds.addAttr( rigGroup, longName='metaParent', dataType='string' )
        NodeUtility.connectNodes( self.inNodeName, 'rigGroup', 'rig', 'metaParent' )
        
        # Create skeleton group.
        skeletonGroup = cmds.createNode( 'transform', name='skeleton', parent='character' )
        cmds.addAttr( skeletonGroup, longName='metaParent', dataType='string' )
        NodeUtility.connectNodes( self.inNodeName, 'skeletonGroup', 'skeleton', 'metaParent' )
Ejemplo n.º 3
0
def loadModule( inFolder, inFileName ):
    '''
    Loads a module into the scene.
    
    @param inFolder: String. Name for the sub-folder the module XML is located.
    @param inFileName: String. Name of the module XML. 
    '''
    dirPath = getPresetPath( FRAME_PRESETS_PATH+inFolder )
    fullPath = dirPath+'/'+inFileName+'.xml'
    xmlFile = readModuleXML( fullPath )
    
    # Create a temp group to put the module inside while creating.
    moduleGroup = '|{0}'.format( cmds.group( em=True, name='TEMP' ) )
    
    # Grab all the bits.
    bits = xmlFile['bits']
    
    # Make each bit.
    tick = 0
    storeBitConnections = []

    while tick < len(bits):
        if bits[0]['parent'] == 'None':
            bitParent = moduleGroup
        else:
            bitParent = moduleGroup+bits[0]['parent']
        
        bitName = bits[0]['name']
        bitPlugs = bits[0]['plugs']
        shapePlugs = bits[0]['shape']
        bitComponents = bits[0]['components']
        
        # Make the bit.
        if cmds.objExists( bitParent ):
            newBit = cmds.makeGLBit( name=bitName, objecttype=bits[0]['shapeType'] )            
            cmds.parent( newBit, bitParent )
            
            # From this point we use the long name for the bit. This avoids any
            # name clashes.
            fullBitName = '{0}{1}'.format( bitParent, newBit )
            
            # Setup plugs for transform and custom attributes.
            for plug in bitPlugs:
                if not NodeUtility.attributeCheck( fullBitName, plug['name'] ):
                    NodeUtility.addPlug( fullBitName, plug['name'], plug['attrType'], plug['attrDataType'] )
                    if plug['value'] is not None:
                        NodeUtility.setPlug( fullBitName, plug['name'], plug['value'], inAttrDataType=plug['attrDataType'] )
                else:          
                    # Setup position and rotation.
                    NodeUtility.setPlug( fullBitName, plug['name'], plug['value'] )
            
            # Setup plugs for shape attributes.
            shapeName = cmds.listRelatives( fullBitName, shapes=True )
            fullShapeName = '{0}|{1}'.format( fullBitName, shapeName[0] )
            for plug in shapePlugs:
                if plug['attrDataType'] == 'TdataCompound' or plug['attrDataType'] == 'matrix':
                    # We skip compound nodes at this stage. They are for the child arrow drawing and must be
                    # hooked up after all the objects are created.
                    connectionChild = '{0}{1}'.format( moduleGroup, plug['value'] )
                    storeBitConnections.append( { 'parent':fullBitName, 'child':connectionChild } )
                elif plug['attrDataType'] == 'message':
                    print 'MESSAGE'
                else:
                    NodeUtility.setPlug( fullShapeName, plug['name'], plug['value'], inAttrDataType=plug['attrDataType'] )
            
            # Setup bit components.
            for comp in bitComponents:
                compType = comp['name']
                
                # We have to special case components that have additional kwargs.
                if compType == 'CurveControlComponent':
                    # Handle curve control component type.
                    for plug in comp['plugs']:
                        if plug['name'] == 'curveType':
                            curveType = plug['value']
                    newComp = components.addComponentToObject( compType, inObject=fullBitName, curveType=curveType )
                else:
                    # Handle basic component.
                    newComp = components.addComponentToObject( compType, inObject=fullBitName )

                for plug in comp['plugs']:
                    # Bit of a hack with the parentName attribute. This attr is setup when the component is created.
                    # So there is no need to apply the stored plug value from the XML.
                    if plug['attrDataType'] == 'message':
                        if plug['name'] != 'parentName':
                            if plug['value'] != 'None':
                                sourcePlug = plug['value'].split('.')
                                NodeUtility.connectNodes( sourcePlug[0], sourcePlug[1], newComp.name(), plug['name'] )
                    else:
                        NodeUtility.setPlug( newComp.name(), plug['name'], plug['value'], inAttrDataType=plug['attrDataType'] )
                    
            # Remove the bit from the list
            bits.remove( bits[0] )
        #tick = tick+1
            
    # Now do the hook ups for the child arrows.
    for i in storeBitConnections:
        NodeUtility.setBitChild( i['parent'], i['child'] )