def joint(side, lowerJoint, upperJoint, useSphere=0, sharedUpper=0, sharedLower=0, show=1, heightScale=1):
    name = lowerJoint + "_" + upperJoint

    upperName = "SKEL_"
    if sharedUpper == 0:
        upperName += side + "_"
    upperName += upperJoint

    lowerName = "SKEL_"
    if sharedLower == 0:
        lowerName += side + "_"
    lowerName += lowerJoint

    print name
    cmds.spaceLocator(name="%s_%s" % (side, name))
    cmds.pointConstraint(lowerName, "%s_%s" % (side, name))
    cmds.pointConstraint(upperName, "%s_%s" % (side, name))
    cmds.aimConstraint(upperName, "%s_%s" % (side, name))
    if useSphere:
        cmds.sphere(name="%s_%s_C" % (side, name), radius=1)
    else:
        cmds.cylinder(name="%s_%s_C" % (side, name), radius=0.5, heightRatio=6 * heightScale)

    cmds.setAttr("%s_%s_C.doubleSided" % (side, name), 0)
    if show == 0:
        cmds.setAttr("%s_%s_C.primaryVisibility" % (side, name), 0)

        # cmds.rotate( 0, 0, 90, '%s_FOREARM_C' % (side) )
        # cmds.makeIdentity( '%s_FOREARM_C' % (side), apply = 1, rotate = 1 )
    cmds.select("%s_%s" % (side, name), "%s_%s_C" % (side, name))
    cmds.parentConstraint()
    return
Ejemplo n.º 2
0
def newGrp(name):
    #Create a clean group
    try:
        cmds.select(name)
    except:
        cmds.sphere(n="temp")
        cmds.group("temp",n = name,world=True)
        cmds.delete("temp")
Ejemplo n.º 3
0
 def testStaticNurbsSurfacePropReadWrite(self):
     nodeName = 'nSphere'
     shapeName = 'nSphereShape'
     MayaCmds.sphere(name=nodeName)
     self.setProps(shapeName)
     self.__files.append(util.expandFileName('staticPropNurbs.abc'))
     MayaCmds.AbcExport(j='-atp SPT_ -root %s -file %s' % (nodeName, self.__files[-1]))
     self.verifyProps(shapeName, self.__files[-1])
 def create_world_button( self, *args  ):
     if( cmds.objExists( "OurSampleWorld" ) ):
         return 0
     else:
         cmds.sphere( r=10, sections=40, spans=30, name="OurSampleWorld" )
         cmds.setAttr( "OurSampleWorld.scale", 9.599, 9.599, 9.599 )
         cmds.makeIdentity( apply=True, t=1, r=1, s=1 )
         self.wbbox = cmds.exactWorldBoundingBox( "OurSampleWorld" )
         cmds.move((self.wbbox[0] + self.wbbox[3])/2, self.wbbox[4], (self.wbbox[2] + self.wbbox[5])/2, "OurSampleWorld.scalePivot", "OurSampleWorld.rotatePivot", absolute=True)
         cmds.move( 0, 0, 0, "OurSampleWorld", rpr=True )
         cmds.connectControl( "world_size_slider", "OurSampleWorld.scaleX", "OurSampleWorld.scaleY", "OurSampleWorld.scaleZ" )
Ejemplo n.º 5
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" )
Ejemplo n.º 6
0
def addModification( meshObjs ):
    
    import sgBFunction_attribute
    import sgBFunction_dag
    
    meshObjs = sgBFunction_dag.getChildrenMeshExists( meshObjs )
    softMod = cmds.deformer( meshObjs, type='softMod' )[0]
    
    ctlGrp = cmds.createNode( 'transform' )
    cmds.setAttr( ctlGrp+'.dh', 1 )
    dcmp   = cmds.createNode( 'decomposeMatrix' )
    ctl = cmds.sphere()[0]
    ctl = cmds.parent( ctl, ctlGrp )[0]
    sgBFunction_attribute.addAttr( ctl, ln='__________', at='enum', enumName = ':Modify Attr', cb=1 )
    sgBFunction_attribute.addAttr( ctl, ln='falloffRadius', min=0, dv=1, k=1 )
    sgBFunction_attribute.addAttr( ctl, ln='envelope', min=0, max=1, dv=1, k=1 )
    
    cmds.connectAttr( ctlGrp+'.wim', softMod+'.bindPreMatrix' )
    cmds.connectAttr( ctlGrp+'.wm', softMod+'.preMatrix' )
    cmds.connectAttr( ctl+'.wm', softMod+'.matrix' )
    cmds.connectAttr( ctl+'.m',  softMod+'.weightedMatrix' )
    
    cmds.connectAttr( ctlGrp+'.wm', dcmp+'.imat' )
    
    cmds.connectAttr( dcmp+'.ot', softMod+'.falloffCenter' )
    for i in range( len( meshObjs ) ):
        cmds.connectAttr( meshObjs[i]+'.wm', softMod+'.geomMatrix[%d]' % i )
    
    cmds.connectAttr( ctl+'.envelope', softMod+'.envelope' )
    cmds.connectAttr( ctl+'.falloffRadius', softMod+'.falloffRadius' )
    
    cmds.xform( ctlGrp, ws=1, t=cmds.getAttr( meshObjs[0]+'.wm' )[-4:-1] )
    cmds.select( ctlGrp )
Ejemplo n.º 7
0
 def createImpactHelper(self):
     '''
     Creates IS Sphere Helper
     '''
     mImpact = cmds.sphere(r = 0.00001, n = 'IS_Impact')
     mImpactShape = cmds.listRelatives(mImpact[0])[0]
     
     self._mVoroImpactTrs = mImpact[0]
     self._mVoroImpactShape = mImpact[1]
     
     cmds.setAttr(mImpact[0] + '.visibility', False)
     cmds.setAttr(mImpact[0] + '.overrideEnabled', True)
     cmds.setAttr(mImpact[0] + '.overrideColor', 14)
     cmds.setAttr(mImpact[1] + '.sections', 2)
     cmds.setAttr(mImpact[1] + '.spans', 2)
     cmds.setAttr(mImpactShape + '.curvePrecisionShaded', 20)
     
     self._mVoroImpactShader = cmds.shadingNode('lambert', name = 'IS_ImpactMat', asShader = True)
     cmds.setAttr(self._mVoroImpactShader + '.diffuse', 0.0)
     cmds.setAttr(self._mVoroImpactShader + '.translucence', 0.3)
     cmds.setAttr(self._mVoroImpactShader + '.translucenceDepth', 0.75)
     cmds.setAttr(self._mVoroImpactShader + '.color', 0.0, 1.0, 0.0, type = 'double3')
     cmds.setAttr(self._mVoroImpactShader + '.incandescence', 0.0, 0.15, 0.0, type = 'double3')
     cmds.setAttr(self._mVoroImpactShader + '.transparency', 0.55, 0.55, 0.55, type = 'double3')
     
     cmds.select(mImpact, replace = True)
     cmds.hyperShade(assign = self._mVoroImpactShader)
     mel.eval('hyperShadePanelMenuCommand("hyperShadePanel1", "deleteUnusedNodes")')
     
     if (cmds.attributeQuery('hiddenInOutliner', node = self._mVoroImpactTrs, exists = True)):
         cmds.setAttr(self._mVoroImpactTrs + '.hiddenInOutliner', True)
     
     cmds.select(clear = True)
     cmds.scriptEditorInfo (clearHistory = True)
Ejemplo n.º 8
0
 def createPetals(self):
     '''This method creates the petals of flower. '''
     
     # create the petal
     mc.sphere( ax=(0, 1, 0) );
     mc.move( 0, 0, -1.6 );
     mc.scale( 0.7, 0.3, 1.7 );    
     self.currentPetal = mc.ls( sl=True );
     currentPetal0 = self.currentPetal[0]
 
     # reset the coordinates
     mc.makeIdentity( apply=True, t=1, r=1, s=1, n=0 );
     mc.move( 0, 0, 0, currentPetal0 + '.scalePivot' )
     mc.move( 0, 0, 0, currentPetal0 + '.rotatePivot' )
      
     # move the tip of the petal
     mc.select( currentPetal0 + ".cv[3] [7]" )
     mc.move( 0, 1.5, 0, r=True )
   
     # select the inner part of the petal
     # move them down
     for uCV in range (5,7):  
         for vCV in range (0, 8):
             mc.select( currentPetal0 + ".cv[" + str(uCV) + "] [" + str(vCV) + "]" );
             mc.move( 0, -0.3, 0, r=True )
     
     # delete history
     mc.select( currentPetal0 )
     maya.mel.eval( "DeleteHistory" )
     
     # create the rest of the petals
     numPetals = random.randrange (10, 20);
     mc.select( currentPetal0 )
     degreeApart = ( 360 / numPetals );
     for i in range (0, numPetals):    
         newPetal = mc.duplicate ( rr=True );
         self.currentPetal.append(newPetal)
         mc.rotate( 0, degreeApart, 0, r=True );
         
         # randomly rotate the petals
         petalRX = random.randrange( -5, 5 );
         petalRY = random.randrange( -5, 5 );
         petalRZ = random.randrange( -5, 5 );
         mc.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
         mc.rotate( petalRX, petalRY, petalRZ, r=True )
         
     return self.currentPetal
Ejemplo n.º 9
0
    def runTest(self):
        # create a nurbs sphere
        mySphere = cmds.sphere()[0]
        # a default sphere should have u/v
        # parameter ranges of 0:4/0:8
        
        # The following selections should
        # result in one of these:
        desiredResults = ('nurbsSphere1.u[2:3][0:8]',
                          'nurbsSphere1.u[2:3][*]',
                          'nurbsSphere1.u[2:3]',
                          'nurbsSphere1.uv[2:3][0:8]',
                          'nurbsSphere1.uv[2:3][*]',
                          'nurbsSphere1.uv[2:3]',
                          'nurbsSphere1.v[0:8][2:3]',
                          'nurbsSphere1.v[*][2:3]')

                
        # Passes
        cmds.select('nurbsSphere1.u[2:3][*]')
        self.assertTrue(cmds.ls(sl=1)[0] in desiredResults)
        
        # Passes
        cmds.select('nurbsSphere1.v[*][2:3]')
        self.assertTrue(cmds.ls(sl=1)[0] in desiredResults)        

        # Fails! - returns 'nurbsSphere1.u[2:3][0:1]'
        cmds.select('nurbsSphere1.u[2:3]')
        self.assertTrue(cmds.ls(sl=1)[0] in desiredResults)
        
        # Fails! - returns 'nurbsSphere1.u[2:3][0:1]'
        cmds.select('nurbsSphere1.uv[2:3][*]')
        self.assertTrue(cmds.ls(sl=1)[0] in desiredResults)

        # The following selections should
        # result in one of these:
        desiredResults = ('nurbsSphere1.u[0:4][2:3]',
                          'nurbsSphere1.u[*][2:3]',
                          'nurbsSphere1.uv[0:4][2:3]',
                          'nurbsSphere1.uv[*][2:3]',
                          'nurbsSphere1.v[2:3][0:4]',
                          'nurbsSphere1.v[2:3][*]',
                          'nurbsSphere1.v[2:3]')
                
        # Passes
        cmds.select('nurbsSphere1.u[*][2:3]')
        self.assertTrue(cmds.ls(sl=1)[0] in desiredResults)

        # Passes
        cmds.select('nurbsSphere1.v[2:3][*]')
        self.assertTrue(cmds.ls(sl=1)[0] in desiredResults)

        # Fails! - returns 'nurbsSphereShape1.u[0:1][2:3]'
        cmds.select('nurbsSphere1.v[2:3]')
        self.assertTrue(cmds.ls(sl=1)[0] in desiredResults)

        # Fails! - returns 'nurbsSphereShape1.u[0:4][0:1]'
        cmds.select('nurbsSphere1.uv[*][2:3]')
        self.assertTrue(cmds.ls(sl=1)[0] in desiredResults)
Ejemplo n.º 10
0
    def test_create_node_and_compile(self):
        sphere = cmds.sphere()
        node = cmds.shadingNode("dl_uberLightShape", asLight=True)
#        cmds.select(sphere, replace=True)
#        node_sg = cmds.sets(renderable=True, noSurfaceShader=True, empty=True, name=node);
#        cmds.defaultNavigation(connectToExisting=True, source=node, destination=node_sg)
#        mel.eval('connectNodeToNodeOverride("%s", "%s")' % (node, node_sg))
#        cmds.sets(edit=True, forceElement=node_sg)
        mel.eval("delightRender %s" % self.renderpass)
Ejemplo n.º 11
0
 def setUp(self):
     cmds.file(f=1, new=1)
     cmds.namespace(add="FOO")
     cmds.namespace(add="BAR")
     cmds.namespace(add="FRED")
     cmds.namespace(add="BAR", parent=":FOO")
     cmds.namespace(add="CALVIN", parent=":FOO:BAR")
     cmds.sphere(n="FOO:sphere1")
     cmds.sphere(n="FOO:sphere2")
     cmds.sphere(n="BAR:sphere1")
     cmds.sphere(n="FOO:BAR:sphere1")
Ejemplo n.º 12
0
 def setUp(self):
     cmds.file(f=1, new=1)
     cmds.namespace( add='FOO' )
     cmds.namespace( add='BAR' )
     cmds.namespace( add='FRED' )
     cmds.namespace( add='BAR', parent=':FOO')
     cmds.namespace( add='CALVIN', parent=':FOO:BAR')
     cmds.sphere( n='FOO:sphere1' )
     cmds.sphere( n='FOO:sphere2' )
     cmds.sphere( n='BAR:sphere1' )
     cmds.sphere( n='FOO:BAR:sphere1' )
Ejemplo n.º 13
0
def main():
    for e in range(COUNT):
        name = "sphere" + str(e)
        shader_name = "sphereShader" + str(e)

        ep = [rp2(5), rp2(5), rp2(5)]
        circle = cmds.sphere(name=name, p=ep, r=rp(.5))

        #color = (int(rp(120)), int(rp(120)), int(rp(120)))
        color = (rp(1), rp(1), rp(1))

        assignNewMaterial(shader_name, color, 'lambert', name)
Ejemplo n.º 14
0
 def __setup_plugin(self):
     rivet = cmds.createNode(self._plugin)
     obj = cmds.sphere()[0]
     shape = cmds.listRelatives(obj, allDescendents=True)[0]
     cmds.connectAttr(shape + ".local", rivet + ".inSurface")
     cmds.connectAttr(obj + ".worldMatrix", rivet + ".inMatrix")
     for num in range(12):
         loc = cmds.spaceLocator()[0]
         cmds.setAttr(rivet + ".parameterUV[%s].parameterU" % num, 0.5)
         cmds.setAttr(rivet + ".parameterUV[%s].parameterV" % num, 0.0)
         cmds.connectAttr(rivet + ".outTranslate[%s]" % num, loc + ".translate")
         cmds.connectAttr(rivet + ".outRotate[%s]" % num, loc + ".rotate")
Ejemplo n.º 15
0
 def setUp(self):
     OpenMaya.MFileIO.newFile(True)
     master = cmds.group(name='master', empty=True)
     for i in (1, 2):
         root = cmds.group(name='root_%d' % i, parent=master, empty=True)
         child = cmds.group(name='child_%d' % i, parent=root, empty=True)
         node = cmds.group(name='node', parent=child, empty=True)
     
     cmds.group('|master|root_2|child_2|node', name='grandchild', parent='|master|root_2|child_2')
     cmds.group(name='node', parent='|master', empty=True)
     cmds.group(name='awesome_node', parent='|master', empty=True)
     cmds.group(name='node_awesome', parent='|master', empty=True)
     cmds.group(name='n0de', parent='|master', empty=True)
     cmds.polyCube(name='cube')
     cmds.parent('cube', '|master')
     cmds.sphere(name='sphere')
     cmds.parent('sphere', '|master')
     cmds.circle(name='circle')
     cmds.parent('|circle', '|master')
     cmds.projectCurve('|master|circle', '|master|sphere')
     cmds.namespace(add='awesome')
     cmds.pointLight(name='awesome:light')
     cmds.parent('|awesome:light', '|master')
Ejemplo n.º 16
0
def	createSpherical4Arrowhead	():
	_controlled		=	cmds.ls		(	long	=	True,	selection	=	True	)
	_baseCurve		=	cmds.curve	( 	degree	=	1,	point	=	[	(0,1,1),(0,3,1),(0,3,2),(0,6,0),(0,3,-2),(0,3,-1),
										(0,1,-1),(0,1,-3),(0,2,-3),(0,0,-6),(0,-2,-3),(0,-1,-3),(0,-1,-1),(0,-3,-1),
										(0,-3,-2),(0,-6,0),(0,-3,2),(0,-3,1),(0,-1,1),(0,-1,3),(0,-2,3),(0,0,6),(0,2,3),
										(0,1,3),(0,1,1)	]	)
	_tempSphere		=	cmds.sphere	(	radius	=	7,	axis	=	(	0,	1,	0	),	sections	=	4,
										startSweep	=	270,	endSweep	=	90,	constructionHistory	=	0	)
	_control 		=	cmds.projectCurve	(	_baseCurve,	_tempSphere,
												constructionHistory	=	False,	direction	=	(	1,	0,	0	),	)
	_control		=	cmds.duplicateCurve	(	_control,	constructionHistory	=	True,	object	=	True	)
		
	cmds.delete		(	_tempSphere	)
	cmds.delete		(	_baseCurve	)
	
	postProcessControl	(	_control[0],	'rotate',	_controlled	)
Ejemplo n.º 17
0
    def test_create_node_and_compile(self):
        mel.eval("source createRenderNode")
        test_void_input = cmds.shadingNode("test_void_input", asShader=True)
        test_void_output = cmds.shadingNode("test_void_output", asUtility=True)

        sphere = cmds.sphere()
        cmds.select(sphere, replace=True)
        node_sg = cmds.sets(renderable=True, noSurfaceShader=True, empty=True, name="test_void_inputSG1");
        cmds.defaultNavigation(connectToExisting=True, source=test_void_input, destination=node_sg)
        mel.eval('connectNodeToNodeOverride("%s", "%s")' % (test_void_input, node_sg))
        cmds.sets(edit=True, forceElement=node_sg)

        cmds.connectAttr(test_void_output + ".voidOutput", test_void_input + ".voidInput[0]", force=True)
        cmds.connectAttr(test_void_output + ".param3", test_void_input + ".param3", force=True)

        
        mel.eval("delightRender %s" % self.renderpass)
Ejemplo n.º 18
0
def createLimb(bones=1):
    xPos= 10
    #joints
    for i in range(0,bones,1):
        limbJnt = cmds.sphere(n='joint_'+str(i))
        cmds.move(i*xPos,0,0,limbJnt)
    #bones
    for i in range(0,bones-1,1):
        bone = cmds.polyCylinder(n='bone_'+str(i),height=10,radius=0.2)
        cmds.move(i*xPos + xPos/2,0,0,bone)
        cmds.rotate(0,0,-90,bone)
    #clusters
    cmds.select(clear=True)    
    for i in range(0,bones,1):
        jntCluster = cmds.cluster()
        cmds.move(i*xPos,0,0,jntCluster)
        cmds.select(clear=True)
Ejemplo n.º 19
0
def createCtlSys(nodeName, drvLocs, size=1, addGrp=1):
    '''
    Adds controls under drvLocs, to be used as offset controls
    size - [float] radius of nurbs sphere control
            if size=1, radius will be 0.2 of distance between first 2 locators
    addGrp - [int] number of offset grps above the control
    Returns ctlSysGrp, and a list of controls
    '''
    # calculate size
    pos1 = pm.dt.Point(mc.xform(drvLocs[0], q=True, ws=True, t=True))
    pos2 = pm.dt.Point(mc.xform(drvLocs[1], q=True, ws=True, t=True))
    vec = pos2 - pos1
    dist = vec.length()
    size = dist * 0.2 * size
    
    # create controls
    ctls = []
    for eachLoc in drvLocs:
        
        grp = eachLoc
        # add offset grps
        for grpId in range(addGrp):
            grp = mc.group(em=True, n=eachLoc.replace('_wireOffset_drvLoc', '_wireOffset_offset%d_grp'%grpId).replace('Orig',''), p=grp)
            mc.xform(grp, os=True, a=True, t=(0,0,0), ro=(0,0,0))
            
        # create control
        ctl = mc.sphere(r=size, n=eachLoc.replace('_wireOffset_drvLoc', '_wireOffset_ctl').replace('Orig',''))[0]
        mc.delete(ctl, ch=True)
        rt.parentSnap(ctl, grp)
        
        # assign color
        # first, break connection to shader
        ctlShape = mc.listRelatives(ctl, c=True, s=True)[0]
        shdConn = mc.listConnections(ctlShape+'.instObjGroups', p=True)[0]
        mc.disconnectAttr(ctlShape+'.instObjGroups', shdConn)
        # assign color override
        mc.setAttr(ctlShape+'.overrideEnabled', 1)
        mc.setAttr(ctlShape+'.overrideColor', 6)
        
        ctls.append(ctl)
    
    ctlSysGrp = mc.group(em=True, n=nodeName+'_wireOffset_ctlSys_grp')
    rt.connectVisibilityToggle(ctls, ctlSysGrp, 'ctlVis', True)
    
    return ctlSysGrp, ctls
def square(x, y, size, offset):# top	 # right	 # bottom	 # left
    tmpAverage = avgElements([  queryArrayElement(x, y - size), queryArrayElement(x + size, y), queryArrayElement(x, y + size),  queryArrayElement(x - size, y) ]);
    editArrayElement(x, y, tmpAverage + offset);
    print 'square'
    s=cmds.sphere()
    cmds.scale(0.1,0.1,0.1)
    curPointPosition = cmds.xform( p[0]+".vtx[%d]"%(x + initSize * y), query=True, translation=True, worldSpace=True )
    cmds.move(curPointPosition[0],curPointPosition[1],curPointPosition[2]) 
      
    #select plane current corresponding edited plane vertex
    #cmds.xform(p[0]+".vtx[%d]"%(i) , translation=[x,y/40,z], worldSpace=True)
    
    #cmds.select(p[0]+".vtx[%d]"%(x + initSize * y))
    global initSize
    print x,y,initSize       
    print p[0]+".vtx[%d]"%(x + initSize * y)
    
    cmds.refresh()
    time.sleep(0.5)
Ejemplo n.º 21
0
    def sphereCtrl(self):

        """
        This procedure creates a coloured sphere
        
        """

        self.__buildName()

        if not self.controlName:
            return

        control = cmds.sphere(n=self.controlName)
        shape = cmds.listRelatives(control[0], s=1)
        cmds.disconnectAttr("%s.instObjGroups[0]" % shape[0], "initialShadingGroup.dagSetMembers[0]")

        self.control = control[0]

        self.__finaliseCtrl()
        common.colorize(self.color, nodeList=[self.control])
Ejemplo n.º 22
0
def create_orient_manipulator(joint, material):
    joint_scale = cmds.jointDisplayScale(query=True)
    joint_radius = cmds.getAttr('{0}.radius'.format(joint))
    radius = joint_scale * joint_radius
    children = cmds.listRelatives(joint, children=True, path=True)
    if children:
        p1 = cmds.xform(joint, q=True, ws=True, t=True)
        p1 = OpenMaya.MPoint(*p1)
        p2 = cmds.xform(children[0], q=True, ws=True, t=True)
        p2 = OpenMaya.MPoint(*p2)
        radius = p1.distanceTo(p2)
    sphere = cmds.sphere(n='{0}_forward'.format(joint), p=(0, 0, 0), ax=(0, 0, -1), ssw=0, esw=180, r=radius, d=3, ut=0, tol=0.01, s=8, nsp=4, ch=0)[0]
    group = cmds.createNode('transform', name='{0}_grp'.format(sphere))
    cmds.parent(sphere, group)
    cmds.setAttr('{0}.sz'.format(sphere), 0)
    cmds.makeIdentity(sphere, apply=True)
    cmds.addAttr(sphere, longName=MESSAGE_ATTRIBUTE, attributeType='message')
    cmds.connectAttr('{0}.message'.format(joint), '{0}.{1}'.format(sphere, MESSAGE_ATTRIBUTE))
    cmds.select(sphere)
    cmds.hyperShade(assign=material)
    for attr in ['tx', 'ty', 'tz', 'ry', 'rz', 'v']:
        cmds.setAttr('{0}.{1}'.format(sphere, attr), lock=True, keyable=False)
    return group, sphere
Ejemplo n.º 23
0
    def __init__(self):
        xPos= 10
        #joints
        loftCircles = self.limbCircles
        limbJoints = self.limbJoints
        loftBone = self.limbLoftBones
        
        for i in range(0,2,1):
            limbJnt = cmds.sphere(n='joint_'+str(i))
            limbJoints.append(limbJnt[0])
            cmds.move(i*xPos,0,0,limbJnt)
            circleJnt = cmds.circle(n='circlelJnt_' + str(i),radius=0.4)
            cmds.move(i*xPos,0,0,circleJnt)
            cmds.rotate(0,-90,0,circleJnt)
            loftCircles.append(circleJnt[0])
 
            cmds.parent(circleJnt[0],limbJnt[0])
            
        loftBone = cmds.loft(loftCircles[0],loftCircles[1],n='loftBone')
        cmds.setAttr(loftBone[0] +  '.inheritsTransform',0)
        cmds.aimConstraint(limbJoints[1],loftCircles[0],mo=True)
        cmds.aimConstraint(limbJoints[0],loftCircles[1],mo=True)
        cmds.group(limbJoints[0],limbJoints[1],loftBone[0],n='limb')
Ejemplo n.º 24
0
		cmds.setAttr("%s.scaleX"%self.sphere, newScaleX)
		cmds.setAttr("%s.scaleZ"%self.sphere, newScaleZ)

testSphere1 = GrowingSphere()
testSphere2 = GrowignSphere()

testSphere1.grow()
testSphere2.grow()

#---------------
#basic use of pymel to show how keeping track of instances can be useful

#this is the python (maya.cmds) way of doing something
import maya.cmds as cmds

pythonSphere = cmds.sphere(n="pythonSphere")
print pythonSphere
print(type(pythonSphere))

#this is the pymel way of doing it
import pymel.core as pm
pymelSphere = pm.sphere(n="pymelSphere")
print pymelSphere
print(type(pymelSphere))

#now try to select them (then change their names and select them)
cmds.select(pythonSphere[0])
pm.select(pymelSphere[0])

#--------------
#a couple of bigger uses of classes in maya
Ejemplo n.º 25
0
	def __init__(self):
		self.sphere = cmds.sphere(n="sphere")[0]
Ejemplo n.º 26
0
#Commented Coding
#JWBerry

#Importing maya commands as cmds to be used later on
import maya.cmds as cmds
#Importing math to use Sin in my rotation
import math

for i in range(1, 73):
    #creating the sphere
    cmds.sphere()

    #Then I move the sphere off from the center
    cmds.move(
        0, 0, -10, relative=True
    )  #relative is okay here becuase I know the sphere is starting from 0,0,0, so it's the same as absolute

    #now to move the pivot point towards the center, making sure to increment the nurbsSphere thingy by one everytime by inserting ' + str(i) + '
    cmds.move(0, 0, 10, ('nurbsSphere' + str(i) + '.scalePivot'),
              ('nurbsSphere' + str(i) + '.rotatePivot'))

    #now to rotate the spheres
    cmds.rotate(0, i * 5, 0, r=True, os=True)

    #now I'm using sin to assign a new y position
    yTranslate = math.sin(math.radians(5 * i))

    cmds.move(0, yTranslate, 0, r=True)
Ejemplo n.º 27
0
#==============================================================================================

#>>Family ====================================================================================
ml_cgmObjects[4].getAllParents()#we can get all the parents of an object as well as the imediate
ml_cgmObjects[4].getAllParents(fullPath = True)#We can get full paths
ml_cgmObjects[4].getAllParents(asMeta = 1)#We can get those as meta too

ml_cgmObjects[0].getChildren()#We can get immediate children
ml_cgmObjects[0].getChildren(asMeta = True)#as meta or full path too

ml_cgmObjects[0].getAllChildren()#We can get all dag children
ml_cgmObjects[0].getAllChildren(asMeta = True)#as meta or full path too

ml_cgmObjects[0].getShapes()# Hmm...no shapes, let's try something with shapes

mi_sphere = cgmMeta.cgmObject(mc.sphere()[0]) #let's wrap a sphere
mi_sphere.getShapes() #Get some shapes
mi_sphere.getShapes(asMeta = 1) #as meta too

#What about some other relative checks...
ml_cgmObjects[1].getSiblings() #What is a sibling? A sibling is a definition of our own...
#It is an object at the same heirarchal level as another object of matching type to our source
ml_cgmObjects[1].getSiblings(asMeta = 1) #Can do the asMeta call as well

ml_cgmObjects[1].getFamilyDict()#Another way to get a few bits of data...

ml_cgmObjects[4].isChildOf(ml_cgmObjects[0]) #We can check up the dag tree for a logic check..
ml_cgmObjects[4].isChildOf(ml_cgmObjects[2]) #This one is not a child of that joint

ml_cgmObjects[0].isParentOf(ml_cgmObjects[1]) #Can check the other relationship as well
ml_cgmObjects[4].isParentOf(ml_cgmObjects[2])
Ejemplo n.º 28
0
	def _createControl(self):
		"""create control object"""
		#curve = mc.circle( c = (0,0,0), nr = (0,0,1), sw = 360, r = 1, d = 3, ut = 0, tol = 0.01, s = 8, ch = 0, n = self.name + '_ctl' )
		curve = mc.sphere( r=0.2, n = self.name + '_ctl' )
		self._control = mn.Node( curve[0] )
		return self._control
Ejemplo n.º 29
0
def buildEyeballGeo():
    #     try:
    # create eyeball controler-----------------------------------------------------------------------------------------
    gEyeballCtrler = cmds.spaceLocator()[0]
    cmds.addAttr(longName='pupilSize', attributeType='float', keyable=True, defaultValue=gDefaultPupilValue)
    cmds.addAttr(longName='irisSize', attributeType='float', keyable=True, defaultValue=gDefaultIrisValue)
    cmds.addAttr(longName='irisConcave', attributeType='float', keyable=True, defaultValue=gDefaultIrisConcaveValue)
    cmds.addAttr(longName='corneaBulge', attributeType='float', keyable=True, defaultValue=gDefaultCorneaBulgeValue)

    # cornea-----------------------------------------------------------------------------------------
    # create eyeball base geometry and detach
    eyeballSphere = cmds.sphere(sections=20, spans=20, axis=(0, 0, 1), radius=0.5)[0]
    #     eyeballSphere=eyeballSphere[0]
    pieceNames = cmds.detachSurface(eyeballSphere, ch=1, rpo=1, parameter=(0.1, 20))
    corneaGeo = pieceNames[0];
    corneaDetach = pieceNames[2];
    cmds.parent(eyeballSphere, gEyeballCtrler, relative=True)
    cmds.parent(corneaGeo, gEyeballCtrler, relative=True)

    # rebuild corneaGeo
    cmds.rebuildSurface(corneaGeo, ch=1, rpo=1, rt=0, end=1, kr=0, kcp=0, kc=0, su=36, du=3, sv=1, dv=3, tol=0.01, fr=0,
                        dir=0)

    # add lattice and deform cornea
    cmds.select(corneaGeo)
    (corneaLat, corneaLatGeo, corneaLatGeoBase) = cmds.lattice(dv=(2, 2, 6), oc=False)
    cmds.setAttr(corneaLatGeo + '.scale', 1.1, 1.1, 1.1)
    cmds.setAttr(corneaLatGeoBase + '.scale', 1.1, 1.1, 1.1)
    cmds.setAttr(corneaGeo + '.overrideEnabled', 1)
    cmds.setAttr(corneaGeo + '.overrideColor', 3)

    corneaDetachRider = cmds.createNode('transform')
    corneaDeformGrp = cmds.createNode('transform')
    corneaRadius = cmds.createNode('transform')

    cmds.parent(corneaDeformGrp, corneaDetachRider, relative=True)
    cmds.parent(corneaRadius, corneaDetachRider, relative=True)
    cmds.parent(corneaLatGeo, corneaDeformGrp, relative=True)
    cmds.parent(corneaLatGeoBase, corneaDeformGrp, relative=True)
    cmds.parent(corneaDetachRider, gEyeballCtrler, relative=True)

    cmds.hide(corneaDetachRider)

    # set opaque for Arnold render
    if gRenderer == 'mtoa':
        corneaGeoShape = cmds.listRelatives(corneaGeo, shapes=True)[0]
        cmds.setAttr(corneaGeoShape + '.aiOpaque', 0)


        # iris-----------------------------------------------------------------------------------------
    # create eyeball base geometry and detach
    eyeballSphere2 = cmds.sphere(sections=20, spans=20, axis=(0, 0, 1), radius=0.5)[0]
    pieceNames = cmds.detachSurface(eyeballSphere2, ch=1, rpo=1, parameter=(0.1, 20))
    irisGeo = pieceNames[0]
    irisDetach = pieceNames[2]
    cmds.delete(eyeballSphere2)
    cmds.parent(irisGeo, gEyeballCtrler, relative=True)

    # add lattice and deform iris
    cmds.select(irisGeo)
    (irisLat, irisLatGeo, irisLatGeoBase) = cmds.lattice(dv=(2, 2, 2), oc=False)
    cmds.setAttr(irisLatGeo + '.scale', 1.1, 1.1, -2)
    cmds.setAttr(irisLatGeoBase + '.scale', 1.1, 1.1, 2)
    cmds.setAttr(irisLatGeo + '.translateZ', -0.5)
    cmds.setAttr(irisLatGeoBase + '.translateZ', -0.5)
    cmds.setAttr(irisGeo + '.overrideEnabled', 1)
    cmds.setAttr(irisGeo + '.overrideColor', 13)

    irisDetachRider = cmds.createNode('transform')
    irisDeformGrp = cmds.createNode('transform')
    irisRadius = cmds.createNode('transform')

    cmds.parent(irisDeformGrp, irisDetachRider, relative=True)
    cmds.parent(irisRadius, irisDetachRider, relative=True)
    cmds.parent(irisLatGeo, irisDeformGrp, relative=True)
    cmds.parent(irisLatGeoBase, irisDeformGrp, relative=True)
    cmds.parent(irisDetachRider, gEyeballCtrler, relative=True)

    cmds.hide(irisDetachRider)

    # pupil-----------------------------------------------------------------------------------------
    # detach from iris geometry
    pieceNames = cmds.detachSurface(irisGeo, ch=1, rpo=1, parameter=(0.1, 20))
    pupilGeo = pieceNames[0]
    pupilDetach = pieceNames[2]
    cmds.parent(pupilGeo, gEyeballCtrler, relative=True)
    cmds.setAttr(pupilGeo + '.overrideEnabled', 1)
    cmds.setAttr(pupilGeo + '.overrideColor', 17)

    # connect attributes-----------------------------------------------------------------------------------------
    expressionStr = '''
                        //calculate cornea-related parameters
                        //cornea translate Z
                        float $cornea_tz = (cos(deg_to_rad(''' + gEyeballCtrler + '''.irisSize*9.0))) * 0.5;
                        //cornea radius
                        float $cornea_rad  = (sin(deg_to_rad(''' + gEyeballCtrler + '''.irisSize*9.0))) * 0.5;
                        //define nurbs surface cornea detach position
                        float $cornea_par  = ((1.0 - linstep( 0.0,10.0,''' + gEyeballCtrler + '''.irisSize)) * 10.0 ) + 10.0;
                        ''' + corneaDetach + '''.parameter[0] = $cornea_par;
                        ''' + corneaDetachRider + '''.translateZ = $cornea_tz;
                        ''' + corneaRadius + '''.translateX = $cornea_rad;
                        ''' + corneaDeformGrp + '''.translateZ = ( 0.5 - $cornea_tz ) * 0.5;
                        ''' + corneaDeformGrp + '''.scaleX = ''' + corneaDeformGrp + '''.scaleY = $cornea_rad * 2.0;
                        ''' + corneaDeformGrp + '''.scaleZ = ( 0.5 - $cornea_tz );
                        ''' + corneaLat + '''.envelope = (1.0 - (smoothstep(0.0,11.0,''' + gEyeballCtrler + '''.irisSize))) * (''' + gEyeballCtrler + '''.corneaBulge * 0.1);
                        
                        //calculate iris-related parameters
                        float $iris_tz   = ( cos(deg_to_rad((''' + gEyeballCtrler + '''.irisSize+0.3)*9.0)) ) * 0.485;
                        float $iris_rad  = ( sin(deg_to_rad((''' + gEyeballCtrler + '''.irisSize+0.3)*9.0)) ) * 0.485;
                        float $iris_par  = ((1.0 - ((''' + gEyeballCtrler + '''.irisSize+0.3)*0.1)) * 10.0 ) + 10.0;
                        ''' + irisDetach + '''.parameter[0] = $iris_par;
                        ''' + irisDetachRider + '''.translateZ = $iris_tz;
                        ''' + irisRadius + '''.translateX = $iris_rad;
                        ''' + irisDeformGrp + '''.translateZ = ( 0.5 - $iris_tz ) * 0.5;
                        ''' + irisDeformGrp + '''.scaleX = ''' + irisDeformGrp + '''.scaleY = $iris_rad * 2.0;
                        ''' + irisDeformGrp + '''.scaleZ = ( 0.5 - $iris_tz );
                        ''' + irisLat + '''.envelope = ''' + gEyeballCtrler + '''.irisConcave * 0.1;
                        
                        float $pupil_par = max( (((1.0 - ((''' + gEyeballCtrler + '''.pupilSize)*0.1)) * 10.0 ) + 10.0), $iris_par + 0.1 );
                        ''' + pupilDetach + '''.parameter[0] = $pupil_par;
                        '''

    cmds.expression(s=expressionStr)

    # deform latticeGeo
    for x in range(0, 2):
        for y in range(0, 2):
            for z in range(3, 6):
                pointNameStr = corneaLatGeo + '.pt[' + str(x) + '][' + str(y) + '][' + str(z) + ']'
                ptTranslateZ = cmds.getAttr(pointNameStr + '.zValue')
                cmds.setAttr(pointNameStr + '.zValue', ptTranslateZ * 2 + 0.319)
            #                     cmds.select(pointNameStr)
            #                     cmds.move(0, 0, 0.05, r=True)

            # rename objects------------------------------------
    gEyeballCtrlerName = 'eyeballCtrler'

    cmds.rename(gEyeballCtrler, gEyeballCtrlerName)
    cmds.rename(pupilGeo, 'pupilGeo')
    cmds.rename(pupilDetach, 'pupilDetach')

    cmds.rename(irisLat, 'irisLat')
    cmds.rename(irisLatGeo, 'irisLatGeo')
    cmds.rename(irisLatGeoBase, 'irisLatGeoBase')
    cmds.rename(irisGeo, 'irisGeo')
    cmds.rename(irisDetach, 'irisDetach')
    cmds.rename(irisDetachRider, 'irisDetachRider')
    cmds.rename(irisDeformGrp, 'irisDeformGrp')
    cmds.rename(irisRadius, 'irisRadius')
    cmds.rename(corneaLat, 'corneaLat')
    cmds.rename(corneaLatGeo, 'corneaLatGeo')
    cmds.rename(corneaLatGeoBase, 'corneaLatGeoBase')
    cmds.rename(eyeballSphere, 'eyeballSphere')
    cmds.rename(corneaGeo, 'corneaGeo')
    cmds.rename(corneaDetach, 'corneaDetach')
    cmds.rename(corneaDetachRider, 'corneaDetachRider')
    cmds.rename(corneaDeformGrp, 'corneaDeformGrp')
    cmds.rename(corneaRadius, 'corneaRadius')
Ejemplo n.º 30
0
	def HI(self):
                cmds.sphere()
Ejemplo n.º 31
0
def flowerMaker(nf):
    #erases anything on stage creates a new file
    #cmds.file( f=True, new=True)
    #sets plaback time
    numPetals = 10
    createShader = 1
    #Check for Shader
    shads = cmds.ls()
    for myNode in shads:
        if myNode == "petalColor":
            createShader = 0

    if createShader == 0:
        print "The Shader is already there \n"

    elif createShader == 1:
        cmds.shadingNode('lambert', n="petalColor", asShader=True)
        cmds.shadingNode('ramp', asTexture=True, n="petalRamp")
        cmds.sets(renderable=True,
                  empty=True,
                  noSurfaceShader=True,
                  n='petalColorSG')
        cmds.connectAttr('petalColor.outColor',
                         'petalColorSG.surfaceShader',
                         f=True)
        cmds.connectAttr('petalRamp.outColor', 'petalColor.color')
        cmds.setAttr("petalRamp.colorEntryList[3].color",
                     1,
                     1,
                     0.5,
                     type='double3')
        cmds.setAttr("petalRamp.colorEntryList[3].position", 1)
        cmds.setAttr("petalRamp.colorEntryList[2].color",
                     1,
                     1,
                     1,
                     type='double3')
        cmds.setAttr("petalRamp.colorEntryList[2].position", .5)
        cmds.setAttr("petalRamp.colorEntryList[1].color",
                     1,
                     0.5,
                     0.5,
                     type='double3')
        cmds.setAttr("petalRamp.colorEntryList[1].position", 0)
        cmds.setAttr('petalRamp.type', 8)

        cmds.shadingNode('lambert', n="coreColor", asShader=True)
        cmds.shadingNode('ramp', asTexture=True, n="coreRamp")
        cmds.sets(renderable=True,
                  empty=True,
                  noSurfaceShader=True,
                  n='coreColorSG')
        cmds.connectAttr('coreColor.outColor',
                         'coreColorSG.surfaceShader',
                         f=True)
        cmds.connectAttr('coreRamp.outColor', 'coreColor.color')
        cmds.setAttr("coreRamp.colorEntryList[3].color",
                     1,
                     1,
                     0.5,
                     type='double3')
        cmds.setAttr("coreRamp.colorEntryList[3].position", 1)
        cmds.setAttr("coreRamp.colorEntryList[1].color",
                     1,
                     0.5,
                     0.5,
                     type='double3')
        cmds.setAttr("coreRamp.colorEntryList[1].position", 0)
        cmds.setAttr('coreRamp.type', 8)

    cmds.sphere(ax=(0, 1, 0), n="core")
    #build the flower core
    myCore = cmds.ls(sl=1)
    cmds.scale(1, .5, 1)
    cmds.move(0, 0.2, 0)
    cmds.sets(myCore[0], edit=True, forceElement='coreColorSG')
    #build the petal
    cmds.sphere(ax=(0, 1, 0))
    cmds.move(0, 0, -1.6)
    cmds.scale(.7, .3, 1.7)
    cmds.FreezeTransformations()
    cmds.ResetTransformations()
    myPetal = cmds.ls(sl=1)
    cmds.parent(myPetal, myCore, shape=True)
    cmds.select(myPetal[0])
    cmds.pickWalk(d='down')
    myPetalShape = cmds.ls(sl=1)
    cmds.sets(myPetalShape[0], edit=True, forceElement='petalColorSG')
    #move the tip of the petal
    cmds.select(myPetal[0] + ".cv[3][7]")
    cmds.move(0, 2, 0, r=1)
    #Select the inner part of the petal pull down
    #One loop for the U direction
    for uCV in range(5, 7):
        for vCV in range(0, 8):
            cmds.select(myPetal[0] + ".cv[" + str(uCV) + "][" + str(vCV) + "]")
            cmds.move(0, -0.4, 0, r=1)

    cmds.select(myPetal[0])
    degreeApart = float((360 / numPetals))

    for k in range(3):
        if k is not 0:
            cmds.duplicate()
            cmds.scale((k % 2 + 1) * 0.5)
            cmds.rotate(k * 20, k * 20)
        for i in range(2, numPetals + 1):
            cmds.duplicate()
            cmds.rotate(0, degreeApart, 0, r=1)

    cmds.select(myCore)
    cmds.rename('Flower' + str(nf))
# #############################################################################