Esempio n. 1
0
 def inLayer( self , layerData ):
     for ln in layerData:
         if cmds.ls( ln[0] ) != []:
             cmds.delete( ln[0] )
         cmds.createDisplayLayer( name=ln[0] )
         print ln[0]
         map ( lambda item : cmds.editDisplayLayerMembers( ln[0] , item )  , ln[1] )
Esempio n. 2
0
 def constructLayer(self , theFile ):
     layers = [ x for x in cmds.ls(type="displayLayer" ) if x!= 'defaultLayer' ]
     if layers != []:
         cmds.delete( layers ) 
     self.layerData = self.xml2layer( theFile )
     print 'self.layerData : ' , self.layerData 
     for x in self.layerData :
         cmds.select( x[1] )
         print x[0]
         cmds.createDisplayLayer(n=x[0])            
         cmds.select(d=1)
Esempio n. 3
0
def drawCurve( target,start,end,colour,samples ):
	# print target,start,end,samples,colour
	# make locator, constrain to target
	cmds.spaceLocator( name="myLocator" )
	cmds.select( target )
	cmds.select( "myLocator", add=True )
	cmds.pointConstraint()

	# make a new render layer with locator, and change display colour
	cmds.select( "myLocator" )
	exists = cmds.objExists( "AnimationCurves" )
	if ( exists==False ):
		cmds.createDisplayLayer( name="AnimationCurves", number=1, nr=True )
		cmds.createDisplayLayer( name="Spheres", number=1, nr=True )
		cmds.setAttr( "AnimationCurves.color", colour )
		cmds.setAttr( "Spheres.color", 16 )		

	# make a list of all the frames where points for the curve will be created
	frameList = []
	frameList.append( start )
	length = end - start
	samples = cmds.intField( samplesField, q=1, v=1 )
	interval = int( length / (samples-1) ) # using int() to ensure integer frame numbers
	for i in range( 1,samples ):
		frameList.append( start+interval*i )
	frameList.append( end )

	# make a list of tuples containing the locations of the target/locator for every frame needed
	xFormList = []
	n = 0
	for frame in ( frameList ):
		x = cmds.getAttr( "myLocator.tx",time=frame )
		y = cmds.getAttr( "myLocator.ty",time=frame )
		z = cmds.getAttr( "myLocator.tz",time=frame )
		currentXForm = ( x,y,z )
		xFormList.append( currentXForm )
		cmds.sphere( n="sphere"+str(n), r=0.2 )
		cmds.move( x,y,z, "sphere"+str(n), a=True )
		n+=1
		# print frame, "= ", x,y,z
	cmds.editDisplayLayerMembers( "Spheres", "sphere*", nr=True )

	# create curve using list of tuples
	cmds.curve( p=xFormList, d=1, ws=True )
	cmds.rename( target+"_animation_curve" )
	cmds.group( target+"_animation_curve", "sphere*", n="curve" )
	# add curve to animation curves layer
	cmds.editDisplayLayerMembers( "AnimationCurves", "curve", nr=True )
	cmds.delete("myLocator")
	cmds.button( ccButton, e=1, en=0 )
	cmds.frameLayout( buttonGroup, e=1, l="Delete curve before creating another" )
Esempio n. 4
0
	def imageCard(self):
		selImage=mc.fileDialog()
		material=mc.shadingNode('lambert',asShader=1)
		fileNode=mc.shadingNode('file',asTexture=1)
		mc.setAttr(fileNode+'.fileTextureName',selImage,typ='string')
		mc.connectAttr(fileNode+'.outColor', material+'.color')
		sizeFactor=0.01
		imageSize=mc.getAttr(fileNode+'.outSize')
		modelPlane=mc.polyPlane(w=imageSize[0][0]*sizeFactor,h=imageSize[0][1]*sizeFactor,sx=1,sy=1,n='modelPlane',ax=[0,1,0],ch=0)
		mc.hyperShade(modelPlane,assign=material)
		if not mc.objExists('layer_ModelTemplate'): 
			mc.createDisplayLayer(name='layer_ModelTemplate')
			mc.setAttr('layer_ModelTemplate.displayType',2)
		mc.editDisplayLayerMembers('layer_ModelTemplate',modelPlane)
Esempio n. 5
0
def createDisplayLayer( geoGroup, layerDisplayMode=2 ):
    """
    createDisplayLayer( 'model_dnt', 2 )
    """
    MC.select(geoGroup)
    lyr = MC.createDisplayLayer(name='geo_layer')
    MC.setAttr(lyr+'.displayType', layerDisplayMode)
    return lyr
    def DrawJointMotionPaths( self, roots ):
        """ Gathers points for each joint of each root and build motion paths (optimized to only cycle thru timeline once) """
        # prep the data structure
        keypoints = {}
        for root in roots:
            keypoints[root] = {}
            #.split(':')[-1]
            joints = [j for j in mc.listRelatives( root, allDescendents=True ) if j in self.traceableObjs]  # TODO: just get the nearby joints by projecting them all onto the viewing plane and finding the distance
            for j in joints:
                keypoints[root][j] = []
        # cycle through the timeline and record data
        for t in range(int(mc.playbackOptions(q=True,minTime=True)), int(mc.playbackOptions(q=True,maxTime=True))+1):
            mc.currentTime(t)
            for root in roots:
                #.split(':')[-1]
                joints = [j for j in mc.listRelatives( root, allDescendents=True ) if j in self.traceableObjs]
                for j in joints:
                    keypoints[root][j].append( mc.xform( j, q=True, ws=True, translation=True ) )
        # use the data to build motion curves
        cols = [9,12,13,14,15,17,18,23,29,31]   # color indices for the display layers
        for root in roots:
            joints = [j for j in mc.listRelatives( root, allDescendents=True ) if j in self.traceableObjs]
            if len(joints) > 0:
                traceGroup = mc.group(n="%s_MotionTraces"%root,empty=True)
                curves = []
                for num, j in enumerate(joints):
                    curve = bmt.CurveMotionTrace( j, keys=keypoints[root][j] )
                    curveGeom = curve.construct("%s_trace"%j)
                    curves.append( curveGeom )   # add the motion paths to the trace's search list and set up the DTWs

                    displayLayerName = "%s_MotionPaths"%j#.split(':')[-1]
                    if not mc.objExists(displayLayerName):
                        mc.createDisplayLayer(name=displayLayerName)
                        mc.setAttr("%s.color"%displayLayerName, cols[num])  
                        mc.editDisplayLayerMembers( displayLayerName, curveGeom )
                    else:
                        objs = mc.editDisplayLayerMembers(displayLayerName, query=True )
                        if objs:
                            objs.append( curveGeom )
                        else:
                            objs = [curveGeom]
                        mc.editDisplayLayerMembers( displayLayerName, objs )
                mc.parent(curves, traceGroup)
                mc.parent(traceGroup, root)
                mc.select(cl=True)
Esempio n. 7
0
def MakeMouthSndJnt():
    mouthPnt = mc.filterExpand (sm=31)
    mc.select (cl=1)
    lx_mouthJnt=[]
    lx_num =1
    for lx_i in mouthPnt :
        lx_pos = mc.xform (lx_i ,q=1,ws =1,t=1)
        lx_jnt = mc.joint (n=("snd_mouthLip"+str(lx_num )),p=(lx_pos [0],lx_pos [1],lx_pos [2]),radius= 0.1)
        lx_mouthJnt .append(lx_jnt )
        mc.select (cl=1)
        lx_num += 1
    mc.select (lx_mouthJnt,r=True )
    mc.createDisplayLayer (name="Layer_MouthSnd",num = 1,nr=1)
    mc.setAttr ("Layer_MouthSnd.displayType",0)
    mc.setAttr ("Layer_MouthSnd.color",4)
    mc.group(n = "grp_mouthSnd01",w=1,em=1)
    mc.select (all=1)
    mc.select (cl=1)
    mc.parent(lx_mouthJnt ,"grp_mouthSnd01")
Esempio n. 8
0
def _getLayer(layerName, create):
    '''Convenience method to get, and create if necessary, one of
	   Massive layers'''
    layer = ""
    layers = mc.ls(layerName, type="displayLayer")
    if create and not layers:
        layers = [mc.createDisplayLayer(name=layerName, empty=True)]
        mc.setAttr("%s.visibility" % layers[0], False)
    if layers:
        layer = layers[0]
    return layer
Esempio n. 9
0
def setup_bbox_hierarchy(scene_nodes):
    bbox_layer = cmds.ls("bbox_layer", type="displayLayer")
    if not bbox_layer:
        bbox_layer = [cmds.createDisplayLayer(name="bbox_layer")]

    for node in sorted(scene_nodes, key=len):
        bbox = setup_bbox(node, bbox_layer)
        add_bbox_parent(node, bbox)

    # Set levelOfDetail attr to "Bounding Box".
    cmds.setAttr("{0}.levelOfDetail".format(bbox_layer[0]), 1)
Esempio n. 10
0
def layerPathRibbons():
	global listIsoparm
	global nameCurveSelect
	global sLocator
	global eLocator
	global meshRib
	
	if not cmds.objExists('IsopRibLayer'):
		#Create Display Layers
		cmds.createDisplayLayer( noRecurse=True, name='IsopRibLayer' )
		cmds.createDisplayLayer( noRecurse=True, name='PathRibLayer' )
		cmds.createDisplayLayer( noRecurse=True, name='SurfaceRibLayer')
		cmds.createDisplayLayer( noRecurse=True, name='MeshRibLayer')
		cmds.createDisplayLayer( noRecurse=True, name='LocatorsRibLayer')
	cmds.editDisplayLayerMembers( 'IsopRibLayer', listIsoparm )
	cmds.editDisplayLayerMembers( 'PathRibLayer', nameCurveSelect )
	cmds.editDisplayLayerMembers( 'SurfaceRibLayer', nameCurveSelect +'Loft' )
	cmds.editDisplayLayerMembers( 'LocatorsRibLayer', sLocator )
	cmds.editDisplayLayerMembers( 'LocatorsRibLayer', eLocator )
	cmds.editDisplayLayerMembers( 'MeshRibLayer', meshRib[0] )
Esempio n. 11
0
def createSkeletonControls():
    #setting up layers to put the joints and controls into
    cmds.createDisplayLayer(n ='Controls')
    cmds.createDisplayLayer(n ='Joints')

    #starting to find all the joints
    originalSelection = cmds.ls(sl = True)[0]
    allJoints = []
    allJoints.append(originalSelection)
    relativeList = cmds.listRelatives(allJoints[0], ad = True)
    #Maya recurses, so it goes from the bottom and returns up
    relativeList.reverse()
    for relative in relativeList:
        allJoints.append(relative)
    for i in range(0, len(allJoints)):
        if i == 0:
        #at the root
            createMayaBox(allJoints[i], '', True)
            continue
        parentName = cmds.listRelatives(allJoints[i], ap = True)[0]
        createMayaBox(allJoints[i], parentName, False)
    return cmds.select(originalSelection)
Esempio n. 12
0
    def setupSceneForAnimation(self, file):
        print 'setup scene.........................'
        print file
        """ Create a fileType node set to animation """

        import tap.tools.maya.createFileTypeNode as createFileTypeNode
        """ Looks for the file type node, and creates one if it does not find one """
        turbineFileTypeNode = ""

        typeNode = pm.mel.eval("$temp = `getLayerTypeNode`;")

        dlgResult = True
        if dlgResult == True:
            createFileTypeNode.createFileTypeNode("AnimationNode")
        """ Populate the node options with the character prefix and destination directory. """
        cmds.select('transform*')
        fileTypeNode = cmds.ls(sl=True)

        prefixAttr = (fileTypeNode[0] + '.FilePrefix')
        dataDirAttr = (fileTypeNode[0] + '.DataDirectory')

        dataDirVal = ('character/' + self.characterName + '/animation')
        prefixVal = self.characterName.partition('_')[0]

        cmds.setAttr(prefixAttr, prefixVal, type='string')
        cmds.setAttr(dataDirAttr, dataDirVal, type='string')
        """ Determine a layer name based off the file name """
        layerNameA = file.replace('.ma', '')
        prefixValExt = (prefixVal + '_')
        layerName = layerNameA.replace(prefixValExt, '')
        """ Put the setup on the layer """

        cmds.select('Setup_grp', hi=True)
        cmds.select(fileTypeNode, hi=True, add=True)
        setupContents = cmds.ls(sl=True)

        cmds.createDisplayLayer(n=layerName)

        print 'done........................'
Esempio n. 13
0
def run(params, rig):
    for num, element in enumerate(params['layers']):
        nodes = [x.name() for x in element['objects']]
        if not cmds.objExists(element['name']):
            display_layer = cmds.createDisplayLayer(nodes, n=element['name'])
        else:
            cmds.editDisplayLayerMembers(element['name'], nodes)
            display_layer = element['name']

        cmds.setAttr('{}.visibility'.format(display_layer), element['visible'])
        for attr in ('displayType', 'shading', 'texturing', 'playback'):
            attr_name = '{}.{}'.format(display_layer, attr)
            cmds.setAttr(attr_name, element[attr])
 def CreateDisplayLayers(self):
     cmds.select(ScenePrepClass.GroupName)
     LayerName = ScenePrepClass.GroupName + "_layer"
     if cmds.objExists(LayerName):
         cmds.delete(LayerName)
     cmds.createDisplayLayer(name = LayerName , nr = False)
     print "Primary display Layer Created"
     
     cmds.select(cmds.listRelatives(cmds.ls(cameras = True, lights = True),parent = True))
     try:
         cmds.select("UserLights", add = True)
     except:
         pass
     try:
         cmds.select("CMLightRig", add = True)
     except:
         pass
     LayerName = "CM Lights and Cameras"
     if cmds.objExists(LayerName):
         cmds.delete(LayerName)
     cmds.createDisplayLayer(name = LayerName , nr = False)
     print "Lights and cameras layer Created"
Esempio n. 15
0
 def TriangulateLows(self):
     if cmds.objExists("Triangulated"):
         pass
     else:
         cmds.createDisplayLayer(noRecurse=True,
                                 name='Triangulated',
                                 empty=True)
     for each in Tri_List:
         cmds.select(each, add=True)
         cmds.delete()
     for each in List_Low:
         cmds.select(each, add=True)
         Name = cmds.ls(sl=1, o=1)
         Mesh = Name[0]
         cmds.duplicate()
         cmds.rename('Tri_' + Mesh)
         cmds.Triangulate()
         Tri_List.append(cmds.ls(sl=1, o=1))
         Name = cmds.ls(sl=1, o=1)
         Mesh = Name[0]
         cmds.editDisplayLayerMembers('Triangulated', Name, noRecurse=True)
         cmds.select(clear=True)
Esempio n. 16
0
def create_imagePlanes():
    front_ip = cmds.imagePlane(name="front_IP",
                               fileName="front_ref.jpg",
                               lookThrough="front",
                               showInAllViews=False)
    cmds.move(0, 0, -950)
    fnt_layer = cmds.createDisplayLayer(name="front_ref_L")
    cmds.setAttr("{}.displayType".format(fnt_layer), 2)
    cmds.imagePlane(name="side_IP",
                    fileName="side_ref.jpg",
                    lookThrough="side",
                    showInAllViews=False)
    cmds.move(-950, 0, 0)
    cmds.rotate(0, 90, 0)
    side_layer = cmds.createDisplayLayer(name="side_ref_L")
    cmds.setAttr("{}.displayType".format(side_layer), 2)
    cmds.imagePlane(name="back_IP",
                    fileName="back_ref.jpg",
                    lookThrough="back",
                    showInAllViews=False)
    cmds.move(0, 0, 950)
    cmds.rotate(0, 180, 0)
    back_layer = cmds.createDisplayLayer(name="back_ref_L")
    cmds.setAttr("{}.displayType".format(back_layer), 2)
 def prepareOrginialGeo(self,*args):
     sel = cmds.ls(sl=True)[0]
     if '_org' in sel:
         blendshape_base_geo = cmds.duplicate(sel,n="{0}_blendshape".format(sel.split('_org')[0]))
         layers = cmds.ls(type='displayLayer')
         if "org_geo_layer" not in layers:
             org_layer = cmds.createDisplayLayer(n="org_geo_layer",e=True)
             cmds.editDisplayLayerMembers(org_layer,sel,blendshape_base_geo,noRecurse=True)
             cmds.setAttr("{0}.displayType".format(org_layer),2)
         elif "org_geo_layer" in layers:
             cmds.editDisplayLayerMembers(org_layer,sel,noRecurse=True)
             cmds.setAttr("{0}.displayType".format(org_layer),2)
     else:
         cmds.confirmDialog(m="Please Select The Orginial Geo!")
     cmds.select(sel,blendshape_base_geo,r=True)
Esempio n. 18
0
def add_capsule(radius=None, half_height=None):
    if not radius:
        radius = 42
    if not half_height:
        half_height = 86

    trueHalfHeight = (half_height * 2) - (radius * 2)
    capsule = cmds.polyCylinder(name="collision_capsule",
                                r=radius,
                                h=trueHalfHeight,
                                sx=18,
                                sy=1,
                                sz=5,
                                ax=[0, 0, 1],
                                rcp=True,
                                cuv=3,
                                ch=True)
    cmds.setAttr(capsule[0] + ".tz", half_height + 2.2)
    cmds.setAttr(capsule[0] + ".rz", 90)

    cmds.addAttr(capsule[0], ln="Radius", dv=radius, keyable=True)
    cmds.addAttr(capsule[0], ln="HalfHeight", dv=half_height, keyable=True)

    expr = str(capsule[1] + ".radius = " + capsule[0] + ".Radius;\n" +
               capsule[1] + ".height = (" + capsule[0] + ".HalfHeight*2) - (" +
               capsule[0] + ".Radius*2);")
    cmds.expression(s=expr, o=capsule[1], ae=1, uc="all")

    cmds.setAttr(capsule[0] + ".overrideEnabled", 1)
    cmds.setAttr(capsule[0] + ".overrideColor", 18)
    cmds.setAttr(capsule[0] + ".overrideShading", 0)

    cmds.addAttr(capsule[0], ln="Shaded", dv=0, min=0, max=1, keyable=True)
    cmds.connectAttr(capsule[0] + ".Shaded", capsule[0] + ".overrideShading")

    cmds.parentConstraint("root", capsule[0], mo=True)
    cmds.select(capsule[0], r=True)
    capsuleDisplayLayer = cmds.createDisplayLayer(nr=True,
                                                  name="Collision Capsule")
    cmds.setAttr(capsuleDisplayLayer + ".displayType", 2)
    cmds.setAttr(capsuleDisplayLayer + ".v", 0)

    for attr in ["tx", "ty", "tz", "rx", "ry", "rz", "sx", "sy", "sz"]:
        cmds.setAttr(capsule[0] + "." + attr,
                     lock=True,
                     keyable=False,
                     channelBox=False)
    cmds.select(clear=True)
Esempio n. 19
0
def customEvaluatorDisplay(customEvaluatorName):
    """
	Take the named custom evaluator and put each of its evaluation clusters
	into a different display layer with a rotating colouring. (It's rotating
	because the display layers only have a small number of colours available
	whereas there could be a large number of clusters in the scene.)

	Although it only works for DAG nodes this provides a simple visual cue
	of how the custom evaluator has created its clusters.
	"""
    print 'Assigning clusters to display layers'
    clusterInfo = cmds.evaluatorInternal(name=customEvaluatorName,
                                         query=True,
                                         clusters=True)
    if clusterInfo == None:
        print 'No clusters on evaluator %s' % customEvaluatorName
    else:
        idx = 0
        colour = 1
        try:
            while idx < len(clusterInfo):
                clusterSize = clusterInfo[idx]
                clusterContents = []
                for subIndex in range(1, clusterSize + 1):
                    objectName = clusterInfo[idx + subIndex]
                    if 'dagNode' in cmds.nodeType(objectName, inherited=True):
                        clusterContents.append(objectName)
                # No sense creating a display layer when no DAG objects exist
                if len(clusterContents) > 0:
                    cmds.select(clusterContents)
                    newLayer = cmds.createDisplayLayer(noRecurse=True,
                                                       name='%sLayer' %
                                                       customEvaluatorName)
                    cmds.setAttr('%s.drawInfo.color' % newLayer, colour)
                    colour = (colour + 1) % 256
                    print '%s contains %s' % (newLayer, clusterContents)
                idx += clusterSize + 1
        except Exception, ex:
            print 'ERR: Bad cluster information at index %d (%s)' % (idx,
                                                                     str(ex))
Esempio n. 20
0
def create_imagePlanes():
    front_ip = cmds.imagePlane(
        name="front_IP",
        fileName="front_ref.jpg",
        lookThrough="front",
        showInAllViews=False)
    cmds.move(0,0,-950)
    cmds.createDisplayLayer(name="front_ref_L")
    cmds.imagePlane(
        name="side_IP",
        fileName="side_ref.jpg",
        lookThrough="side",
        showInAllViews=False)
    cmds.move(-950,0,0)
    cmds.rotate(0,90,0)
    cmds.createDisplayLayer(name="side_ref_L")
    cmds.imagePlane(
        name="back_IP",
        fileName="back_ref.jpg",
        lookThrough="back",
        showInAllViews=False)
    cmds.move(0,0,950)
    cmds.rotate(0,180,0)
    cmds.createDisplayLayer(name="back_ref_L")
Esempio n. 21
0
def shot(cam):

    # verifier la sauvegarde avant de faire la creation d'un shot...

    filename = mc.file(q=True, sn=True)
    charvalue = filename.split('/')

    # Verifier que l'on est dans le projet

    if not project_name in charvalue:
        sys.exit('You are not working in the Project !!')

    if not 'seq' in charvalue:
        sys.exit('This is not a sequence...')

    current_seq = charvalue[5]
    shot_path = project_dir + '/prod/seq/' + current_seq + '/shots/'

    print(shot_path + '<= shot_path')

    # get cam_name

    shot_name = cam.split('_')
    shot_name = str(shot_name[-1])

    if os.path.exists(shot_path + shot_name):

        sys.exit('Shot name already existing.')

    os.mkdir(shot_path + shot_name)
    os.mkdir(shot_path + shot_name + '/cloth')
    os.mkdir(shot_path + shot_name + '/export')

    # create FX folder

    os.mkdir(shot_path + shot_name + '/fx')
    os.mkdir(shot_path + shot_name + '/fx/houdini')
    os.mkdir(shot_path + shot_name + '/fx/fur')

    # create Anim folder

    os.mkdir(shot_path + shot_name + '/anim')
    os.mkdir(shot_path + shot_name + '/anim/V000')
    os.mkdir(shot_path + shot_name + '/playblasts')

    # create lookdev folder

    os.mkdir(shot_path + shot_name + '/lookdev')
    os.mkdir(shot_path + shot_name + '/lookdev/guerilla')
    os.mkdir(shot_path + shot_name + '/lookdev/textures')

    # virer les autres cameras

    all_cams = mc.ls('cams')
    all_cams = mc.listRelatives(all_cams, c=True)
    all_cams.remove(cam)

    for each in all_cams:

        mc.delete(each)

    mc.parent(cam, w=True)
    mc.delete('cams')
    mc.rename(cam, 'cam')

    # create display layers for props, sets, building
    sel = mc.ls('props', 'sets', 'building')

    # voir si c'est bien utile...
    mc.createDisplayLayer(sel, name='assembly', nr=True)

    mc.file(rename=shot_path + shot_name + '/anim/V000/anim.ma')
    mc.file(save=True, type='mayaAscii')
Esempio n. 22
0
	GeoLocList.append(GeoT)
	
count = 1
clearSelect = True	
mc.select(clear=True)
for JNT in ('_FK_JNT','_IK_JNT','_SkinJNT'):
	mc.select(clear=True)
	mc.joint( n = GeoDic[0]+JNT,p = (GeoLocList[0][0],GeoLocList[0][1],GeoLocList[0][2]), rad = 0.4)
	for i in range(1,7):
		mc.joint( n = GeoDic[i]+JNT,p = (GeoLocList[i][0],GeoLocList[i][1],GeoLocList[i][2]), rad = 0.4)
		mc.joint(GeoDic[i-1]+JNT,e= True, zso = True,oj='xyz',sao  ='yup')
		if i=3:
			mc.select(clear=True)
		
	mc.select(GeoDic[0]+JNT , GeoDic[1]+JNT ,GeoDic[2]+JNT )
	mc.createDisplayLayer(noRecurse=True,n = JNT + '_Layer')

		
for i in range(3):	
	mc.parentConstraint(GeoDic[i]+'_FK_JNT',GeoDic[i]+'_IK_JNT', GeoDic[i]+'_SkinJNT')

mc.select(GeoDic[1] + '_IK_JNT')
mc.joint(e= True,spa = True,ch = True)
mc.ikHandle( sj=GeoDic[0]+'_IK_JNT', ee=GeoDic[2]+'_IK_JNT',sol = 'ikRPsolver')
mc.rename('ikHandle1','ArmIKhandle')


#create hand
mc.select(clear=True)
wirstT = mc.xform('Wrist_SkinJNT',q = True,t = True,ws = True)
mc.joint( p = (wirstT[0],wirstT[1],wirstT[2]))
def importReferenceVideo_Process(*args):
    
    videoFile = cmds.textField("refQuickTimeMovieTextField", q = True, text = True)
    videoNiceName = videoFile.rpartition("/")[2].partition(".")[0]
    
    #create the polygon plane
    moviePlane = cmds.polyPlane(w = 720, h = 480, sx = 1, sy = 1, name = ( videoNiceName + "_ShotReferencePlane"))[0]
    cmds.select(moviePlane)
    cmds.addAttr(longName='transparency', defaultValue=0, minValue=0, maxValue=1, keyable = True)

    cmds.createDisplayLayer(name = ( videoNiceName + "_Layer"), nr = True)
    
    cmds.select(clear = True)

    cmds.setAttr(moviePlane + ".tz", -10000)
    cmds.setAttr(moviePlane + ".rx", -180)
    cmds.makeIdentity(moviePlane, apply = True, r = 1, t = 1, s = 1)

    
    #create the camera for the plane
    camera = cmds.camera()[0]
    cam = cmds.rename(camera, (videoNiceName + "_Reference_Cam"))
    
    #position the camera
    constraint = cmds.parentConstraint(moviePlane, cam)[0]
    cmds.delete(constraint)
    
    cmds.setAttr(cam + ".rotateX", 90)
    cmds.setAttr(cam + ".translateY", -800)
    cmds.setAttr(cam + "Shape.focalLength", 38)
    
    #constrain the camera to the plane
    cmds.parentConstraint(moviePlane, cam, mo = True)
    
    #scale up the plane a tad, and lock all attrs
    cmds.setAttr(moviePlane + ".sx", 1.055, lock = True)
    cmds.setAttr(moviePlane + ".sy", 1.055, lock = True)
    cmds.setAttr(moviePlane + ".sz", 1.055, lock = True)
    cmds.setAttr(moviePlane + ".tx", lock = True)
    cmds.setAttr(moviePlane + ".ty", lock = True)
    cmds.setAttr(moviePlane + ".tz", lock = True)
    cmds.setAttr(moviePlane + ".rx", lock = True)
    cmds.setAttr(moviePlane + ".ry", lock = True)
    cmds.setAttr(moviePlane + ".rz", lock = True)
    
    #lock down the camera attrs
    cmds.setAttr(cam + ".tx", lock = True)
    cmds.setAttr(cam + ".ty", lock = True)
    cmds.setAttr(cam + ".tz", lock = True)
    cmds.setAttr(cam + ".rx", lock = True)
    cmds.setAttr(cam + ".ry", lock = True)
    cmds.setAttr(cam + ".rz", lock = True)
    cmds.setAttr(cam + ".sx", lock = True)
    cmds.setAttr(cam + ".sy", lock = True)
    cmds.setAttr(cam + ".sz", lock = True)
    
    
    #create the movie shader/texture and attach to plane
    movieShader = cmds.shadingNode("lambert", asShader = True, name = moviePlane + "_M")
    moviePlaceNode = cmds.shadingNode("place2dTexture", asUtility = True)
    movieNode = cmds.shadingNode("movie", asTexture = True)
    
    cmds.connectAttr(moviePlaceNode + ".outUV", movieNode + ".uvCoord")
    cmds.connectAttr(moviePlaceNode + ".outUvFilterSize", movieNode + ".uvFilterSize")
    cmds.connectAttr(movieNode + ".outColor", movieShader + ".color")
    
    #connect the transparency of the shader to the plane attr
    cmds.connectAttr(moviePlane + ".transparency", movieShader + ".transparencyR")
    cmds.connectAttr(moviePlane + ".transparency", movieShader + ".transparencyG")
    cmds.connectAttr(moviePlane + ".transparency", movieShader + ".transparencyB")
    
    
    cmds.setAttr(movieNode + ".fileTextureName", videoFile, type = "string")
    
    #add the material to the movie plane
    cmds.select(moviePlane)
    cmds.hyperShade(assign = movieShader)
    cmds.select(clear = True)
    
    cmds.setAttr(movieNode + ".useFrameExtension", 1)
    
    #make sure that the playback options are updating all viewports
    cmds.playbackOptions(v = "all")
    
    
    #take the frame offset value, and create an expression
    frameOffsetValue = cmds.textField("frameOffsetTextField", q = True, text = True)
    if frameOffsetValue != "":
        expressionString = (movieNode + ".frameExtension = frame + " + str(frameOffsetValue))
        expression = cmds.expression(name = (movieNode + "_expression"), string = expressionString)
        
    else:
        expressionString = (movieNode + ".frameExtension = frame")
        expression = cmds.expression(name = (movieNode + "_expression"), string = expressionString)
def go():
    project = Project()
    environment = Environment()

    # Create a global position locator which will grab Jampa's position despite his scaled translations
    mc.currentTime(0)
    globalPos = mc.spaceLocator(p=[0,0,0])
    globPos = mc.rename(globalPos, "jampaGlobalPos")
    mc.select("jampa_rig_main_global_cc_01")
    mc.select(globPos, add=True)
    mc.pointConstraint(offset=[0,0,0], weight=1)
    mc.orientConstraint(offset=[0,0,0], weight=1)

    # Get transformation variables from globPos locator
    tx = mc.getAttr(globPos+".translateX")
    ty = mc.getAttr(globPos+".translateY")
    tz = mc.getAttr(globPos+".translateZ")
    rx = mc.getAttr(globPos+".rotateX")
    ry = mc.getAttr(globPos+".rotateY")
    rz = mc.getAttr(globPos+".rotateZ")

    # get alembic filepath for scene's animation (requires prior export)
    src = mc.file(q=True, sceneName=True)
    src_dir = os.path.dirname(src)
    checkout_element = project.get_checkout_element(src_dir)
    checkout_body_name = checkout_element.get_parent()
    body = project.get_body(checkout_body_name)
    element = body.get_element(Department.ANIM)
    cache_file = os.path.join(element.get_dir(), "cache", "jampa_rig_main.abc")

    # checkout cfx scene for corresponding shot number
    current_user = environment.get_current_username()
    element = body.get_element(Department.CFX)
    cfx_filepath = element.checkout(current_user)

    #open cfx file 
    if cfx_filepath is not None:
        if not mc.file(q=True, sceneName=True) == '':
            mc.file(save=True, force=True) #save file

        if not os.path.exists(cfx_filepath):
            mc.file(new=True, force=True)
            mc.file(rename=cfx_filepath)
            mc.file(save=True, force=True)
        else:
            mc.file(cfx_filepath, open=True, force=True)

    # import alembic
    command = "AbcImport -mode import \"" + cache_file + "\""
    maya.mel.eval(command)

    # delete all geo except jampa skin and rename
    geometry = mc.ls(geometry=True)
    transforms = mc.listRelatives(geometry, p=True, path=True)
    mc.select(transforms, r=True)
    for geo in mc.ls(sl=True):
        if(geo != "jampa_rig_main_jampa_geo_body"):
            mc.delete(geo)
    collide = "JAMPA_COLLIDE"
    mc.rename("jampa_rig_main_jampa_geo_body", collide)

    # reference robe
    body = project.get_body("jampa_robe")
    element = body.get_element(Department.MODEL)
    robe_file = element.get_app_filepath()
    mc.file(robe_file, reference=True)

    # set robe transforms to variables above
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.translateX", tx)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.translateY", ty)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.translateZ", tz)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.rotateX", rx)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.rotateY", ry)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.rotateZ", rz)

    # make jampa skin a passive collider
    mc.select(collide)
    command = "makeCollideNCloth"
    maya.mel.eval(command)
    rigid_shape = "nRigid_jampa"
    mc.rename("nRigid1", rigid_shape)
    mc.setAttr(rigid_shape+".stickiness", 0.2)
    mc.setAttr(rigid_shape+".friction", 0.5)

    # make cloth objects and display layers of each robe piece
    jampa_torso = "jampa_robe_model_main_robe_torso_01"
    jampa_sash = "jampa_robe_model_main_robe_sash_01"
    jampa_skirt = "jampa_robe_model_main_robe_skirt_01"

    cloth_pieces = {jampa_torso, jampa_sash, jampa_skirt}
    command = "createNCloth 0"
    for cp in cloth_pieces:
        mc.select(cp)
        maya.mel.eval(command)
        mc.rename("nCloth1", "nCloth_"+cp)
        mc.select(cp)
        layername = "cloth_"+cp[:-3].replace("robe_model_main_robe_", "")
        mc.createDisplayLayer(name=layername.upper(), number=1, noRecurse=True)

    # set appropriate values in nucleus node
    nucleus = "nucleus_jampa"
    mc.rename("nucleus1", nucleus)
    mc.setAttr(nucleus+".subSteps", 30)
    mc.setAttr(nucleus+".startFrame", -30)
    mc.setAttr(nucleus+".spaceScale", 0.23)

    mc.currentTime(-50)
def tf_createLayer(layer, colorIndex):
    print(colorIndex)
    cmds.createDisplayLayer( name=layer, e = True )
    #cmds.setAttr('%s' % (layer + ".displayType"), 0)
    cmds.setAttr('%s' % (layer + ".color"), colorIndex - 1)
def importReferenceVideo_Process(*args):

    videoFile = cmds.textField("refQuickTimeMovieTextField", q=True, text=True)

    videoNiceName = videoFile.rpartition("/")[2].partition(".")[0]

    #create the polygon plane

    moviePlane = cmds.polyPlane(w=720,
                                h=480,
                                sx=1,
                                sy=1,
                                name=(videoNiceName +
                                      "_ShotReferencePlane"))[0]

    cmds.select(moviePlane)

    cmds.addAttr(longName='transparency',
                 defaultValue=0,
                 minValue=0,
                 maxValue=1,
                 keyable=True)

    cmds.createDisplayLayer(name=(videoNiceName + "_Layer"), nr=True)

    cmds.select(clear=True)

    cmds.setAttr(moviePlane + ".tz", -10000)

    cmds.setAttr(moviePlane + ".rx", -180)

    cmds.makeIdentity(moviePlane, apply=True, r=1, t=1, s=1)

    #create the camera for the plane

    camera = cmds.camera()[0]

    cam = cmds.rename(camera, (videoNiceName + "_Reference_Cam"))

    #position the camera

    constraint = cmds.parentConstraint(moviePlane, cam)[0]

    cmds.delete(constraint)

    cmds.setAttr(cam + ".rotateX", 90)

    cmds.setAttr(cam + ".translateY", -800)

    cmds.setAttr(cam + "Shape.focalLength", 38)

    #constrain the camera to the plane

    cmds.parentConstraint(moviePlane, cam, mo=True)

    #scale up the plane a tad, and lock all attrs

    cmds.setAttr(moviePlane + ".sx", 1.055, lock=True)

    cmds.setAttr(moviePlane + ".sy", 1.055, lock=True)

    cmds.setAttr(moviePlane + ".sz", 1.055, lock=True)

    cmds.setAttr(moviePlane + ".tx", lock=True)

    cmds.setAttr(moviePlane + ".ty", lock=True)

    cmds.setAttr(moviePlane + ".tz", lock=True)

    cmds.setAttr(moviePlane + ".rx", lock=True)

    cmds.setAttr(moviePlane + ".ry", lock=True)

    cmds.setAttr(moviePlane + ".rz", lock=True)

    #lock down the camera attrs

    cmds.setAttr(cam + ".tx", lock=True)

    cmds.setAttr(cam + ".ty", lock=True)

    cmds.setAttr(cam + ".tz", lock=True)

    cmds.setAttr(cam + ".rx", lock=True)

    cmds.setAttr(cam + ".ry", lock=True)

    cmds.setAttr(cam + ".rz", lock=True)

    cmds.setAttr(cam + ".sx", lock=True)

    cmds.setAttr(cam + ".sy", lock=True)

    cmds.setAttr(cam + ".sz", lock=True)

    #create the movie shader/texture and attach to plane

    movieShader = cmds.shadingNode("lambert",
                                   asShader=True,
                                   name=moviePlane + "_M")

    moviePlaceNode = cmds.shadingNode("place2dTexture", asUtility=True)

    movieNode = cmds.shadingNode("movie", asTexture=True)

    cmds.connectAttr(moviePlaceNode + ".outUV", movieNode + ".uvCoord")

    cmds.connectAttr(moviePlaceNode + ".outUvFilterSize",
                     movieNode + ".uvFilterSize")

    cmds.connectAttr(movieNode + ".outColor", movieShader + ".color")

    #connect the transparency of the shader to the plane attr

    cmds.connectAttr(moviePlane + ".transparency",
                     movieShader + ".transparencyR")

    cmds.connectAttr(moviePlane + ".transparency",
                     movieShader + ".transparencyG")

    cmds.connectAttr(moviePlane + ".transparency",
                     movieShader + ".transparencyB")

    cmds.setAttr(movieNode + ".fileTextureName", videoFile, type="string")

    #add the material to the movie plane

    cmds.select(moviePlane)

    cmds.hyperShade(assign=movieShader)

    cmds.select(clear=True)

    cmds.setAttr(movieNode + ".useFrameExtension", 1)

    #make sure that the playback options are updating all viewports

    cmds.playbackOptions(v="all")

    #take the frame offset value, and create an expression

    frameOffsetValue = cmds.textField("frameOffsetTextField",
                                      q=True,
                                      text=True)

    if frameOffsetValue != "":

        expressionString = (movieNode + ".frameExtension = frame + " +
                            str(frameOffsetValue))

        expression = cmds.expression(name=(movieNode + "_expression"),
                                     string=expressionString)

    else:

        expressionString = (movieNode + ".frameExtension = frame")

        expression = cmds.expression(name=(movieNode + "_expression"),
                                     string=expressionString)
def orangizeRig(prefix):

    #### Orangise hierarchy and set global constraints ####

    if cmds.objExists(prefix + "_Rig_Grp"):
        print "Rig group already exists"
    else:
        jointGrp = cmds.group(em=True, name=prefix + "_Rig_Grp")

    controls = [
        "_Centre", "_L_Foot", "_R_Foot", "_L_Elbow", "_R_Elbow", "_L_Knee",
        "_R_Knee"
    ]

    for i in controls:
        cmds.parent(prefix + i + "_Con", prefix + "_Rig_Grp")

    cmds.parent(prefix + "_Root_Jnt", prefix + "_Rig_Grp")
    cmds.delete(prefix + "_Jnt_Grp")

    cmds.parent(prefix + "_Loc_Grp", prefix + "_Secondary_Loc_Grp",
                prefix + "_Rig_Grp")
    cmds.hide(prefix + "_Loc_Grp", prefix + "_Secondary_Loc_Grp")

    cmds.parentConstraint(prefix + "_Global_Con", prefix + "_Rig_Grp", mo=True)
    cmds.scaleConstraint(prefix + "_Global_Con", prefix + "_Rig_Grp", mo=True)

    #### Display Layers ####

    if (cmds.objExists(prefix + "_Controllers_Layer")):
        cmds.editDisplayLayerMembers(prefix + "_Controllers_Layer",
                                     prefix + "_Global_Con")
    else:
        _ctrl = cmds.select(prefix + "_Global_Con")
        cmds.createDisplayLayer(name=prefix + "_Controllers_Layer")

    for i in controls:
        cmds.editDisplayLayerMembers(prefix + "_Controllers_Layer",
                                     prefix + i + "_Con")

    if (cmds.objExists(prefix + "_Skeleton_Layer")):
        cmds.editDisplayLayerMembers(prefix + "_Skeleton_Layer",
                                     prefix + "_Root_Jnt")
        cmds.editDisplayLayerMembers(prefix + "_Skeleton_Layer",
                                     prefix + "_L_INV_Heel_Jnt")
        cmds.editDisplayLayerMembers(prefix + "_Skeleton_Layer",
                                     prefix + "_R_INV_Heel_Jnt")
        cmds.editDisplayLayerMembers(prefix + "_Skeleton_Layer",
                                     prefix + "_L_Arm_IK")
        cmds.editDisplayLayerMembers(prefix + "_Skeleton_Layer",
                                     prefix + "_R_Arm_IK")

    else:
        _ctrl = cmds.select(prefix + "_Root_Jnt")
        cmds.createDisplayLayer(name=prefix + "_Skeleton_Layer")
        cmds.editDisplayLayerMembers(prefix + "_Skeleton_Layer",
                                     prefix + "_L_INV_Heel_Jnt")
        cmds.editDisplayLayerMembers(prefix + "_Skeleton_Layer",
                                     prefix + "_R_INV_Heel_Jnt")
        cmds.editDisplayLayerMembers(prefix + "_Skeleton_Layer",
                                     prefix + "_L_Arm_IK")
        cmds.editDisplayLayerMembers(prefix + "_Skeleton_Layer",
                                     prefix + "_R_Arm_IK")

    cmds.setAttr("%s.displayType" % (prefix + "_Skeleton_Layer"), 2)
    cmds.setAttr("%s.visibility" % (prefix + "_Skeleton_Layer"), 0)
export_path = sys.argv[-1]
namespace_var = os.path.split(obj_path)[1]
namespace_var = os.path.splitext(namespace_var)[0]

# Import High Res and Low Res modeling as reference
mc.file(obj_path, r=True, type="OBJ", ignoreVersion=True, gl=True, mergeNamespacesOnClash=False, namespace=namespace_var + "HighRes", options="mo=1;")
mc.setAttr(namespace_var + "HighResRN.proxyTag", "HighRes", type="string")
mc.file(obj_path.replace("_out.obj", "-lowres_out.obj"), r=True, type="OBJ", ignoreVersion=True, gl=True, mergeNamespacesOnClash=False, namespace=namespace_var + "LowRes", options="mo=1;")
mc.setAttr(namespace_var + "LowResRN.proxyTag", "LowRes", type="string")

# Create High resolution display layer
all_objects = mc.ls()
for object in all_objects:
    if "LowRes" in object:
        mc.select(object, add=True)
mc.createDisplayLayer(name="Low Resolution", nr=True)
mc.select(clear=True)

# Create Low resolution display layer
all_objects = mc.ls()
for object in all_objects:
    if "HighRes" in object:
        mc.select(object, add=True)
mc.createDisplayLayer(name="High Resolution", nr=True)
mc.setAttr("Low_Resolution.visibility", False)
mc.setAttr("High_Resolution.visibility", True)

# Save file
mc.file(rename=export_path)
mc.file(save=True, type='mayaAscii', f=True)
Esempio n. 29
0
from maya_python_castle.Utils.Utils import Vector3
import maya_python_castle.Utils as Utils
import maya.app.general.positionAlongCurve as mayaGeneral
import maya_python_castle.Doors as Doors
import maya_python_castle.Towers as Towers
import maya_python_castle.Walls as Walls
import maya_python_castle.Ramparts as Ramparts

reload(Utils.Utils)
reload(Walls)
reload(Towers)
reload(Doors)
reload(Ramparts)

if (not cmds.objExists("Ramparts")):
    rampartsLayer = cmds.createDisplayLayer(n="Ramparts", mc=True, num=1)
else:
    print("layer exist deja")


class Castle:
    def __init__(self, interiorRampart, exteriorRampart, groundRampart):

        groupNames = []
        self.interiorRampart = interiorRampart
        self.exteriorRampart = exteriorRampart
        self.groundRampart = groundRampart
        self.interiorRampart.instantiateRampartCurveBased()
        groupNames.append(self.interiorRampart.groupName)
        self.exteriorRampart.instantiateRampartCurveBased()
        groupNames.append(self.exteriorRampart.groupName)
Esempio n. 30
0
def build ( char=None, cleanUp=False ):
    '''
    Builds the specified character
    
    '''
    #Build root structure
    rootSys = root.build()
    
    if not char:
        char = 'defaultChar'

    # import geo
    geoList = geo.importGeo(char)
    for g in geoList:
        cmds.parent( g, rootSys['geoGrp'] )
    
    # Import joints
    joints.importSkel(char)
    
    # Parent joints to root defJnts group
    jnts = cmds.ls(type='joint')
    for j in jnts:
        p = cmds.listRelatives(j, p=1)
        if not p:
            cmds.parent(j, rootSys['defJntsGrp'])

    # Build spine
    spineSys = spine.build( hips='cn_spine_01_defJnt', chest='cn_spine_06_defJnt', head='cn_spine_11_defJnt',numSpineJoints=6, numHeadJoints=6, twistAxis='x', bendAxis='y', cleanUp=cleanUp )
    cmds.parent(spineSys['xformGrp'], rootSys['systemsGrp'])
    spineTarg = cmds.group(empty=True)
    spineTarg = cmds.rename(spineTarg, common.getName(side='cn', rigPart='spine', function='const', nodeType='grp'))
    common.align(spineTarg, spineSys['xformGrp'])
    cmds.parent(spineTarg, rootSys['constGrp'])
    cmds.parentConstraint( spineTarg, spineSys['xformGrp'] )

    # Build limbs
    lf_arm = anom.systems.limb.build( startJoint='lf_shoulder_1_defJnt', middleJoint='lf_arm_1_defJnt', endJoint='lf_hand_defJnt', extraJoint='lf_hand_end_defJnt', side='lf', name='arm', twistJointCount=6 )
    cmds.parent( lf_arm['limbSystem_grp'], rootSys['systemsGrp'] )
    
    rt_arm = anom.systems.limb.build( startJoint='rt_shoulder_1_defJnt', middleJoint='rt_arm_1_defJnt', endJoint='rt_hand_defJnt', extraJoint='rt_hand_end_defJnt', side='rt', name='arm', twistJointCount=6 )
    cmds.parent( rt_arm['limbSystem_grp'], rootSys['systemsGrp'] )
    
    lf_leg = anom.systems.limb.build( startJoint='lf_leg_1_defJnt', middleJoint='lf_knee_1_defJnt', endJoint='lf_foot_defJnt', extraJoint='lf_foot_end_defJnt', side='lf', name='leg', twistJointCount=5, isLeg=True )
    cmds.parent( lf_leg['limbSystem_grp'], rootSys['systemsGrp'] )
    
    rt_leg = anom.systems.limb.build( startJoint='rt_leg_1_defJnt', middleJoint='rt_knee_1_defJnt', endJoint='rt_foot_defJnt', extraJoint='rt_foot_end_defJnt', side='rt', name='leg', twistJointCount=5, isLeg=True )
    cmds.parent( rt_leg['limbSystem_grp'], rootSys['systemsGrp'] )


    
    # Build hands
    lf_hand = anom.systems.hand.build( side='lf', root='lf_hand_root_defJnt',
                                       fingerDict={'thumb':'lf_hand_thumb1_defJnt',
                                                   'index':'lf_hand_index1_defJnt',
                                                   'mid':'lf_hand_mid1_defJnt',
                                                   'pinky':'lf_hand_pinky1_defJnt'},
                                      cleanUp=cleanUp )
    cmds.parent (lf_hand['systemGrp'], rootSys['systemsGrp'])
    cmds.parentConstraint( lf_arm['jointList'][2], lf_hand['systemGrp'], mo=1 ) # Sorry - I know it's horrible but time's running out!! (Bad, bad Duncan... :p)
    
    rt_hand = anom.systems.hand.build( side='rt', root='rt_hand_root_defJnt',
                                       fingerDict={'thumb':'rt_hand_thumb1_defJnt',
                                                   'index':'rt_hand_index1_defJnt',
                                                   'mid':'rt_hand_mid1_defJnt',
                                                   'pinky':'rt_hand_pinky1_defJnt'},
                                      cleanUp=cleanUp )
    cmds.parent (rt_hand['systemGrp'], rootSys['systemsGrp'])
    cmds.parentConstraint( rt_arm['jointList'][2], rt_hand['systemGrp'], mo=1 )
    
    # Build feet
    lf_foot = reverseFoot.build( side = 'lf', jntFoot = lf_leg['jointList'][-1],
                                 ctrlFoot = lf_leg['end_ctrl'],
                                 ikHandleLeg = lf_leg['ikHandle'],
                                 mesh = 'cn_body_render_mesh',
                                 stretchLoc = lf_leg['stretch_positions'][1],
                                 cleanUp = cleanUp
                                 )
    cmds.parent( lf_foot['systemsGrp'], rootSys['systemsGrp'])
    
    rt_foot = reverseFoot.build( side = 'rt',
                                 jntFoot = rt_leg['jointList'][-1],
                                 ctrlFoot = rt_leg['end_ctrl'],
                                 ikHandleLeg = rt_leg['ikHandle'],
                                 mesh = 'cn_body_render_mesh',
                                 stretchLoc = rt_leg['stretch_positions'][1],
                                 cleanUp = cleanUp
                                 )
    cmds.parent( rt_foot['systemsGrp'], rootSys['systemsGrp'])
    
    # Build AutoHips
    lf_autoHip = autoHip.createAutoHip(lf_leg['start_ctrl'], spineSys['hipCtrl'][0], lf_leg['end_ctrl'])
    rt_autoHip = autoHip.createAutoHip(rt_leg['start_ctrl'], spineSys['hipCtrl'][0], rt_leg['end_ctrl'])
    cmds.parent( lf_autoHip['autoHipSystem_grp'], rt_autoHip['autoHipSystem_grp'], rootSys['systemsGrp'])

    # Build Rivets
    lf_shoulder_rivet = rivet.build( targ=lf_arm['start_ctrl'], mesh='cn_body_render_mesh', side='lf', rigPart='arm', cleanUp=cleanUp )
    cmds.parent( lf_shoulder_rivet['follicle'], rootSys['constGrp'] )
    cmds.pointConstraint( lf_shoulder_rivet['constGrp'], cmds.listRelatives(lf_arm['start_ctrl'], p=1)[0] )
    
    rt_shoulder_rivet = rivet.build( targ=rt_arm['start_ctrl'], mesh='cn_body_render_mesh', side='rt', rigPart='arm', cleanUp=cleanUp )
    cmds.parent( rt_shoulder_rivet['follicle'], rootSys['constGrp'] )
    cmds.pointConstraint( rt_shoulder_rivet['constGrp'], cmds.listRelatives(rt_arm['start_ctrl'], p=1)[0] )
    
    lf_eye_rivet = rivet.build( targ='lf_head_eye_defJnt', mesh='cn_body_render_mesh', side='lf', rigPart='eye', cleanUp=cleanUp )
    cmds.parent( lf_eye_rivet['follicle'], rootSys['constGrp'] )
    
    rt_eye_rivet = rivet.build( targ='rt_head_eye_defJnt', mesh='cn_body_render_mesh', side='rt', rigPart='eye', cleanUp=cleanUp )
    cmds.parent( rt_eye_rivet['follicle'], rootSys['constGrp'] )
    
    connectToPuppet()

    # Bind skin
    cmds.select( cmds.listRelatives(rootSys['geoGrp']) )
    anom.core.skinWeights.rebindSkinClusters( char )
    anom.core.skinWeights.setSkinWeights( char )
    cmds.reorderDeformers( 'lf_foot_contact_ffd', 'skincluster_cn_body_render_mesh', 'cn_body_render_mesh' )

    # Make everything follow root the evil way | global scale
    cmds.parentConstraint( rootSys['constGrp'][0], rootSys['systemsGrp'][0], mo=1 )
    cmds.scaleConstraint ( rootSys['constGrp'][0], rootSys['systemsGrp'][0], mo=1 )
    cmds.connectAttr( rootSys['systemsGrp'][0] + '.scale', rootSys['defJntsGrp'][0] + '.scale' )

    invScale = cmds.shadingNode( 'multiplyDivide', asUtility = True, name = 'root_systems_invScale_md' )
    cmds.setAttr( invScale + '.operation', 2 )
    cmds.setAttr( invScale + '.input1', 1, 1, 1, type='double3' )
    cmds.connectAttr( rootSys['systemsGrp'][0] + '.scale', invScale + '.input2' )

    #connect autoHip to inverse world scale
    cmds.connectAttr( invScale + '.output', lf_autoHip['placer'][0] + '.scale' )
    cmds.connectAttr( invScale + '.output', rt_autoHip['placer'][0] + '.scale' )

    #connect follicles to systemGrp scale this fixes errors from the offset at extreme scaling values
    for fol in [ lf_shoulder_rivet['follicle'], rt_shoulder_rivet['follicle'], lf_eye_rivet['follicle'], rt_eye_rivet['follicle'] ]:
        cmds.connectAttr( rootSys['systemsGrp'][0] + '.scale', fol+'.scale' )
        cmds.setAttr( fol+'.v', 0 )

    # finally hide defJnts
    if cleanUp:
        cmds.setAttr( rootSys['offsetCtrl'][0].control +'.jointsVisibility', 0 )

    # create a Layer for the meshes
    cmds.createDisplayLayer( name='MESH_layer', empty=True )
    cmds.editDisplayLayerMembers( 'MESH_layer', rootSys['geoGrp'], noRecurse=True )
    cmds.setAttr( 'MESH_layer.displayType', 2 ) # unselectable

    cmds.select( clear=True )
Esempio n. 31
0
def makeOutline():
    _fullPathList = []
    _selectedList = cmds.ls(sl=True, long=True)
    _subList = cmds.ls("*_Outline", "*Base", "eyes", sl=True, long=True)
    _objectList = list(set(_selectedList) - set(_subList))
    _surfaceShader = "outline_m"
    _displayLayer = "OL"
    _groupName = "outline_GP"

    # if no groups exist
    if not cmds.ls(_groupName, long=True):
        mel.eval('print ("[ {} ] group not found\\n");'.format(_groupName))
        return 

    if not _objectList:
        mel.eval('print ("Outline not needed\\n");')
        return

    for _object in _objectList:
        _tmpList = _object.split('|')
        _rootName = _tmpList[1]
        _mainName = _tmpList[-1]
        
        # find relatives
        if not cmds.listRelatives(_object, s=True, ni=True, f=True, type="mesh"):
            continue

        # 1. If something has outline go to the top
        if cmds.objExists(_rootName + '|' + _groupName + '|' + _mainName + '_Outline'):
            continue
        
        if cmds.objExists(_rootName + '|' + _groupName + '|' + _mainName + 'Base'):
            continue

        #New process
        _duplicate = cmds.duplicate(_object, rr=True)[0]
        _duplicate = cmds.rename(_duplicate, _mainName + '_Outline')
        
        # full path to get parents for unique objects
        cmds.parent(_duplicate, _rootName + '|' + _groupName)
        _fullPath = cmds.ls(sl=True, long=True)[0]
        _fullPathList.append(_fullPath)
        
        # Reverse normals
        mel.eval('ReversePolygonNormals;')
        # you have to do this in forloop because you cant remove multiple checks at once 
        cmds.setAttr(_fullPath + ".doubleSided", 0)
        
        # 3. move object a little inwards
        cmds.select(_fullPath, r=True)
        mel.eval('MovePolygonComponent;')
        cmds.setAttr(cmds.ls(type="polyMoveVertex")[-1] + ".localTranslateZ", -0.1)

        # 5. Delete History
        cmds.select(_fullPath, r=True)
        mel.eval('DeleteHistory;')

        # 6. outline wrap on original model
        _grpPath = _object.rsplit("|", 1)[0]
        _beforeList = cmds.ls(_grpPath, dag=True, tr=True)

        cmds.select(_object, add=True)
        mel.eval('CreateWrap;')
        
        #rename base and put it into outline group
        _afterList = cmds.ls(_grpPath, dag=True, tr=True)
        _afterList = list(set(_afterList) - set(_beforeList))
        cmds.parent(_afterList, _rootName + '|' + _groupName)
        cmds.rename(_afterList[0], _mainName + 'Base')
    
    # 4. Create and assign material
    if len(cmds.ls(_surfaceShader, type="surfaceShader")) <= 0:
        mel.eval('createRenderNodeCB -asShader "surfaceShader" surfaceShader "";')
        _surfaceShader = cmds.rename("outline_m")
        cmds.setAttr(_surfaceShader + ".outColor", 0.1882, 0.0784, 0, type="double3")
    
    cmds.select(_fullPathList, r=True)
    cmds.hyperShade(assign=_surfaceShader)

    # 7. Make layer and then rename to "OL", Lock
    cmds.select(_fullPathList, r=True)
    if len(cmds.ls(_displayLayer, type="displayLayer")) <= 0:
        cmds.createDisplayLayer(name=_displayLayer, number=1, nr=True)
    else:
        cmds.editDisplayLayerMembers(_displayLayer, _fullPathList)
    cmds.setAttr(_displayLayer + ".displayType", 2)

    
    if not _fullPathList:
        mel.eval('print ("Outline not needed\\n");')
        return

    # to tell tool user that processing has ended
    _printMessage = "{} objects made with outlines\\n".format(len(_fullPathList))
    mel.eval('print (" '+ _printMessage +' ");')
    return
Esempio n. 32
0
def createDisplayer(value):
    if not dispLayerName(value) in dispLayerList():
        mc.createDisplayLayer(empty=True, n=dispLayerName(value))
Esempio n. 33
0
def finalize(sm, surf, color=22, sphVis=1, lra=1, mode=1, scale=1):

    # Get names
    sm_dfrm = sm[0]
    sm_hdl = sm[1]
    off = cmds.listRelatives(sm_hdl, p=1)[0]
    riv = cmds.listRelatives(off, p=1)[0]
    geo = cmds.listRelatives(surf, p=1)[0]
    if ':' in geo:
        geo = geo.split(':')[1]

    # Falloff
    cmds.addAttr(sm_hdl,
                 ln='falloffMode_keyable',
                 nn='Falloff Mode',
                 at='enum',
                 en='Volume:Surface',
                 k=1)
    cmds.connectAttr('{}.falloffMode_keyable'.format(sm_hdl),
                     '{}.falloffMode'.format(sm_dfrm))

    # Falloff curve
    cmds.addAttr(sm_hdl,
                 ln='falloffCurve',
                 at='enum',
                 en='None:Linear:Smooth:Spline',
                 k=1,
                 dv=2)
    cmds.connectAttr('{}.falloffCurve'.format(sm_hdl),
                     '{}.falloffCurve[0].falloffCurve_Interp'.format(sm_dfrm))

    # Sphere
    shp = cmds.listRelatives(off, s=1)[0]
    crv2, make2 = cmds.circle(n=shp.replace('Shape', '2'), nr=[0, 1, 0])
    shp2 = cmds.listRelatives(crv2, s=1)[0]
    cmds.setAttr('{}.sx'.format(crv2), .75)
    cmds.setAttr('{}.sy'.format(crv2), .75)
    cmds.setAttr('{}.sz'.format(crv2), .75)
    #cmds.setAttr ('{}.ihi'.format (make2), 0)
    cmds.makeIdentity(crv2, a=1, s=1)
    crv3, make3 = cmds.circle(n=shp.replace('Shape', '3'), nr=[1, 0, 0])
    shp3 = cmds.listRelatives(crv3, s=1)[0]
    cmds.setAttr('{}.sx'.format(crv3), .75)
    cmds.setAttr('{}.sy'.format(crv3), .75)
    cmds.setAttr('{}.sz'.format(crv3), .75)
    #cmds.setAttr ('{}.ihi'.format (make3), 0)
    cmds.makeIdentity(crv3, a=1, s=1)
    cmds.parent(shp2, off, add=1, s=1)
    cmds.parent(shp3, off, add=1, s=1)

    hist = cmds.listHistory(shp)
    for h in hist:
        if 'makeNurbCircle' in h:
            make = h
            cmds.setAttr('{}.ihi'.format(h), 0)
        if 'transformGeometry' in h:
            cmds.setAttr('{}.ihi'.format(h), 0)

    hist = cmds.listHistory(shp2)
    for h in hist:
        if 'makeNurbCircle' in h:
            make2 = h
            cmds.setAttr('{}.ihi'.format(h), 0)
        if 'transformGeometry' in h:
            cmds.setAttr('{}.ihi'.format(h), 0)

    hist = cmds.listHistory(shp3)
    for h in hist:
        if 'makeNurbCircle' in h:
            make3 = h
            cmds.setAttr('{}.ihi'.format(h), 0)
        if 'transformGeometry' in h:
            cmds.setAttr('{}.ihi'.format(h), 0)

    cmds.connectAttr('{}.falloffRadius'.format(sm_hdl),
                     '{}.radius'.format(make))
    cmds.connectAttr('{}.falloffRadius'.format(sm_hdl),
                     '{}.radius'.format(make2))
    cmds.connectAttr('{}.falloffRadius'.format(sm_hdl),
                     '{}.radius'.format(make3))
    cmds.delete(crv2, crv3)
    cmds.addAttr(sm_hdl, ln='sphere', at='bool', dv=sphVis)
    cmds.setAttr('{}.sphere'.format(sm_hdl), cb=1)
    cmds.connectAttr('{}.sphere'.format(sm_hdl), '{}.v'.format(shp))
    cmds.connectAttr('{}.sphere'.format(sm_hdl), '{}.v'.format(shp2))
    cmds.connectAttr('{}.sphere'.format(sm_hdl), '{}.v'.format(shp3))

    # LRA
    cmds.addAttr(sm_hdl, ln='localRotationAxis', at='bool', dv=lra)
    cmds.setAttr('{}.localRotationAxis'.format(sm_hdl), cb=1)
    cmds.connectAttr('{}.localRotationAxis'.format(sm_hdl),
                     '{}.displayLocalAxis'.format(sm_hdl))

    # Nurbs Curve
    crv = cmds.curve(d=1,
                     p=[(-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, -0.5),
                        (-0.5, 0.5, -0.5), (-0.5, 0.5, 0.5), (-0.5, -0.5, 0.5),
                        (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5),
                        (0.5, -0.5, 0.5), (-0.5, -0.5, 0.5), (0.5, -0.5, 0.5),
                        (0.5, 0.5, 0.5), (0.5, 0.5, -0.5), (0.5, -0.5, -0.5),
                        (-0.5, -0.5, -0.5), (-0.5, 0.5, -0.5)])
    crv_shp = cmds.listRelatives(crv, s=1)[0]
    for a in ['sx', 'sy', 'sz']:
        cmds.setAttr('{}.{}'.format(crv, a), .4)
    cmds.makeIdentity(crv, a=1, s=1)
    for a in ['sx', 'sy', 'sz']:
        cmds.setAttr('{}.{}'.format(crv, a), scale)
    cmds.makeIdentity(crv, a=1, s=1)
    cmds.parent(crv, off)
    for a in ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']:
        if 't' in a or 'r' in a:
            cmds.setAttr('{}.{}'.format(crv, a), 0)
        elif 's' in a:
            cmds.setAttr('{}.{}'.format(crv, a), 1)
    cmds.parent(crv_shp, sm_hdl, add=1, s=1)
    cmds.delete(crv)
    shps = cmds.listRelatives(sm_hdl, s=1)
    for shp1 in shps:
        if 'curve' in shp1:
            crv_shp2 = shp1
    if mode == 1:
        vis_dv = 0
    elif mode == 2:
        vis_dv = 1
    cmds.addAttr(sm_hdl,
                 ln='visualizationMode',
                 at='enum',
                 en='Handle:Nurbs Curve',
                 dv=vis_dv)
    cmds.setAttr('{}.visualizationMode'.format(sm_hdl), cb=1)
    cmds.connectAttr('{}.visualizationMode'.format(sm_hdl),
                     '{}.v'.format(crv_shp2))
    rev = cmds.createNode('reverse', n='{}_REV'.format(sm_hdl))
    cmds.setAttr('{}.ihi'.format(rev), 0)
    cmds.connectAttr('{}.visualizationMode'.format(sm_hdl),
                     '{}.inputX'.format(rev))
    cmds.connectAttr('{}.outputX'.format(rev),
                     '{}.displayHandle'.format(sm_hdl))

    # Color
    cmds.setAttr('{}.overrideEnabled'.format(sm_hdl), 1)
    cmds.setAttr('{}.overrideColor'.format(sm_hdl), color)

    # Group
    grp = 'stickyMods_GRP'
    if not cmds.objExists(grp):
        cmds.group(n=grp, em=1, w=1)
    geoGrp = '{}_MOD_GRP'.format(geo)
    if not cmds.objExists(geoGrp):
        cmds.group(n=geoGrp, em=1, w=1)
        cmds.parent(geoGrp, grp)
    cmds.parent(riv, geoGrp)

    # Layer
    dl = 'stickyMods_LAY'
    if not cmds.objExists(dl):
        cmds.createDisplayLayer(n=dl, e=1)
        cmds.editDisplayLayerMembers(dl, grp)
        cmds.setAttr('{}.color'.format(dl), color)
    try:
        cmds.disconnectAttr('stickyMods_LAY.drawInfo',
                            '{}.drawOverride'.format(shp))
        cmds.disconnectAttr('stickyMods_LAY.drawInfo',
                            '{}.drawOverride'.format(shp2))
        cmds.disconnectAttr('stickyMods_LAY.drawInfo',
                            '{}.drawOverride'.format(shp3))
    except:
        pass
    cmds.setAttr('{}.overrideEnabled'.format(shp), 1)
    cmds.setAttr('{}.overrideColor'.format(shp), 29)
    cmds.setAttr('{}.overrideEnabled'.format(shp2), 1)
    cmds.setAttr('{}.overrideColor'.format(shp2), 29)
    cmds.setAttr('{}.overrideEnabled'.format(shp3), 1)
    cmds.setAttr('{}.overrideColor'.format(shp3), 29)

    # Cleanup
    sms = cmds.ls('{}_*_MOD'.format(geo))
    if sms:
        cnt = len(sms) + 1
    else:
        cnt = 1
    sm_hdl = cmds.rename(sm_hdl, '{}_{}_MOD'.format(geo, cnt))
    cmds.rename(crv_shp2, '{}_{}_CRVShape'.format(geo, cnt))
    sm_dfrm = '{}SoftMod'.format(sm_hdl)
    cmds.rename(riv, '{}_{}_MOD_RIV'.format(geo, cnt))
    cmds.rename(off, '{}_{}_MOD_OFF'.format(geo, cnt))
    sm_dfrm = cmds.rename(sm_dfrm, '{}_{}_MOD_DFRM'.format(geo, cnt))
    cmds.select(sm_hdl)
    sm = [sm_dfrm, sm_hdl]

    return sm
Esempio n. 34
0
    def CreateProxies(self):
        thumbsOn = True
        fingersNum = 4
        toesNum = 1
        spineNum = 4
        neckNum = 2
        self.Main = "Proxies_Main"
        self.Proxies_Root = "Proxies_Root"
        self.Proxies_SpineTop = "Proxies_SpineTop"
        self.Proxies_Head = "Proxies_Head"
        self.Proxies_Jaw = "Proxies_Jaw"
        self.Proxies_JawTip = "Proxies_JawTip"
        self.Proxies_HeadTip = "Proxies_HeadTip"
        self.Proxies_L_Eye = "Proxies_L_Eye"
        self.Proxies_R_Eye = "Proxies_R_Eye"
        self.Proxies_SpineOrientLocator = "Proxies_SpineOrientLocator"
        self.Proxies_NeckOrientLocator = "Proxies_NeckOrientLocator"
        # todo : SET UNITS TO CENTIMETERS
        # todo :  Close NODE EDITOR
        # Joint Base
        Main = cmds.circle(n=self.Main, c=(0, 0, 0), nr=(0, 1, 0), sw=360, r=8, d=3, ut=0, tol=0.01, s=8, ch=0)

        # Root
        self.CreatePrixyNode(name=self.Proxies_Root,
                             mScale=[1.6, 1.6, 1.6],
                             mMvoe=[0, 15.25, 0],
                             lScale=[0.4, 0.4, 0.4])

        # Top
        self.CreatePrixyNode(name=self.Proxies_SpineTop,
                             PC=self.Proxies_Root,
                             mScale=[1.6, 1.6, 1.6],
                             mMvoe=[0, 6.6, 0],
                             lScale=[0.4, 0.4, 0.4])

        # Aim Locator
        loc = cmds.spaceLocator(n=self.Proxies_SpineOrientLocator)
        cmds.parent(self.Proxies_SpineOrientLocator, self.Main)
        cmds.pointConstraint(self.Proxies_Root, self.Proxies_SpineOrientLocator)
        cmds.aimConstraint(self.Proxies_SpineTop, self.Proxies_SpineOrientLocator, aimVector=[0, 1, 0],
                           upVector=[1, 0, 0], worldUpType="vector", worldUpVector=[1, 0, 0])
        cmds.setAttr("%s.visibility" % self.Proxies_SpineOrientLocator, 0)

        # Spline
        self.spineProxies = []
        i2 = spineNum - 1
        nPad = "0"
        for i in range(1, spineNum):
            self.ProxyBase("Proxies_Spine_%s%s" % (nPad, i))
            cmds.group("Proxies_Spine_%s%s" % (nPad, i), n="Proxies_Spine_%s%s_GRP" % (nPad, i))
            cmds.xform(os=True, piv=[0, 0, 0])
            cmds.makeIdentity("Proxies_Spine_%s%s_GRP" % (nPad, i), apply=True, t=1, r=1, s=1)
            cmds.pointConstraint(self.Proxies_Root, self.Proxies_SpineTop, "Proxies_Spine_%s%s_GRP" % (nPad, i))
            cmds.orientConstraint(self.Proxies_SpineOrientLocator, "Proxies_Spine_%s%s_GRP" % (nPad, i))
            cmds.setAttr("Proxies_Spine_%s%s_GRP_pointConstraint1.Proxies_RootW0" % (nPad, i), i2)
            cmds.setAttr("Proxies_Spine_%s%s_GRP_pointConstraint1.Proxies_SpineTopW1" % (nPad, i), i)
            self.spineProxies.append("Proxies_Spine_%s%s" % (nPad, i))
            # CONNECTORS
            if i == 1:
                self.ProxyConnectors(self.Proxies_Root, "Proxies_Spine_%s%s" % (nPad, i))
            else:
                self.ProxyConnectors("Proxies_Spine_%s%s" % (nPad, i), "Proxies_Spine_%s%s" % (nPad, i - 1))
            i2 = i2 - 1
        self.ProxyConnectors("Proxies_Spine_%s%s" % (nPad, spineNum - 1), self.Proxies_SpineTop)

        cmds.select(self.spineProxies)
        cmds.pickWalk(d="up")
        spineProxiesG = cmds.ls(sl=True)

        # Head
        self.CreatePrixyNode(name=self.Proxies_Head,
                             PC=self.Proxies_SpineTop,
                             mMvoe=[0, 2, 0],
                             mScale=[1.25, 1.25, 1.25])

        # CREATE AIM LOCATOR TO ORIENT NECK PROXIES
        cmds.spaceLocator(n=self.Proxies_NeckOrientLocator)
        cmds.parent(self.Proxies_NeckOrientLocator, self.Main)
        cmds.pointConstraint(self.Proxies_SpineTop, self.Proxies_NeckOrientLocator)
        cmds.aimConstraint(self.Proxies_Head, self.Proxies_NeckOrientLocator, aimVector=[0, 1, 0],
                           upVector=[1, 0, 0], worldUpType="vector", worldUpVector=[1, 0, 0])
        cmds.setAttr("%s.visibility" % self.Proxies_NeckOrientLocator, 0)

        # Neck
        self.neckProxies = []
        i2 = neckNum - 1
        nPad = "0"
        for i in range(1, neckNum):
            self.ProxyBase("Proxies_Neck_%s%s" % (nPad, i))
            cmds.scale(0.8, 0.8, 0.8, "Proxies_Neck_%s%s" % (nPad, i), r=True)
            cmds.makeIdentity("Proxies_Neck_%s%s" % (nPad, i), apply=True, t=1, r=1, s=1)
            cmds.group("Proxies_Neck_%s%s" % (nPad, i), n="Proxies_Neck_%s%s_GRP" % (nPad, i))
            cmds.xform(os=True, piv=[0, 0, 0])
            cmds.makeIdentity("Proxies_Neck_%s%s_GRP" % (nPad, i), apply=True, t=1, r=1, s=1)
            cmds.pointConstraint(self.Proxies_SpineTop, self.Proxies_Head, "Proxies_Neck_%s%s_GRP" % (nPad, i))
            cmds.orientConstraint(self.Proxies_NeckOrientLocator, "Proxies_Neck_%s%s_GRP" % (nPad, i))
            cmds.setAttr("Proxies_Neck_%s%s_GRP_pointConstraint1.Proxies_SpineTopW0" % (nPad, i), i2)
            cmds.setAttr("Proxies_Neck_%s%s_GRP_pointConstraint1.Proxies_HeadW1" % (nPad, i), i)
            self.neckProxies.append("Proxies_Neck_%s%s" % (nPad, i))
            if i == 1:
                self.ProxyConnectors(self.Proxies_SpineTop, "Proxies_Neck_%s%s" % (nPad, i))
            else:
                self.ProxyConnectors("Proxies_Neck_%s%s" % (nPad, i), "Proxies_Neck_%s%s" % (nPad, i - 1))
            i2 = i2 - 1

        cmds.select(self.neckProxies)
        cmds.pickWalk(d="up")
        neckProxiesG = cmds.ls(sl=True)
        self.ProxyConnectors("Proxies_Neck_%s%s" % (nPad, neckNum - 1), self.Proxies_Head)

        # Jaw
        self.CreatePrixyNode(self.Proxies_Jaw,
                             PC=self.Proxies_Head,
                             mMvoe=[0, 0.83, 0.38],
                             isConnect=True)

        self.CreatePrixyNode(self.Proxies_JawTip,
                             PC=self.Proxies_Jaw,
                             mMvoe=[0, -0.83, 1.52],
                             isConnect=True)

        self.CreatePrixyNode(self.Proxies_HeadTip,
                             PC=self.Proxies_Head,
                             mMvoe=[0, 3.38, 0],
                             isConnect=True)
        # Eye
        self.CreatePrixyNode(self.Proxies_L_Eye,
                             PC=self.Proxies_Head,
                             mMvoe=[0.57, 1.53, 1.64],
                             isConnect=True)

        self.CreatePrixyNode(self.Proxies_R_Eye,
                             PC=self.Proxies_Head,
                             mMvoe=[-0.57, 1.53, 1.64],
                             isConnect=True)

        # Arms
        armLoop = 1
        armPrefx = "_L"
        armMultiplier = 1.0
        while armLoop <= 2:

            Clavicle = "Proxies" + armPrefx + "_Clavicle"
            self.CreatePrixyNode(Clavicle,
                                 PC=self.Proxies_SpineTop,
                                 mMvoe=[armMultiplier * 1.25, 0.5, 0],
                                 isConnect=True,
                                 isParent=True)

            Shoulder = "Proxies" + armPrefx + "_Shoulder"
            self.CreatePrixyNode(Shoulder,
                                 PC=Clavicle,
                                 mMvoe=[armMultiplier * 1.7, 0, 0],
                                 isConnect=True,
                                 isParent=True)

            Elbow = "Proxies" + armPrefx + "_Elbow"
            self.CreatePrixyNode(Elbow,
                                 PC=Shoulder,
                                 mMvoe=[armMultiplier * 3.5, 0, 0],
                                 isConnect=True)

            Wrist = "Proxies" + armPrefx + "_Wrist"
            self.CreatePrixyNode(Wrist,
                                 PC=Elbow,
                                 mMvoe=[armMultiplier * 3.5, 0, 0],
                                 isConnect=True)

            ElbowG = "Proxies" + armPrefx + "_Elbow_GRP"
            cmds.group(n=ElbowG, em=True)
            PCons = cmds.pointConstraint(Elbow, ElbowG)
            cmds.delete(PCons)
            cmds.parent(Elbow, ElbowG)
            cmds.makeIdentity(ElbowG, apply=True, t=1, r=1, s=1)
            cmds.move(0, 0, 0.001, "%s.scalePivot" % ElbowG, "%s.rotatePivot" % ElbowG, r=True)
            cmds.pointConstraint(Shoulder, Wrist, ElbowG, mo=True)
            cmds.parent(ElbowG, Wrist, self.Main)

            Palm = "Proxies" + armPrefx + "_Palm"
            self.CreatePrixyNode(Palm,
                                 PC=Wrist,
                                 mMvoe=[armMultiplier * 0.7, 0, 0],
                                 mScale=[0.7, 0.7, 0.7],
                                 lScale=[0.175, 0.175, 0.175],
                                 isConnect=True,
                                 isParent=True)

            if thumbsOn:
                ThumbJ1 = "Proxies" + armPrefx + "_ThumbJ1"
                self.CreatePrixyNode(ThumbJ1,
                                     PC=Wrist,
                                     mMvoe=[armMultiplier * 0.45, 0, 0.51],
                                     mScale=[0.75, 0.75, 0.75],
                                     lScale=[0.1875, 0.1875, 0.1875],
                                     isConnect=True,
                                     isParent=True)

                ThumbJ2 = "Proxies" + armPrefx + "_ThumbJ2"
                self.CreatePrixyNode(ThumbJ2,
                                     PC=ThumbJ1,
                                     mMvoe=[armMultiplier * 0, 0, 0.75],
                                     mScale=[0.75, 0.75, 0.75],
                                     lScale=[0.1875, 0.1875, 0.1875],
                                     isConnect=True,
                                     isParent=True)

                ThumbJ3 = "Proxies" + armPrefx + "_ThumbJ3"
                self.CreatePrixyNode(ThumbJ3,
                                     PC=ThumbJ2,
                                     mMvoe=[armMultiplier * 0, 0, 0.75],
                                     mScale=[0.75, 0.75, 0.75],
                                     lScale=[0.1875, 0.1875, 0.1875],
                                     isConnect=True,
                                     isParent=True)

                ThumbJTip = "Proxies" + armPrefx + "_ThumbJTip"
                self.CreatePrixyNode(ThumbJTip,
                                     PC=ThumbJ3,
                                     mMvoe=[armMultiplier * 0, 0, 0.75],
                                     mScale=[0.75, 0.75, 0.75],
                                     lScale=[0.1875, 0.1875, 0.1875],
                                     isConnect=True,
                                     isParent=True)

            fingerIndex = 1
            while fingerIndex <= fingersNum:
                FingerJ1 = "Proxies" + armPrefx + "_Finger_" + str(fingerIndex) + "_J1"
                if fingerIndex == 1:
                    self.ProxyBase(FingerJ1)
                    PCons = cmds.pointConstraint(Wrist, FingerJ1)
                    cmds.delete(PCons)
                    cmds.move(armMultiplier * 1.47, 0, 0, FingerJ1, r=True, os=True, wd=True)
                    if fingersNum == 2:
                        cmds.move(0, 0, 0.25, FingerJ1, r=True)
                        cmds.makeIdentity(FingerJ1, apply=True, t=1, r=1, s=1)
                    elif fingersNum >= 3:
                        cmds.move(0, 0, 0.5, FingerJ1, r=True)
                        cmds.makeIdentity(FingerJ1, apply=True, t=1, r=1, s=1)
                else:
                    FingerJ0 = "Proxies" + armPrefx + "_Finger_" + str(fingerIndex - 1) + "_J1"
                    self.ProxyBase(FingerJ1)
                    PCons = cmds.pointConstraint(FingerJ0, FingerJ1)
                    cmds.delete(PCons)
                    cmds.move(0, 0, -0.4, FingerJ1, r=True, os=True, wd=True)

                cmds.scale(0.62, 0.62, 0.62, FingerJ1)
                cmds.makeIdentity(FingerJ1, apply=True, t=1, r=1, s=1)
                cmds.setAttr("%sSnapShape.localScaleX" % FingerJ1, 0.155)
                cmds.setAttr("%sSnapShape.localScaleY" % FingerJ1, 0.155)
                cmds.setAttr("%sSnapShape.localScaleZ" % FingerJ1, 0.155)
                cmds.parent(FingerJ1, Palm)
                self.ProxyConnectors(Palm, FingerJ1)

                FingerJ2 = "Proxies" + armPrefx + "_Finger_" + str(fingerIndex) + "_J2"
                self.CreatePrixyNode(FingerJ2,
                                     PC=FingerJ1,
                                     mMvoe=[armMultiplier * 0.61, 0, 0],
                                     mScale=[0.62, 0.62, 0.62],
                                     lScale=[0.155, 0.155, 0.155],
                                     isConnect=True,
                                     isParent=True)

                FingerJ3 = "Proxies" + armPrefx + "_Finger_" + str(fingerIndex) + "_J3"
                self.CreatePrixyNode(FingerJ3,
                                     PC=FingerJ2,
                                     mMvoe=[armMultiplier * 0.61, 0, 0],
                                     mScale=[0.62, 0.62, 0.62],
                                     lScale=[0.155, 0.155, 0.155],
                                     isConnect=True,
                                     isParent=True)

                FingerJTip = "Proxies" + armPrefx + "_Finger_" + str(fingerIndex) + "_JTip"
                self.CreatePrixyNode(FingerJTip,
                                     PC=FingerJ3,
                                     mMvoe=[armMultiplier * 0.61, 0, 0],
                                     mScale=[0.62, 0.62, 0.62],
                                     lScale=[0.155, 0.155, 0.155],
                                     isConnect=True,
                                     isParent=True)

                fingerIndex += 1

            cmds.makeIdentity(Wrist, apply=True, t=1, r=1, s=1)
            armPrefx = "_R"
            armMultiplier = -1.0
            armLoop += 1

        # Legs
        legLoop = 1
        legPrefx = "_L"
        legMultiplier = 1.0
        while legLoop <= 2:
            Hip = "Proxies" + legPrefx + "_Hip"
            self.CreatePrixyNode(Hip,
                                 PC=self.Proxies_Root,
                                 mMvoe=[legMultiplier * 1.72, -0.8, 0],
                                 isConnect=True,
                                 isParent=True)

            Knee = "Proxies" + legPrefx + "_Knee"
            self.CreatePrixyNode(Knee,
                                 PC=Hip,
                                 mMvoe=[0, -6.4, 0],
                                 mRotate=[0, 180, 90],
                                 isConnect=True,
                                 isParent=True)

            Ankle = "Proxies" + legPrefx + "_Ankle"
            self.CreatePrixyNode(Ankle,
                                 PC=Knee,
                                 mMvoe=[0, -6.4, 0],
                                 isConnect=True,
                                 isParent=True)

            KneeG = "Proxies" + legPrefx + "_Knee_GRP"
            cmds.group(n=KneeG, em=True)
            PCons = cmds.pointConstraint(Knee, KneeG)
            cmds.delete(PCons)
            cmds.parent(Knee, KneeG)
            cmds.makeIdentity(KneeG, apply=True, t=1, r=1, s=1)
            # cmds.move(0,0,0.001,"%s.scalePivot" % KneeG,"%s.rotatePivot"  % KneeG ,r=True)
            cmds.pointConstraint(Hip, Ankle, KneeG, mo=True)
            cmds.parent(KneeG, Ankle, self.Main)

            Ball = "Proxies" + legPrefx + "_Ball"
            self.CreatePrixyNode(Ball,
                                 PC=Ankle,
                                 mMvoe=[0, -1.65, 2.26],
                                 isConnect=True,
                                 isParent=True)

            Toe = "Proxies" + legPrefx + "_Toe"
            self.CreatePrixyNode(Toe,
                                 PC=Ball,
                                 mMvoe=[0, 0, 1.7])

            if toesNum == 1:
                self.ProxyConnectors(Ball, Toe)

            BallG = "Proxies" + legPrefx + "_Ball_GRP"
            cmds.group(n=BallG, em=True)
            cmds.parent(BallG, Ball)
            cmds.parent(Toe, BallG)

            KneeLocator = "Proxies" + legPrefx + "_KneeLocator"
            cmds.spaceLocator(n=KneeLocator)
            PCons = cmds.pointConstraint(Knee, KneeLocator)
            cmds.delete(PCons)
            cmds.parent(KneeLocator, Knee)
            cmds.move(0, 0, 1.5, KneeLocator, r=True)
            cmds.setAttr("%s.v" % KneeLocator, 0)

            # toe num
            cmds.makeIdentity(Ball, apply=True, t=1, r=1, s=1)
            legLoop += 1
            legPrefx = "_R"
            legMultiplier = -1.0

        # PARENT CONTROLS
        cmds.parent(self.Proxies_Root, spineProxiesG, self.Proxies_SpineTop, neckProxiesG, self.Proxies_Head, self.Main)
        cmds.parent(self.Proxies_Jaw, self.Proxies_HeadTip, self.Proxies_L_Eye, self.Proxies_R_Eye,
                    self.Proxies_Head)
        cmds.parent(self.Proxies_JawTip, self.Proxies_Jaw)

        # INDICATOR
        self.ElbowIndicator("L")
        self.ElbowIndicator("R")
        self.KneeIndicator("L")
        self.KneeIndicator("R")

        # LOCATORS FOR FOOT TILT
        self.FootTilt("L")
        self.FootTilt("R")

        self.LimitAndLock()

        # CREATE LAYER
        cmds.select(self.Main)
        layer = cmds.objExists("ProxiesLayer")
        if layer is not None:
            cmds.createDisplayLayer(n="ProxiesLayer", number=1, nr=True)
        else:
            cmds.editDisplayLayerMembers("ProxiesLayer", self.Main, noRecurse=True)

        cmds.select(clear=True)

        # menber
        self.Main = "Proxies_Main"
        self.Proxies_Root = "Proxies_Root"
        self.Proxies_SpineTop = "Proxies_SpineTop"
        self.Proxies_Head = "Proxies_Head"
        self.Proxies_Jaw = "Proxies_Jaw"
        self.Proxies_JawTip = "Proxies_JawTip"
        self.Proxies_HeadTip = "Proxies_HeadTip"
        self.Proxies_L_Eye = "Proxies_L_Eye"
        self.Proxies_R_Eye = "Proxies_R_Eye"
        self.Proxies_L_Clavicle = "Proxies_L_Clavicle"
        self.Proxies_L_Shoulder = "Proxies_L_Shoulder"
        self.Proxies_L_Wrist = "Proxies_L_Wrist"
        self.Proxies_L_Palm = "Proxies_L_Palm"
        self.Proxies_L_Hip = "Proxies_L_Hip"
        self.Proxies_L_Ankle = "Proxies_L_Ankle"
        self.Proxies_L_Elbow = "Proxies_L_Elbow"
        self.Proxies_L_Knee = "Proxies_L_Knee"
        self.Proxies_L_Ball = "Proxies_L_Ball"
        self.Proxies_L_Toe = "Proxies_L_Toe"
        self.Proxies_R_Clavicle = "Proxies_R_Clavicle"
        self.Proxies_R_Shoulder = "Proxies_R_Shoulder"
        self.Proxies_R_Wrist = "Proxies_R_Wrist"
        self.Proxies_R_Palm = "Proxies_R_Palm"
        self.Proxies_R_Hip = "Proxies_R_Hip"
        self.Proxies_R_Ankle = "Proxies_R_Ankle"
        self.Proxies_R_Elbow = "Proxies_R_Elbow"
        self.Proxies_R_Knee = "Proxies_R_Knee"
        self.Proxies_R_Ball = "Proxies_R_Ball"
        self.Proxies_R_Toe = "Proxies_R_Toe"

        pass
Esempio n. 35
0
 def create(**kwargs):
     return DisplayLayer(_cmds.createDisplayLayer(**kwargs))
mc.file(obj_path.replace("_out.obj", "-lowres_out.obj"),
        r=True,
        type="OBJ",
        ignoreVersion=True,
        gl=True,
        mergeNamespacesOnClash=False,
        namespace=namespace_var + "LowRes",
        options="mo=1;")
mc.setAttr(namespace_var + "LowResRN.proxyTag", "LowRes", type="string")

# Create High resolution display layer
all_objects = mc.ls()
for object in all_objects:
    if "LowRes" in object:
        mc.select(object, add=True)
mc.createDisplayLayer(name="Low Resolution", nr=True)
mc.select(clear=True)

# Create Low resolution display layer
all_objects = mc.ls()
for object in all_objects:
    if "HighRes" in object:
        mc.select(object, add=True)
mc.createDisplayLayer(name="High Resolution", nr=True)
mc.setAttr("Low_Resolution.visibility", False)
mc.setAttr("High_Resolution.visibility", True)

# Save file
mc.file(rename=export_path)
mc.file(save=True, type='mayaAscii', f=True)
Esempio n. 37
0
aFacectrls=[u'ctrls_ear_r_fk', u'ctrls_ear_l_fk', u'ctrls_squint_l_facepnt', u'ctrls_snear_l_facepnt', u'ctrls_snear_r_facepnt', u'ctrls_squint_r_facepnt', u'ctrls_nose_facepnt', u'ctrls_headLow_facepnt', u'ctrls_tongue_fk', u'ctrl_upperTeeth_fk_offset', u'ctrl_lowerTeeth_fk_offset', u'ctrls_lipUp_facelips', u'ctrls_cheeks_facecheek', u'ctrls_eyebrow_facemask', u'ctrls_eye_l_facecartooneyelid', u'ctrls_eye_r_facecartooneyelid', u'ctrls_noseBridge_facepnt',u'ctrls_lipBot_facelips',u'ctrls_glassAuxiliaryes_fk' ,u'ctrl_glasses_fk']
for oFacectrls in aFacectrls:
    try:
        cmds.parent( oFacectrls ,'ctrls_face',a=1) 
    except (RuntimeError,ValueError):
        pass
        
cmds.addAttr('ctrl_head_fk',ln='StrechSquash',at='short',min=0,max=1,dv=0)
cmds.setAttr('ctrl_head_fk.StrechSquash',1,e=1,channelBox=1)
cmds.connectAttr( 'ctrl_head_fk.StrechSquash','ctrls_head_faceheadsquash.visibility')
cmds.connectAttr( 'ctrl_head_fk.faceboard','ctrls_face.visibility')
cmds.connectAttr( 'ctrl_head_fk.visibility_Faceboard','ctrls_face.visibility')

###### in case clean is not performed
delete('controls_layer')
delete('misc_layer')
cmds.select('ctrl_root',r=1)
cmds.createDisplayLayer( n="controls_layer",num=1 ,nr=1)
setAttr( controls_layer.visibility, 1)
setAttr(controls_layer.displayType, 0)
setAttr(controls_layer.color, 17) 
setAttr("other.visibility",0)
setAttr("jnts.visibility",0)
setAttr("other.template",1)
setAttr("jnts.template",1)


####### in case legs are disconnected
cmds.connectAttr( 'ctrl_cog.HipL','net_Leg.ikState')
cmds.connectAttr( 'ctrl_cog.HipR' ,'net_Leg1.ikState')
Esempio n. 38
0
		cmds.select(cl=1)
        #now skin the mesh item to the joint
		cmds.skinCluster( jointName, mesh, tsb=True, mi=1)
	#clear the selections
    cmds.select(cl=1)
	print(duplicateMeshArray)
    #group the duplicate meshes
	cmds.select(duplicateMeshArray)
	cmds.group(n=dupMeshGroup)
	
    #add the base joint to the asset list
	assetsLayer.append('base_j')
    #select all of the asset layer list contents
	cmds.select(assetsLayer)
    #create a display layer containing the list contents
	cmds.createDisplayLayer(nr=True, n=dlayNameA)
    #clear the selection
	cmds.select(cl=True)
	
    #select all of the duplicate mesh list contents
	cmds.select(duplicateMeshArray)
    #create a display layer containing the list contents
	cmds.createDisplayLayer(nr=True, n=dlayNameB)
    #clear the selection
	cmds.select(cl=True)
    #redeclare the mesh list, duplicate mesh list, and asset list, all as empty lists
	meshArray = []
	duplicateMeshArray = []
	assetsLayer = []

# function that goes through and contrains the joints to the duplicate meshes..
Esempio n. 39
0
def QSR_CreateReferenceLayer():
    # I create the Ref layer once and set it as a reference layer
    if not cmds.objExists('ReferenceLayer'):
        cmds.createDisplayLayer(n='ReferenceLayer', empty=True)
        cmds.setAttr('ReferenceLayer.displayType', 2)
Esempio n. 40
0
    def MainProcessing(self):
        cmds.circle(n=self.Main,
                    c=(0, 0, 0),
                    nr=(0, 1, 0),
                    sw=360,
                    r=8,
                    d=3,
                    ut=0,
                    tol=0.01,
                    s=8,
                    ch=0)
        # Root
        self.CreatePrixyNode(name=self.Proxies_Root,
                             mScale=[1.6, 1.6, 1.6],
                             mMvoe=[0, 15.25, 0],
                             lScale=[0.4, 0.4, 0.4])

        # Spine Top
        self.CreatePrixyNode(name=self.Proxies_SpineTop,
                             PC=self.Proxies_Root,
                             mScale=[1.6, 1.6, 1.6],
                             mMvoe=[0, 6.6, 0],
                             lScale=[0.4, 0.4, 0.4])

        self.Proxies_SpineOrientLocator = "Proxies_SpineOrientLocator"
        self.Proxies_NeckOrientLocator = "Proxies_NeckOrientLocator"

        # Aim
        cmds.spaceLocator(n=self.Proxies_SpineOrientLocator)
        cmds.parent(self.Proxies_SpineOrientLocator, self.Main)
        cmds.pointConstraint(self.Proxies_Root,
                             self.Proxies_SpineOrientLocator)
        cmds.aimConstraint(self.Proxies_SpineTop,
                           self.Proxies_SpineOrientLocator,
                           aimVector=[0, 1, 0],
                           upVector=[1, 0, 0],
                           worldUpType="vector",
                           worldUpVector=[1, 0, 0])
        cmds.setAttr("%s.visibility" % self.Proxies_SpineOrientLocator, 0)

        # Spline
        i2 = self.spineNum - 1
        for i, Spine in enumerate(self.Proxies_SpineList):
            self.ProxyBase(Spine)
            SpineGRP = Spine + "_GRP"
            cmds.group(Spine, n=SpineGRP)
            cmds.xform(os=True, piv=[0, 0, 0])
            cmds.makeIdentity(SpineGRP, apply=True, t=1, r=1, s=1)
            cmds.pointConstraint(self.Proxies_Root, self.Proxies_SpineTop,
                                 SpineGRP)
            cmds.orientConstraint(self.Proxies_SpineOrientLocator, SpineGRP)
            cmds.setAttr("%s_pointConstraint1.Proxies_RootW0" % SpineGRP, i2)
            cmds.setAttr("%s_pointConstraint1.Proxies_SpineTopW1" % SpineGRP,
                         i + 1)
            # CONNECTORS
            if i + 1 == 1:
                self.ProxyConnectors(self.Proxies_Root, SpineGRP)
            else:
                self.ProxyConnectors(SpineGRP, self.Proxies_SpineList[i - 1])
            i2 = i2 - 1
        self.ProxyConnectors(self.Proxies_SpineList[self.spineNum - 2],
                             self.Proxies_SpineTop)
        cmds.select(self.Proxies_SpineList)
        cmds.pickWalk(d="up")
        spineProxiesG = cmds.ls(sl=True)

        # Head
        self.CreatePrixyNode(name=self.Proxies_Head,
                             PC=self.Proxies_SpineTop,
                             mMvoe=[0, 2, 0],
                             mScale=[1.25, 1.25, 1.25])

        # CREATE AIM LOCATOR TO ORIENT NECK PROXIES
        cmds.spaceLocator(n=self.Proxies_NeckOrientLocator)
        cmds.parent(self.Proxies_NeckOrientLocator, self.Main)
        cmds.pointConstraint(self.Proxies_SpineTop,
                             self.Proxies_NeckOrientLocator)
        cmds.aimConstraint(self.Proxies_Head,
                           self.Proxies_NeckOrientLocator,
                           aimVector=[0, 1, 0],
                           upVector=[1, 0, 0],
                           worldUpType="vector",
                           worldUpVector=[1, 0, 0])
        cmds.setAttr("%s.visibility" % self.Proxies_NeckOrientLocator, 0)

        i2 = self.neckNum - 1
        for i, Neck in enumerate(self.Proxies_NeckList):
            self.ProxyBase(Neck)
            cmds.scale(0.8, 0.8, 0.8, Neck, r=True)
            cmds.makeIdentity(Neck, apply=True, t=1, r=1, s=1)
            NeckGRP = Neck + "_GRP"
            cmds.group(Neck, n=NeckGRP)
            cmds.xform(os=True, piv=[0, 0, 0])
            cmds.makeIdentity(NeckGRP, apply=True, t=1, r=1, s=1)
            cmds.pointConstraint(self.Proxies_SpineTop, self.Proxies_Head,
                                 NeckGRP)
            cmds.orientConstraint(self.Proxies_NeckOrientLocator, NeckGRP)
            cmds.setAttr("%s_pointConstraint1.Proxies_SpineTopW0" % NeckGRP,
                         i2)
            cmds.setAttr("%s_pointConstraint1.Proxies_HeadW1" % NeckGRP, i + 1)
            # CONNECTORS
            if i + 1 == 1:
                self.ProxyConnectors(self.Proxies_SpineTop, NeckGRP)
            else:
                self.ProxyConnectors(NeckGRP, self.Proxies_NeckList[i - 1])
            i2 = i2 - 1
        self.ProxyConnectors(self.Proxies_NeckList[self.neckNum - 2],
                             self.Proxies_Head)
        cmds.select(self.Proxies_NeckList)
        cmds.pickWalk(d="up")
        neckProxiesG = cmds.ls(sl=True)

        # Jaw
        self.CreatePrixyNode(self.Proxies_Jaw,
                             PC=self.Proxies_Head,
                             mMvoe=[0, 0.83, 0.38],
                             isConnect=True)

        self.CreatePrixyNode(self.Proxies_JawTip,
                             PC=self.Proxies_Jaw,
                             mMvoe=[0, -0.83, 1.52],
                             isConnect=True)

        self.CreatePrixyNode(self.Proxies_HeadTip,
                             PC=self.Proxies_Head,
                             mMvoe=[0, 3.38, 0],
                             isConnect=True)
        self.Main_Side("L")
        self.Main_Side("R")

        # PARENT CONTROLS
        cmds.parent(self.Proxies_Root, spineProxiesG, self.Proxies_SpineTop,
                    neckProxiesG, self.Proxies_Head, self.Main)
        cmds.parent(self.Proxies_Jaw, self.Proxies_HeadTip, self.Proxies_Eyes,
                    self.Proxies_Head)
        cmds.parent(self.Proxies_JawTip, self.Proxies_Jaw)

        self.ElbowIndicator("L")
        self.ElbowIndicator("R")

        self.KneeIndicator("L")
        self.KneeIndicator("R")

        # LOCATORS FOR FOOT TILT
        self.FootTilt("L")
        self.FootTilt("R")

        self.LimitAndLock()

        # CREATE LAYER
        cmds.select(self.Main)
        layer = cmds.objExists("ProxiesLayer")
        if layer is not None:
            cmds.createDisplayLayer(n="ProxiesLayer", number=1, nr=True)
        else:
            cmds.editDisplayLayerMembers("ProxiesLayer",
                                         self.Main,
                                         noRecurse=True)

        cmds.select(clear=True)

        pass
def splitMeshByInfluences(threshold, *args):
    import maya.mel as mel
    
    finalMeshList = []
    
    # find the meshes that the user has selected
    selected = cmds.ls(sl=True, type="transform")

    # Create an empty set.  We wil add to it later.
    cmds.select(cl=True)
    setName = cmds.sets(n="Rigid_Meshes")
    
    rigidMeshMasterGrp = cmds.group(em=True, name="Rigid_Mesh")

    # for each mesh:
    for mesh in selected:
        rigidMeshMeshGrp = cmds.group(em=True, name="Rigid_"+mesh, p=rigidMeshMasterGrp)
        #print "Mesh:"+mesh

        skinCluster = mel.eval('findRelatedSkinCluster %s' % mesh)
        influences = cmds.skinCluster(skinCluster, q=True, inf=True)
        #print influences

        for inf in influences:
            # Duplicate the mesh with input connections
            dupeMesh = cmds.duplicate(mesh, name=mesh+"__"+inf, rr=False)[0]
            #print "DupeMesh:       "+dupeMesh
            for attr in ["tx", "ty", "tz", "rx", "ry", "rz", "sx", "sy", "sz", "v"]:
                cmds.setAttr(dupeMesh+"."+attr, lock=False, k=True)
            cmds.makeIdentity(dupeMesh, t=1, r=1, s=1, apply=True)
            cmds.select(dupeMesh, r=True)
            mel.eval("CenterPivot")
            cmds.parent(dupeMesh, rigidMeshMeshGrp)
            
            finalMeshList.append(dupeMesh)
            cmds.sets(dupeMesh, add=setName)

            # Select the verts that are influenced by the inf joint.
            if len(influences) <= 1:
                const = cmds.parentConstraint(inf, rigidMeshMeshGrp, dupeMesh, mo=True)[0]
                cmds.setAttr(const+"."+rigidMeshMeshGrp+"W1", 0)
            else:
                verts = []
                for x in range(cmds.polyEvaluate(mesh, v=True)):
                    v = cmds.skinPercent(skinCluster, '%s.vtx[%d]' % (mesh, x), transform=inf, q=True)
                    if v > threshold:
                        verts.append('%s.vtx[%d]' % (dupeMesh, x))
                #print verts
                if verts:
                    cmds.select(verts)            
                    # Convert the selection to contained faces
                    if len(verts) != cmds.polyEvaluate(mesh, v=True):
                        mel.eval("InvertSelection;")
                        cmds.select(cmds.polyListComponentConversion(fv=True, tf=True, internal=True ))
                        cmds.delete()
                    cmds.select(dupeMesh, r=True)
                    mel.eval("CenterPivot")
                    const = cmds.parentConstraint(inf, rigidMeshMeshGrp, dupeMesh, mo=True)[0]
                    cmds.setAttr(const+"."+rigidMeshMeshGrp+"W1", 0)
                else:
                    print "No Valid Verts so we didnt use this influence."
                    cmds.delete(dupeMesh)

    cmds.select(rigidMeshMasterGrp, hi=True)
    cmds.createDisplayLayer(cmds.ls(sl=True), name="RigidMesh_L")
    
    return finalMeshList
Esempio n. 42
0
def PlacementTool():
	cmds.undoInfo(openChunk=True)
	Start = True
	if cmds.objExists('__Placement_Tool__'): 
		cmds.makeLive(none=True)
		if cmds.objExists('__Placement_Tool_c__'): cmds.delete('__Placement_Tool_c__')
		if cmds.objExists('__Placement_Tool_f__'): cmds.delete('__Placement_Tool_f__')
		if cmds.objExists('__Placement_Tool_g__'): cmds.delete('__Placement_Tool_g__')
		if cmds.objExists('__Placement_Tool__'): cmds.delete('__Placement_Tool__')
		cmds.xform(rp=(osPivot[0],osPivot[1],osPivot[2]),os=1)
		Start = False
		PT_START_UI()
	if Start:
		global osPivot
		osPivot=cmds.xform(q=1,rp=1,os=1)
		global wsPivot
		wsPivot=cmds.xform(q=1,rp=1,ws=1)
		cmds.setToolTo('moveSuperContext')
		sel=cmds.ls(sl=1,l=1)
		cmds.InvertSelection()
		cmds.select(cmds.ls(sl=1,v=1))
		cmds.select(cmds.filterExpand(sm=12))
		selAll=cmds.ls(sl=1)
		cmds.duplicate()
		cmds.group(name=('__Placement_Tool_g__'))
		cmds.CombinePolygons()
		cmds.hyperShade(assign='lambert1')
		cmds.polyMapDel()
		cmds.DeleteHistory()
		cmds.rename('__Placement_Tool__')
		cmds.hide()
		# Move Pivot
		cmds.select(sel)
		for i in sel :
		    pos = cmds.xform(i,q=1,ws=1,piv=1)
		    dup = cmds.duplicate(i,rr=1,po=1)
		    for attr in ['tx','ty','tz','rx','ry','rz','sx','sy','sz'] :
		        if cmds.getAttr(dup[0]+'.'+attr,lock=True):cmds.setAttr(dup[0]+'.'+attr,lock=False)
		    shapeNode = cmds.ls(cmds.listRelatives(i,c=1,f=1),l=1,s=1)
		    for s in shapeNode :
		        cmds.parent(s,dup[0],add=1,s=1)
		    if cmds.listRelatives(dup[0],p=1) :
		        cmds.parent(dup[0],w=1)
		    cmds.setAttr(dup[0]+'.r',0,0,0,type="double3")              
		    bb=cmds.xform(dup[0],q=1,bb=1,ws=1)
		    cp=cmds.objectCenter(dup[0])
		    xpos=cp[0];ypos=bb[1];zpos = cp[2]
		    loc=cmds.spaceLocator()
		    cmds.xform(loc[0],ws=1,t=(xpos,ypos,zpos))
		    cmds.parent(loc[0],dup[0])
		    cmds.delete(cmds.parentConstraint(i,dup[0]))
		    pivPos=cmds.xform(loc[0],q=1,ws=1,t=1)
		    cmds.xform(i,ws=1,piv=(pivPos[0],pivPos[1],pivPos[2]))
		    cmds.delete(dup[0],loc[0])
		cmds.select(sel,r=1)
		cmds.select('__Placement_Tool__',r=1);cmds.select(sel,add=1)
		cmds.normalConstraint(worldUpType="none",aimVector=(0, 1, 0),upVector=(0, 1, 0),weight=1,name='__Placement_Tool_c__')
		cmds.select('__Placement_Tool__',r=1);cmds.makeLive()
		cmds.select(selAll)
		cmds.createDisplayLayer(name="__Placement_Tool_f__",number=1,nr=1)
		import maya.mel as mel
		mel.eval('layerEditorLayerButtonTypeChange("__Placement_Tool_f__")')
		mel.eval('layerEditorLayerButtonTypeChange("__Placement_Tool_f__")')
		cmds.select(sel)
		PT_STOP_UI()
	cmds.undoInfo(closeChunk=True)
Esempio n. 43
0
        # organizando a hierarquia dos grupos
        childGroup = meshGrp, ctrlGrp, dataGrp
        cmds.parent(childGroup, allGrp)

        # criando controles
        masterCtrl = cmds.circle(name="master_ctrl", c=[0, 0, 0], sw=360, d=3, r=80, nr=[0, 1, 0], ch=False)
        globalCtrl = cmds.circle(name="global_ctrl", c=[0, 0, 0], sw=360, d=3, r=100, nr=[0, 1, 0], ch=False)

        # organizando a hierarquia das curvas
        cmds.parent(masterCtrl, globalCtrl)
        cmds.parent(globalCtrl, ctrlGrp)

        # setando model no rig
        cmds.parent(model, meshGrp)

        # setando cores
        cmds.setAttr(str(masterCtrl[0]) + ".overrideEnabled", 1)
        cmds.setAttr(str(masterCtrl[0]) + ".overrideColor", 13)
        cmds.setAttr(str(globalCtrl[0]) + ".overrideEnabled", 1)
        cmds.setAttr(str(globalCtrl[0]) + ".overrideColor", 17)

        # setando layers
        cmds.select("MESH")
        geoLr = cmds.createDisplayLayer(noRecurse=True, name='GEO_lr')
        cmds.select(clear=True)
        cmds.select("CTRL")
        ctrlLr = cmds.createDisplayLayer(noRecurse=True, name='CTRL_lr')
except Exception as error:
    print(error)
Esempio n. 44
0
	def __create_layer(self):
		# If the display layer doesn't already exist, create it
		if not cmds.objExists(self.layer_name):
			self.layer_name = cmds.createDisplayLayer(name=self.layer_name, empty=True)