예제 #1
0
def doConnectScaleToCGMTagOnObject(objectList, cgmTag, storageObject):
    attributeList = []

    for obj in objectList:
        userAttrsData = attributes.returnUserAttrsToDict(obj)
        success = False
        for key in userAttrsData.keys():
            if key == cgmTag:
                success = True
                buffer = attributes.addFloatAttributeToObject (storageObject, userAttrsData.get(key), dv = 1 )

        if success:
            attributes.doConnectAttr(buffer,(obj+'.scaleX'))
            attributes.doConnectAttr(buffer,(obj+'.scaleY'))
            attributes.doConnectAttr(buffer,(obj+'.scaleZ'))

        attributeList.append(buffer)
예제 #2
0
def doConnectScaleToCGMTagOnObject(objectList, cgmTag, storageObject):
    attributeList = []

    for obj in objectList:
        userAttrsData = attributes.returnUserAttrsToDict(obj)
        success = False
        for key in userAttrsData.keys():
            if key == cgmTag:
                success = True
                buffer = attributes.addFloatAttributeToObject (storageObject, userAttrsData.get(key), dv = 1 )

        if success:
            attributes.doConnectAttr(buffer,(obj+'.scaleX'))
            attributes.doConnectAttr(buffer,(obj+'.scaleY'))
            attributes.doConnectAttr(buffer,(obj+'.scaleZ'))

        attributeList.append(buffer)
예제 #3
0
def cgmTagToFloatAttr(obj,cgmTag,*a, **kw):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Lays out a seies of objects in column and row format

    ARGUMENTS:
    objectList(string)
    columnNumber(int) - number of columns
    
    RETURNS:
    Nada
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    userAttrsData = attributes.returnUserAttrsToDict(obj)
    success = False
    for key in userAttrsData.keys():
        if key == cgmTag:
            try:
                return attributes.addFloatAttributeToObject (obj, userAttrsData.get(key),*a, **kw )
            except:
                return False
예제 #4
0
def cgmTagToFloatAttr(obj, cgmTag, *a, **kw):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Lays out a seies of objects in column and row format

    ARGUMENTS:
    objectList(string)
    columnNumber(int) - number of columns
    
    RETURNS:
    Nada
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    userAttrsData = attributes.returnUserAttrsToDict(obj)
    success = False
    for key in userAttrsData.keys():
        if key == cgmTag:
            try:
                return attributes.addFloatAttributeToObject(
                    obj, userAttrsData.get(key), *a, **kw)
            except:
                return False
예제 #5
0
    def __init__(self,
                 objName,
                 attrName,
                 attrType=False,
                 value=None,
                 enum=False,
                 initialValue=None,
                 lock=None,
                 keyable=None,
                 hidden=None,
                 *a,
                 **kw):
        """ 
        Asserts object's existance and that it has a transform. Then initializes. If 
        an existing attribute name on an object is called and the attribute type is different,it converts it. All functions
        ignore locks on attributes and will act when called regardless of target settings
        
        
        Keyword arguments:
        obj(string) -- must exist in scene or an ObjectFactory instance
        attrName(string) -- name for an attribute to initialize
        attrType(string) -- must be valid attribute type. If AttrFactory is imported, you can type 'print attrTypesDict'
        enum(string) -- default enum list to set on call or recall
        value() -- set value on call
        initialValue() -- only set on creation
        
        *a, **kw
        
        """
        ### input check
        try:
            #If we have an Object Factory instance, link it
            objName.nameShort
            self.obj = objName
        except:
            #If it fails, check that the object name exists and if so, initialize a new Object Factory instance
            assert mc.objExists(
                objName) is True, "'%s' doesn't exist" % objName
            self.obj = ObjectFactory(objName)

        self.form = attributes.validateRequestedAttrType(attrType)
        self.attr = attrName
        self.children = False
        initialCreate = False

        # If it exists we need to check the type.
        if mc.objExists('%s.%s' % (self.obj.nameShort, attrName)):
            currentType = mc.getAttr('%s.%s' % (self.obj.nameShort, attrName),
                                     type=True)
            if not attributes.validateAttrTypeMatch(
                    attrType, currentType) and self.form is not False:
                if self.obj.refState:
                    return guiFactory.warning(
                        "'%s' is referenced. cannot convert '%s' to '%s'!" %
                        (self.obj.nameShort, attrName, attrType))
                self.doConvert(attrType)

            else:
                self.attr = attrName
                self.form = currentType

        else:
            try:
                if self.form == False:
                    self.form = 'string'
                    attributes.addStringAttributeToObj(self.obj.nameShort,
                                                       attrName, *a, **kw)
                elif self.form == 'double':
                    attributes.addFloatAttributeToObject(
                        self.obj.nameShort, attrName, *a, **kw)
                elif self.form == 'string':
                    attributes.addStringAttributeToObj(self.obj.nameShort,
                                                       attrName, *a, **kw)
                elif self.form == 'long':
                    attributes.addIntegerAttributeToObj(
                        self.obj.nameShort, attrName, *a, **kw)
                elif self.form == 'double3':
                    attributes.addVectorAttributeToObj(self.obj.nameShort,
                                                       attrName, *a, **kw)
                elif self.form == 'enum':
                    attributes.addEnumAttrToObj(self.obj.nameShort, attrName,
                                                *a, **kw)
                elif self.form == 'bool':
                    attributes.addBoolAttrToObject(self.obj.nameShort,
                                                   attrName, *a, **kw)
                elif self.form == 'message':
                    attributes.addMessageAttributeToObj(
                        self.obj.nameShort, attrName, *a, **kw)
                else:
                    guiFactory.warning(
                        "'%s' is an unknown form to this class" % (self.form))
                    return False

                initialCreate = True

            except:
                guiFactory.warning("'%s.%s' failed to add" %
                                   (self.obj.nameShort, attrName))

        self.updateData(*a, **kw)

        if enum:
            try:
                self.setEnum(enum)
            except:
                guiFactory.warning("Failed to set enum value of '%s'" % enum)

        if initialValue is not None and initialCreate:
            self.set(initialValue)

        elif value is not None:
            self.set(value)

        if type(keyable) is bool:
            self.doKeyable(keyable)

        if type(hidden) is bool:
            self.doHidden(hidden)

        if type(lock) is bool:
            self.doLocked(lock)
예제 #6
0
def eelFinSwimmer (controlSurface,waveControlObject):
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>auto swim stuff
    """ Creating our deformation surface """
    deformMeshBuffer = mc.duplicate (controlSurface)
    deformMesh = mc.rename (deformMeshBuffer[0],(controlSurface+'_defmesh'))
    """ Creates  our wave deformer """
    deformerBuffer = mc.nonLinear (deformMesh, type = 'wave', name = 'swimWave')
    waveDeformer = mc.rename (deformerBuffer[0], 'waveDeformer')
    waveDeformerHandle = mc.rename (deformerBuffer[1], 'waveDeformerHandle')
    """ move the handle """
    mc.setAttr ((waveDeformerHandle+'.rx'),90)
    mc.setAttr ((waveDeformerHandle+'.ry'),90)
    """ set some variables """
    mc.setAttr ((waveDeformer+'.dropoff'),1)
    mc.setAttr ((waveDeformer+'.dropoffPosition'),1)
    mc.setAttr ((waveDeformer+'.maxRadius'),2)
    """ make our blendshape node and reorder things"""
    blendshapeNode = mc.blendShape (deformMesh, controlSurface, name = 'swim_bsNode' )
    mc.reorderDeformers ("tweak5", blendshapeNode[0],controlSurface)
    """ add some attrs to our wave control object """
    attributes.addSectionBreakAttrToObj (waveControlObject, 'swim')
    attributes.addFloatAttributeToObject (waveControlObject, 'auto', 0, 1, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'speed', -100, 100, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'wavelength', 0, 10, 5)
    attributes.addFloatAttributeToObject (waveControlObject, 'amplitude', 0, 10, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'dropoff', 0, 1, 1)
    attributes.addFloatAttributeToObject (waveControlObject, 'dropoffPosition', 0, 1, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'minRadius', 0, 10, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'maxRadius', 0, 10, 10)
    """ connect a few attrs """
    mc.connectAttr ((waveControlObject+'.auto'),(blendshapeNode[0]+'.'+deformMesh))
    mc.connectAttr ((waveControlObject+'.wavelength'),(waveDeformer+'.wavelength'))
    mc.connectAttr ((waveControlObject+'.amplitude'),(waveDeformer+'.amplitude'))
    mc.connectAttr ((waveControlObject+'.dropoff'),(waveDeformer+'.dropoff'))
    mc.connectAttr ((waveControlObject+'.dropoffPosition'),(waveDeformer+'.dropoffPosition'))
    mc.connectAttr ((waveControlObject+'.minRadius'),(waveDeformer+'.minRadius'))
    mc.connectAttr ((waveControlObject+'.maxRadius'),(waveDeformer+'.maxRadius'))
    """ set some good base values """
    mc.setAttr ((waveControlObject+'.speed'),1)
    mc.setAttr ((waveControlObject+'.wavelength'),4)
    mc.setAttr ((waveControlObject+'.amplitude'),.3)
    mc.setAttr ((waveControlObject+'.dropoff'),1)
    mc.setAttr ((waveControlObject+'.dropoffPosition'),1)
    mc.setAttr ((waveControlObject+'.maxRadius'),2)
    """ sets up swim speed """
    nodes.offsetCycleSpeedControlNodeSetup (waveDeformer,(waveControlObject+'.speed'),90,-10)
예제 #7
0
def rigSpine (crvName,tailCntrlJoints,waveControlObject,splitJoints):
    """ Rebuild curve - with actual curve in it!"""
    """ first have to make our reg spine""" 
    mc.rebuildCurve (crvName, ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=(splitJoints), d=1, tol=5)
    """ Make joint chains"""
    spineJoints = joints.createJointsFromCurve (crvName,'spine')
    """ set joint radius """
    joints.setGoodJointRadius (spineJoints,1)
    """ Orienting the joint chain """
    joints.orientJointChain (spineJoints, 'xyz', 'zup')
    
    """ Renaming the joint chain """
    spineJointsBuffer = names.renameJointChainList (spineJoints, 'tailStart', 'tail')
    spineJoints = spineJointsBuffer
    """ removing initial bind from the spine curve """
    mc.delete ('bindPose1')
    mc.delete ('skinCluster1')
    """ Makes our control surface """
    controlSurface = makeJointControlSurfaceFish(spineJoints[0],tailCntrlJoints,'y','tail')
    """ parenting the tail joints """
    rigging.parentListToHeirarchy (tailCntrlJoints)
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>auto swim stuff
    """ Creating our deformation surface """
    deformMeshBuffer = mc.duplicate (controlSurface)
    deformMesh = mc.rename (deformMeshBuffer[0],(controlSurface[0]+'_defmesh'))
    """ Creates  our wave deformer """
    deformerBuffer = mc.nonLinear (deformMesh, type = 'wave', name = 'swimWave')
    waveDeformer = mc.rename (deformerBuffer[0], 'waveDeformer')
    waveDeformerHandle = mc.rename (deformerBuffer[1], 'waveDeformerHandle')
    """ move the handle """
    position.movePointSnap (waveDeformerHandle,spineJoints[0])
    mc.setAttr ((waveDeformerHandle+'.rx'),90)
    mc.setAttr ((waveDeformerHandle+'.ry'),90)
    """ set some variables """
    mc.setAttr ((waveDeformer+'.dropoff'),1)
    mc.setAttr ((waveDeformer+'.dropoffPosition'),1)
    mc.setAttr ((waveDeformer+'.maxRadius'),2)
    """ make our blendshape node and reorder things"""
    blendshapeNode = mc.blendShape (deformMesh, controlSurface[0], name = 'swim_bsNode' )
    mc.reorderDeformers ("tweak2", blendshapeNode[0],controlSurface[0])
    """ add some attrs to our wave control object """
    attributes.addSectionBreakAttrToObj (waveControlObject, 'swim')
    attributes.addFloatAttributeToObject (waveControlObject, 'auto', min = 0, max = 1, dv =0)
    attributes.addFloatAttributeToObject (waveControlObject, 'speed', -100, 100, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'wavelength', 0, 10, 5)
    attributes.addFloatAttributeToObject (waveControlObject, 'amplitude', 0, 10, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'dropoff', 0, 1, 1)
    attributes.addFloatAttributeToObject (waveControlObject, 'dropoffPosition', 0, 1, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'minRadius', 0, 10, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'maxRadius', 0, 10, 10)
    """ connect a few attrs """
    mc.connectAttr ((waveControlObject+'.auto'),(blendshapeNode[0]+'.'+deformMesh))
    mc.connectAttr ((waveControlObject+'.wavelength'),(waveDeformer+'.wavelength'))
    mc.connectAttr ((waveControlObject+'.amplitude'),(waveDeformer+'.amplitude'))
    mc.connectAttr ((waveControlObject+'.dropoff'),(waveDeformer+'.dropoff'))
    mc.connectAttr ((waveControlObject+'.dropoffPosition'),(waveDeformer+'.dropoffPosition'))
    mc.connectAttr ((waveControlObject+'.minRadius'),(waveDeformer+'.minRadius'))
    mc.connectAttr ((waveControlObject+'.maxRadius'),(waveDeformer+'.maxRadius'))
    """ set some good base values """
    mc.setAttr ((waveControlObject+'.speed'),1)
    mc.setAttr ((waveControlObject+'.wavelength'),4)
    mc.setAttr ((waveControlObject+'.amplitude'),.3)
    mc.setAttr ((waveControlObject+'.dropoff'),1)
    mc.setAttr ((waveControlObject+'.dropoffPosition'),1)
    mc.setAttr ((waveControlObject+'.maxRadius'),2)
    """ sets up swim speed """
    nodes.offsetCycleSpeedControlNodeSetup (waveDeformer,(waveControlObject+'.speed'),90,-10)
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>> Head control and joint
    headJointBuffer = mc.duplicate ('head_anim')
    headJoint = mc.rename (headJointBuffer, 'head_jnt')
    headCtrlGrp = rigging.groupMeObject ('head_anim',True)
    #mc.parent (headJoint, spineJoints[0])
    mc.parent (headJoint, 'move_anim')
    contsBuffer = mc.parentConstraint (spineJoints[0], headCtrlGrp, maintainOffset = True)
    mc.rename (contsBuffer,(headCtrlGrp+'_prntConst'))
    contsBuffer = mc.parentConstraint ('head_anim', headJoint, maintainOffset = True)
    mc.rename (contsBuffer,(headJoint+'_prntConst'))
    mc.parent (headCtrlGrp,'move_anim')
    
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Clean stuff
    """ deform group """
    deformGrp = mc.group (n= 'swimDeform_grp', w=True, empty=True)
    mc.parent (waveDeformerHandle,deformGrp)
    mc.parent (deformMesh,deformGrp)
    mc.setAttr ((deformGrp+'.v'), 0)
    mc.setAttr ((controlSurface[0]+'.v'),0)
    """ delete placement stuff """
    mc.delete ('curvePlacementStuff')
    mc.parent (tailCntrlJoints[0],waveControlObject)
    mc.parent (deformGrp, 'rigStuff_grp')

    
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>> Ctrl Joints to Ctrls
    ctrlSize = (distance.returnAverageDistanceBetweenObjects (tailCntrlJoints))
    curves.parentShape ('head_anim', 'sampleCtrlZ')
    for ctrl in tailCntrlJoints:
        rigging.makeObjCtrl (ctrl,ctrlSize)
 
    #>>>>>>>>>>>>>>>>>>>>>Store skin joint data
    """ check for master skin info group """
    name = 'spine'
    if mc.objExists ('master_skinJntList_grp'):
        masterSkinJointList = ('master_skinJntList_grp')
    else:
        masterSkinJointList = mc.group (n= ('master_skinJntList_grp'), w=True, empty=True)
        mc.parent(masterSkinJointList,'rigStuff_grp')
    """ check for segment skin info group """
    if mc.objExists (name+'_skinJntList_grp'):
        skinJointList = (name+'_skinJntList_grp')
    else:
        skinJointList = mc.group (n= (name+'_skinJntList_grp'), w=True, empty=True)
    mc.parent (skinJointList,masterSkinJointList)
    attributes.storeObjNameToMessage (skinJointList,masterSkinJointList)
    """ store the skin joint data """
    for jnt in spineJoints:
        attributes.storeObjNameToMessage (jnt,skinJointList)
    attributes.storeObjNameToMessage (headJoint,skinJointList)
예제 #8
0
    def __init__(self,objName,attrName,attrType = False,value = None,enum = False,initialValue = None,lock = None,keyable = None, hidden = None, *a, **kw):
        """ 
        Asserts object's existance and that it has a transform. Then initializes. If 
        an existing attribute name on an object is called and the attribute type is different,it converts it. All functions
        ignore locks on attributes and will act when called regardless of target settings
        
        
        Keyword arguments:
        obj(string) -- must exist in scene or an ObjectFactory instance
        attrName(string) -- name for an attribute to initialize
        attrType(string) -- must be valid attribute type. If AttrFactory is imported, you can type 'print attrTypesDict'
        enum(string) -- default enum list to set on call or recall
        value() -- set value on call
        initialValue() -- only set on creation
        
        *a, **kw
        
        """
        ### input check
        try:
            #If we have an Object Factory instance, link it
            objName.nameShort
            self.obj = objName
        except:
            #If it fails, check that the object name exists and if so, initialize a new Object Factory instance
            assert mc.objExists(objName) is True, "'%s' doesn't exist" %objName
            self.obj = ObjectFactory(objName)
        
        self.form = attributes.validateRequestedAttrType(attrType)
        self.attr = attrName
        self.children = False
        initialCreate = False
        
        # If it exists we need to check the type. 
        if mc.objExists('%s.%s'%(self.obj.nameShort,attrName)):
            currentType = mc.getAttr('%s.%s'%(self.obj.nameShort,attrName),type=True)
            if not attributes.validateAttrTypeMatch(attrType,currentType) and self.form is not False:
                if self.obj.refState:
                    return guiFactory.warning("'%s' is referenced. cannot convert '%s' to '%s'!"%(self.obj.nameShort,attrName,attrType))                   
                self.doConvert(attrType)             
                
            else:
                self.attr = attrName
                self.form = currentType
                
        else:
            try:
                if self.form == False:
                    self.form = 'string'
                    attributes.addStringAttributeToObj(self.obj.nameShort,attrName,*a, **kw)
                elif self.form == 'double':
                    attributes.addFloatAttributeToObject(self.obj.nameShort,attrName,*a, **kw)
                elif self.form == 'string':
                    attributes.addStringAttributeToObj(self.obj.nameShort,attrName,*a, **kw)
                elif self.form == 'long':
                    attributes.addIntegerAttributeToObj(self.obj.nameShort,attrName,*a, **kw) 
                elif self.form == 'double3':
                    attributes.addVectorAttributeToObj(self.obj.nameShort,attrName,*a, **kw)
                elif self.form == 'enum':
                    attributes.addEnumAttrToObj(self.obj.nameShort,attrName,*a, **kw)
                elif self.form == 'bool':
                    attributes.addBoolAttrToObject(self.obj.nameShort,attrName,*a, **kw)
                elif self.form == 'message':
                    attributes.addMessageAttributeToObj(self.obj.nameShort,attrName,*a, **kw)
                else:
                    guiFactory.warning("'%s' is an unknown form to this class"%(self.form))
                    return False
                
                initialCreate = True
                
            except:
                guiFactory.warning("'%s.%s' failed to add"%(self.obj.nameShort,attrName))
         
        self.updateData(*a, **kw)
            
        if enum:
            try:
                self.setEnum(enum)
            except:
                guiFactory.warning("Failed to set enum value of '%s'"%enum)        

        if initialValue is not None and initialCreate:
            self.set(initialValue)
          
        elif value is not None:
            self.set(value)
        
        if type(keyable) is bool:
            self.doKeyable(keyable)   
            
        if type(hidden) is bool:
            self.doHidden(hidden)
            
        if type(lock) is bool:
            self.doLocked(lock)