Ejemplo n.º 1
0
def createFocusPlane():
    mc.polyPlane(name="AAfocusPlane",
                 w=10,
                 h=10,
                 sx=1,
                 sy=1,
                 ax=(0, 1, 0),
                 cuv=2,
                 ch=0)

    mySurfaceShader = mc.shadingNode("surfaceShader",
                                     asShader=True,
                                     name="AAfocusPlaneShader")
    mc.setAttr("AAfocusPlaneShader.outColor", 1, 0, 0, type="double3")
    mc.setAttr("AAfocusPlaneShader.outTransparency",
               0.6,
               0.6,
               0.6,
               type="double3")

    mc.select('AAfocusPlane')
    mc.hyperShade(assign=mySurfaceShader)
    mc.select(cl=True)
    mc.hyperShade(objects=mySurfaceShader)

    #set a visibilidade do plano para o render
    mc.setAttr("AAfocusPlaneShape.castsShadows", 0)
    mc.setAttr("AAfocusPlaneShape.receiveShadows", 0)
    mc.setAttr("AAfocusPlaneShape.holdOut", 0)
    mc.setAttr("AAfocusPlaneShape.motionBlur", 0)
    mc.setAttr("AAfocusPlaneShape.primaryVisibility", 0)
    mc.setAttr("AAfocusPlaneShape.smoothShading", 0)
    mc.setAttr("AAfocusPlaneShape.visibleInReflections", 0)
    mc.setAttr("AAfocusPlaneShape.visibleInRefractions", 0)
    mc.setAttr("AAfocusPlaneShape.doubleSided", 1)
Ejemplo n.º 2
0
def generateLeaf(jointPosWorld, planeCnt, jntName):
    cmds.polySphere(r=0.475)
    cmds.move(jointPosWorld[0], jointPosWorld[1], jointPosWorld[2]) #xyz values of joint stored in an array
    cmds.polyPlane(n='leaf'+str(planeCnt), sx=1, sy=3, w=2, h=3)
    shape = 'leaf' + str(planeCnt)
    
    cmds.select(shape + '.e[0]') #selecting the edges and scaling them down to get leaf shape
    cmds.scale( 0.1, 1, 1 )

    cmds.select(shape + '.e[9]')
    cmds.scale( 0, 1, 1 )
    
    cmds.select(shape)
    cmds.polySmooth( shape, dv=2, sdt=1) #smooth it out to round out edges
    cmds.move(0, 0, 1.46, shape + ".scalePivot", shape + ".rotatePivot", absolute=True)
    
    cmds.move(jointPosWorld[0], jointPosWorld[1], (jointPosWorld[2] - 1.31))
    cmds.aimConstraint( jntName, shape )
    cmds.aimConstraint( jntName, shape, rm=True )
    cmds.rotate((str((randint(0,180)))) + 'deg', (str((randint(0,180)))) + 'deg', (str((randint(0,180)))) + 'deg', r=True )
    cmds.polyExtrudeFacet(ltz=0.1) #extrude the leaf to get rid of null sides
    
    #each leaf has a unique size chosen by a random scale value
    scaleVal = random.uniform(0.8,1.2)
    cmds.scale( scaleVal, scaleVal, scaleVal )
Ejemplo n.º 3
0
def make_shape(type, name, divisions):
    """
    Creates shape based on argument passed

    Args:
        type: {cube, cone, cylinder, plane, torus, sphere}
        name: name of the object
        divisions: number of subdivisions we want to apply in x,y and z axis.
                   Same value will be taken in all axis.
    Return:
        None
    """

    if type == 'cube':
        mc.polyCube(n=name, sx=divisions, sy=divisions, sz=divisions)
    elif type == 'cone':
        mc.polyCone(n=name, sx=divisions, sy=divisions, sz=divisions)
    elif type == 'cylinder':
        mc.polyCylinder(n=name, sx=divisions, sy=divisions, sz=divisions)
    elif type == 'plane':
        mc.polyPlane(n=name, sx=divisions, sy=divisions)
    elif type == 'torus':
        mc.polyTorus(n=name, sx=divisions, sy=divisions)
    elif type == 'sphere':
        mc.polySphere(n=name, sx=divisions, sy=divisions)
    else:
        mc.polySphere()
Ejemplo n.º 4
0
    def setUp(self):
        MayaCmds.file(new=True, force=True)
        self.__files = []

        # write out an animated Alembic file
        createAnimatedSolarSystem()
        self.__files.append(util.expandFileName("testAnimatedSolarSystem.abc"))
        MayaCmds.AbcExport(j="-fr 1 24 -root group1 -root group2 -file " + self.__files[-1])

        # write out a static Alembic file that's different than the static scene
        # created by createStaticSolarSystem()
        MayaCmds.currentTime(12, update=True)
        self.__files.append(util.expandFileName("testStaticSolarSystem.abc"))
        MayaCmds.AbcExport(j="-fr 12 12 -root group1 -root group2 -file " + self.__files[-1])

        # write out an animated mesh with animated parent transform node
        MayaCmds.polyPlane(sx=2, sy=2, w=1, h=1, ch=0, n="polyMesh")
        MayaCmds.createNode("transform", n="group")
        MayaCmds.parent("polyMesh", "group")

        # key the transform node
        MayaCmds.setKeyframe("group", attribute="translate", t=[1, 4])
        MayaCmds.move(0.36, 0.72, 0.36)
        MayaCmds.setKeyframe("group", attribute="translate", t=2)

        # key the mesh node
        MayaCmds.select("polyMesh.vtx[0:8]")
        MayaCmds.setKeyframe(t=[1, 4])
        MayaCmds.scale(0.1, 0.1, 0.1, r=True)
        MayaCmds.setKeyframe(t=2)
        self.__files.append(util.expandFileName("testAnimatedMesh.abc"))
        MayaCmds.AbcExport(j="-fr 1 4 -root group -file " + self.__files[-1])

        MayaCmds.file(new=True, force=True)
Ejemplo n.º 5
0
    def create_terrain(self, grid_name, dimensions, subdivisions):
        """
        This function creates the grid with parameters given.
            Parameters:
                grid_name (str): The name that the terrain is going to have.
                dimensions (int): Dimensions for width and height.
                subdivisions (int): Amount of subdivisions for the grid.
        """
        if logger.level == logging.DEBUG:
            start_time = time.time()

        # Create polyPlane with given parameters
        cmds.polyPlane(name=grid_name,
                       width=dimensions,
                       height=dimensions,
                       sx=subdivisions,
                       sy=subdivisions)

        # Save those values so they can be accessed by other functions
        self.gridObject = cmds.ls(selection=True)[0]
        self.gridDimensions = dimensions
        self.gridSubdivisions = subdivisions

        if logger.level == logging.DEBUG:
            logger.debug("--- Grid CREATION took: {} ---".format(time.time() -
                                                                 start_time))
Ejemplo n.º 6
0
    def testAnimatedMeshSwap(self):

        MayaCmds.polyPlane(sx=2, sy=2, w=1, h=1, ch=0, n='polyMesh')
        MayaCmds.createNode('transform', n='group')
        MayaCmds.parent('polyMesh', 'group')
        MayaCmds.AbcImport(self.__files[2], connect='group')

        # this is loaded in for value comparison purpose only
        MayaCmds.AbcImport(self.__files[2], mode='import')

        # check the swapped scene at every frame
        for frame in range(1, 4):
            MayaCmds.currentTime(frame, update=True)
            # tranform node group
            checkEqualTranslate(self, 'group', 'group1', 4)
            # tranform node group
            checkEqualTranslate(self, 'group|polyMesh', 'group1|polyMesh', 4)
            # mesh node polyMesh
            for index in range(0, 9):
                string1 = 'group|polyMesh.vt[%d]' % index
                string2 = 'group1|polyMesh.vt[%d]' % index
                self.failUnlessAlmostEqual(
                    MayaCmds.getAttr(string1)[0][0],
                    MayaCmds.getAttr(string2)[0][0], 4,
                    '%s.x != %s.x' % (string1, string2))
                self.failUnlessAlmostEqual(
                    MayaCmds.getAttr(string1)[0][1],
                    MayaCmds.getAttr(string2)[0][1], 4,
                    '%s.y != %s.y' % (string1, string2))
                self.failUnlessAlmostEqual(
                    MayaCmds.getAttr(string1)[0][2],
                    MayaCmds.getAttr(string2)[0][2], 4,
                    '%s.z != %s.z' % (string1, string2))
Ejemplo n.º 7
0
	def showPlan( self ):
		
		self.getCoordsBoard()
		
		coords = [ self.curPlanCoords[0:3] , self.curPlanCoords[3:6] , self.curPlanCoords[6:9] ] 
		
		# get trs
		position = utilsMath.getBBbarycentre( self.curPlanCoords )
		vUp      = [  coords[2][0] - coords[1][0] , coords[2][1] - coords[1][1] , coords[2][2] - coords[1][2]  ]
		rotation = utilsMayaApi.API_convert2CoordsToEulerOrient( coords[0] , coords[1] , vUp )
		scale        = [ 100 , 100 , 100 ]			

		trs =  position + rotation + scale 
		
		
		# build plane
		symPlaneName = 'mirrorManip_symPlane_msh'
		
		if( mc.objExists( symPlaneName ) ):
			mc.delete( symPlaneName )
			
		mc.polyPlane( n = symPlaneName )
		mc.setAttr( symPlaneName + '.rx' , 90 )
		mc.makeIdentity( symPlaneName , r = True , a = True)		
		utilsMaya.setTRSValueToObj( symPlaneName , trs )

		print(  'create mesh representing plan of coords :' , self.curPlanCoords)		
		return 1
def createHoneyPiece(n):
    planeName = 'plane'+str(n)
    print planeName
    cmds.polyPlane(w=20, h=20, sx=12, sy=12, n=planeName)
    edgeNum = 26
    modVal = 1;
    edgeArray = []
    for i in range(52):
        edgeArray.append(planeName+'.e['+str(edgeNum)+']');
        edgeNum += 2
        if(edgeNum == 51):
            edgeNum = 101
        if(edgeNum==50):
            edgeNum = 49
        if(edgeNum == 126):
            edgeNum = 176
        if(edgeNum==125):
            edgeNum = 124
        if(edgeNum==201):
            edgeNum = 251
        if(edgeNum==200):
            edgeNum = 199
        if(edgeNum==275):
            edgeNum = 274
    cmds.polyBevel(edgeArray, offset=1,offsetAsFraction=1,autoFit=1,segments=1,worldSpace=1,uvAssignment=0,fillNgons=1,mergeVertices=1,mergeVertexTolerance=0.0001,smoothingAngle=30,miteringAngle=180,angleTolerance=180,ch=1)
    cmds.select( clear=True)
    print len(edgeArray)
    del edgeArray[:]
    print len(edgeArray)
    for i in range(532, 620):
        cmds.select(planeName+'.e['+str(i)+']', toggle=True);
    size = 36;
    edgeNum = 31
    counter = 0
    for i in range(size):
        cmds.select(planeName+'.e['+str(edgeNum)+']', toggle=True);
        edgeNum += 2
        counter += 1
        if(counter == 12):
            counter = 0
            edgeNum += 7;
    cmds.delete();
    for i in range(12):
         cmds.select(planeName+'.f['+str(i)+']', toggle=True);
    for i in range(96, 108):
         cmds.select(planeName+'.f['+str(i)+']', toggle=True);
    for i in range(1,8):
        cmds.select(planeName+'.f['+str(i*12)+']', toggle=True);
    for i in range(1,8):
        cmds.select(planeName+'.f['+str(i*12+11)+']', toggle=True);
    cmds.delete();
    
    cmds.scale(1, 1, 0.5, planeName);
    #cmds.select(planeName+'.f[0:113]')
    cmds.polyExtrudeFacet(planeName+'.f[0:113]', constructionHistory=1, keepFacesTogether=0, pvx=4.7, pvy=-1.058, pvz=2.38, divisions=1, twist=0, taper=1, off=0, thickness=0, smoothingAngle=30)
    cmds.setAttr("polyExtrudeFace"+str(n*2+1)+".localScale", 0.833333, 0.833333, 0.829938, type="double3")
    cmds.delete();
    cmds.select(planeName+'.f[0:723]')
    cmds.polyExtrudeFacet(constructionHistory=1, keepFacesTogether=1, pvx=-4.7, pvy=-1.058, pvz=2.38, divisions=1, twist=0, taper=1, off=0, thickness=0, smoothingAngle=30)
    cmds.setAttr("polyExtrudeFace"+str(n*2+2)+".localTranslate", 0, 0, 1, type="double3")
Ejemplo n.º 9
0
def GenTerrain(DATA_SIZE, SEED, h, j):
	
	createTerrainData(DATA_SIZE, SEED, h, j)
	
	name = 'Terrain'
	totalPoints=(DATA_SIZE)*(DATA_SIZE)
	
	if (cmds.objExists(name) == True):
		cmds.delete(name)
    
	cmds.polyPlane( n=name, sx=(DATA_SIZE-1), sy=(DATA_SIZE-1), h=20, w=20)
	count = 0
	
	cmds.progressWindow(title='Setting Points', progress=count, max = totalPoints, status='Setting: 0/'+str(totalPoints))            
                         
	for i in xrange(DATA_SIZE):
		if True: cmds.refresh()
		cmds.delete(name, ch = True)
		for j in xrange(DATA_SIZE):
					offset = dataArray[i][j]
					cmds.polyMoveVertex( name+'.vtx['+str(count)+']', ws = True, ty = offset, cch=True)
					cmds.progressWindow(edit=True, progress=count, status='Setting: '+str(count))
					count+=1
                                    
	cmds.progressWindow(endProgress=1)

	#cmds.polySmooth(n=name, cch = True)
	cmds.delete(name, ch = True)
Ejemplo n.º 10
0
    def createBladeOfGrass(self):
        """ This method creates a blade of grass. """

        # random the high of blade
        self.grassHeight = 0.2 * random.randrange(6, 10)

        # create the plane of blade
        mc.polyPlane(axis=(0, 0, 0),
                     subdivisionsX=2,
                     subdivisionsY=6,
                     height=4)
        mc.move(0, 2, 0)
        self.currentBlade = mc.ls(sl=True)

        # create the form of blade
        mc.displaySmoothness(divisionsU=3,
                             divisionsV=3,
                             pointsWire=16,
                             pointsShaded=4,
                             polygonObject=3)
        mc.select(self.currentBlade[0] + ".vtx[18:20]", r=True)
        mc.softSelect(softSelectEnabled=True, ssd=20, sud=0.5)
        mc.scale(0.1, 1, 1, p=(0, 9.86, 0), r=True)
        mc.softSelect(ssd=8.08, sud=0.5)

        # bend the grass
        bendGrassRandom = 15 * (3.0 - random.random())
        mc.rotate(bendGrassRandom, 0, 0, os=True, r=True, p=(0, 9.18, 0))
        mc.select(self.currentBlade)
        extrudeFace = mc.polyExtrudeFacet(self.currentBlade[0] + ".f[0:11]",
                                          constructionHistory=1,
                                          keepFacesTogether=1,
                                          pvx=0,
                                          pvy=4.84,
                                          pvz=0.14,
                                          divisions=1,
                                          twist=0,
                                          taper=1,
                                          off=0,
                                          thickness=0,
                                          smoothingAngle=30)
        mc.setAttr(extrudeFace[0] + ".localTranslate",
                   0,
                   0,
                   0.05,
                   type='double3')
        mc.softSelect(softSelectEnabled=False)

        # scale the blade
        mc.select(self.currentBlade)
        mc.scale(1, self.grassHeight, 1, r=True)

        # delete history
        maya.mel.eval("DeleteHistory")

        # change the position
        self.changePositionBlade()

        return self.currentBlade
Ejemplo n.º 11
0
def main():
    cmds.softSelect(sse=1, ssd=85.0, ssf=2)
    lines, dimensions = read_in_lines()
    print(dimensions)
    x = dimensions[0]
    y = dimensions[1]
    cmds.polyPlane(width=x, height=y, sx=x, sy=y)
    raise_points(lines, dimensions, 15)
Ejemplo n.º 12
0
def make_scene():
    cmds.file(new=True, f=True)
    cmds.polyPlane(w=5, sw=2, h=5, sh=1, name='square')
    mel.eval("displayStyle -textured")
    mel.eval("displayStyle -wireframeOnShaded")
    cmds.file(rename='TwoPolygonMesh.ma')
    cmds.file(type='mayaAscii', save=True)
    cmds.polyOptions(colorShadedDisplay=True, colorMaterialChannel='none')
Ejemplo n.º 13
0
 def CreateImagePlane(self):
     print self.ChildSelection
     print self.ParentSelection
     
     Texture = self.Path + self.ParentSelection + "/" + self.ChildSelection + ".png"
     
     if os.path.exists(Texture):
         if cmds.objExists("RWSPlane"):
             cmds.delete("RWSPlane")
         if cmds.objExists("RWSTexture"):
             cmds.delete("RWSTexture")
         if cmds.objExists("RWSTexturePlacer"):
             cmds.delete("RWSTexturePlacer")
         if cmds.objExists("RWSShader"):
             cmds.delete("RWSShader")
         if cmds.objExists("RWSShaderSG"):
             cmds.delete("RWSShaderSG")
             
         cmds.polyPlane(name = "RWSPlane",width = cmds.floatField("RWSYfield", query = True, v = True), height = cmds.floatField("RWSZfield", query = True, v = True) , subdivisionsX = 1, subdivisionsY = 1  )
         cmds.rotate(90, 0, 0, "RWSPlane" )
         
         cmds.setAttr("RWSPlaneShape.castsShadows", 0)
         cmds.setAttr("RWSPlaneShape.receiveShadows", 0)
         cmds.setAttr("RWSPlaneShape.motionBlur", 0)
         cmds.setAttr("RWSPlaneShape.primaryVisibility", 0)
         cmds.setAttr("RWSPlaneShape.smoothShading", 0)
         cmds.setAttr("RWSPlaneShape.visibleInReflections", 0)
         cmds.setAttr("RWSPlaneShape.visibleInRefractions", 0)
         cmds.setAttr("RWSPlaneShape.doubleSided", 0)
         
         if cmds.objExists("CMSettings"):
             ModelName = cmds.getAttr("CMSettings.ModelName")
         else:
             ModelName = cmds.ls(sl = True)
             
         
         bbx = cmds.xform(ModelName, bb = True, q = True)
         zMove = -(bbx[5]-bbx[2])/2
         yMove = cmds.floatField("RWSZfield", query = True, v = True)/20
         cmds.move(0, yMove, zMove ,"RWSPlane")
         material = cmds.shadingNode('lambert', asShader=1, name='RWSShader')
         SG = cmds.sets(renderable=1, noSurfaceShader=1, empty=1, name = 'RWSShaderSG')   
         cmds.connectAttr((material + '.outColor'),(SG + '.surfaceShader'),f=1)
         
         cmds.shadingNode("file", asTexture = True, name = "RWSTexture" )
         cmds.setAttr("RWSTexture.fileTextureName", Texture, type = "string")
         cmds.shadingNode("place2dTexture", asUtility = True, name = "RWSTexturePlacer")
         cmds.connectAttr( "RWSTexturePlacer.outUV", "RWSTexture.uv")
         cmds.connectAttr( "RWSTexturePlacer.outUvFilterSize", "RWSTexture.uvFilterSize")
         cmds.connectAttr(  "RWSTexture.outColor", "RWSShader.color", force = True)
          
         try:
             cmds.select("RWSPlane")
             cmds.sets(cmds.ls(selection = True), forceElement = 'RWSShaderSG', e = True)
         except:
             print "Failed to assign shader"
         
         cmds.select(None)
Ejemplo n.º 14
0
	def setUpModel(self):
		#c.file('C:/Users/Sebastian/Documents/maya/projects/default/data/Cobblestones3/Files/untitled.fbx', type='FBX', ra=True, mergeNamespacesOnClash=False, namespace='untitled', options='fbx',  i=True);	
		#name = 'C:\Users\Sebastian\Documents\maya\projects\default\sourceimages\exr\Location_1_1_hdr.exr';
		#sphere = c.polySphere(n='worldSphere', ax=[0, 0, 0], r=80);
		#shader = c.shadingNode('surfaceShader', asShader=True);
		#SG = c.sets(empty=True, renderable=True, noSurfaceShader=True, name=shader+"SG");
		#c.connectAttr(shader+'.outColor', SG+".surfaceShader", force=True);
		#img = c.shadingNode('file', asTexture=True);
		#c.setAttr(img+'.fileTextureName', name, type='string');
		#c.connectAttr(img+'.outColor', shader+'.outColor', force=True);
		#c.sets(sphere[0], edit=True, forceElement=SG);
		#c.setAttr(img+'.hdrMapping', 2);
		#c.setAttr(img+'.hdrExposure', 3);
		
		ground = c.polyPlane(h=100,w=120, n='groundPlane');
		c.move(37,-13, -15, 'groundPlane');
		c.rotate(0, -20, -5,'groundPlane');
		alphaShader = c.shadingNode('lambert', asShader=True, n='alphaShader')
		SG2 = c.sets(empty=True, renderable=True, noSurfaceShader=True, name=alphaShader+"SG2");
 		c.setAttr(alphaShader+'.transparency', 1, 1, 1, type="double3");
 		c.select( 'groundPlane' );
 		c.hyperShade( assign=alphaShader);

		if not (c.pluginInfo("Mayatomr",q=True,loaded=True)):
			c.loadPlugin("Mayatomr")
		else:
			pass
		
		"""
			To load the hdr image from path
		"""
		HDR_Path = c.optionVar(q="WeatherViz_HDR_Path")
		if HDR_Path:
			if os.path.exists(HDR_Path):
				print HDR_Path;
				_setUpIBL();

				return True
			else:
				mel.eval("error(\"WeatherViz | hdr image doesnt exist!\");")
		else:
			mel.eval("warning(\"WeatherViz | No hdr image found!\");")
			#c.confirmDialog(title="sIBL_GUI | Warning", message="No Loader Script found!\nPlease define one in preferences!", button=["Ok"], defaultButton="Ok")
		
		
		
		
		
		ground = c.polyPlane(h=100,w=120, n='groundPlane');
		c.move(37,-13, -15, 'groundPlane');
		c.rotate(0, -20, -5,'groundPlane');
		
		
		alphaShader = c.shadingNode('lambert', asShader=True, n='alphaShader');
		SG2 = c.sets(empty=True, renderable=True, noSurfaceShader=True, name=alphaShader+"SG2");
		c.setAttr(alphaShader+'.transparency', 1, 1, 1, type="double3");
		c.select( 'groundPlane' );
		c.hyperShade( assign=alphaShader);
 def testRenderableOnly(self):
     MayaCmds.polyPlane(name='potato')
     MayaCmds.polyPlane(name='hidden')
     MayaCmds.setAttr("hidden.visibility", 0)
     self.__files.append(util.expandFileName('renderableOnlyTest.abc'))
     MayaCmds.AbcExport(j='-renderableOnly -file ' + self.__files[-1])
     MayaCmds.AbcImport(self.__files[-1], m='open')
     self.failUnless(MayaCmds.objExists('potato'))
     self.failIf(MayaCmds.objExists('hidden'))
 def testRenderableOnly(self):
     MayaCmds.polyPlane(name='potato')
     MayaCmds.polyPlane(name='hidden')
     MayaCmds.setAttr("hidden.visibility", 0)
     self.__files.append(util.expandFileName('renderableOnlyTest.abc'))
     MayaCmds.AbcExport(j='-renderableOnly -file ' + self.__files[-1])
     MayaCmds.AbcImport(self.__files[-1], m='open')
     self.failUnless(MayaCmds.objExists('potato'))
     self.failIf(MayaCmds.objExists('hidden'))
Ejemplo n.º 17
0
 def doIt(self,argList):
     cmds.polyPlane(n='myPlane', h=5, w=2)
     cmds.polySphere(n='mySphere', r=5)
     cmds.select('mySphere')
     cmds.move(0,5,0)
     cmds.rigidBody( n='myRigidBody', active=True, b=0.5, sf=0.4 )
     cmds.select(cl=True)
     cmds.gravity(n='myGravity')
     cmds.connectDynamic('mySphere', fields='myGravity')
Ejemplo n.º 18
0
def make_scene():
    cmds.file(new=True, f=True)
    cmds.polyPlane(w=1, sw=2, h=1, sh=1, name="square")
    cmds.polyUVSet(create=True, uvSet="map2")
    cmds.polyUVSet(copy=True, uvSet="map1", newUVSet="map2")
    mel.eval("displayStyle -textured;")
    mel.eval("displayStyle -wireframeOnShaded;")
    cmds.file(rename="C:\\TwoPolygonMesh.ma")
    cmds.file(type="mayaAscii", save=True)
Ejemplo n.º 19
0
def QTM_FunctionalTest1():
    # Resets everything
    QTM_TestResetScene()
    QTM_TestResetHypershade()
    # Creates a plane
    cmds.polyPlane(name='Object001', w=5, h=5, sx=True, sy=True)
    myMaterial = QTM_NewTextureMaterial()
    # Selects the object and applies the new material
    cmds.select('Object001')
    cmds.hyperShade(assign=myMaterial)
Ejemplo n.º 20
0
def makeCity():

    cmds.select(all=True)
    cmds.delete()
    for i in range(0, 10):
        cmds.polyPlane(sx=10, sy=10, w=25, h=25, name='myP' + str(i))
        cmds.move(i * 25, 0, 0, 'myP' + str(i), a=True, ws=True)
        for j in range(0, 10):
            cmds.duplicate('myP' + str(i), n='myP' + str(i) + str(j))
            cmds.move(i * 25, 0, j * 25 + 25, 'myP' + str(i), a=True, ws=True)
Ejemplo n.º 21
0
    def generate(self, *_):

            # Set polyplane for ground level
            cmds.polyPlane(width=self.options.xDim, height=self.options.yDim)
            cmds.move(self.options.xDim/2, 0, self.options.yDim/2)

            x = 0

            # Nested while loop to create grid of buildings
            while x < self.options.xDim:
                z = 0
                while z < self.options.yDim:
                    # Get random height within range
                    height = random.randrange(self.options.minHeight, self.options.maxHeight)

                    # Choice of building type, accounting for if cylinder checkbox is checked
                    """
                    if self.options.cylinderOption == 1:
                        buildingType = random.randrange(0, 10)
                    else:
                        buildingType = 1
                    """
                    probabilityTotal = self.options.cubeProbability + self.options.cylinderProbability + self.options.coneProbability
                    print("Prob total:" + str(probabilityTotal))
                    buildingType = random.randrange(0, probabilityTotal)

                    buildingWidth = random.randrange(1, 3)

                    if buildingType < self.options.cubeProbability:
                        # PolyCube option
                        cube = CubeBuilding(buildingWidth, height)
                        cube.move_building(x + buildingWidth//2 + self.options.buildingGap, height//2, z + buildingWidth//2 + self.options.buildingGap)

                        if self.options.antennaOption == 1:
                            # Antenna option
                            isAntenna = random.randrange(0, 10)
                            if isAntenna < 2:
                                cube.add_antenna(x + buildingWidth//2 + self.options.buildingGap, height, z + buildingWidth//2 + self.options.buildingGap)
                        self.buildings.append(cube)

                    elif (buildingType >= self.options.cubeProbability) and buildingType < (self.options.cubeProbability + self.options.cylinderProbability):
                        # Cylinder option
                        subdiv = random.randrange(3, 12)
                        cylinder = CylinderBuilding(buildingWidth, height, subdiv)
                        cylinder.move_building(x + buildingWidth//2 + self.options.buildingGap, height//2, z + buildingWidth//2 + self.options.buildingGap)
                        self.buildings.append(cylinder)
                        
                    else:
                        # Cone option
                        cone = ConeBuilding(buildingWidth, height)
                        cone.move_building(x + buildingWidth//2 + self.options.buildingGap, height//2, z + buildingWidth//2 + self.options.buildingGap)
                        self.buildings.append(cone)                        

                    z += buildingWidth + self.options.buildingGap
                x += buildingWidth + self.options.buildingGap
Ejemplo n.º 22
0
def demo():
    cmds.file(f=1, new=1)
    cmds.polyPlane(w=50, h=50)
    cmds.rotate(1.555, -6.203, 6.393, r=1, os=1, fo=1)
    cmds.spotLight()
    cmds.move(14.142, 26.414, 18.0)
    cmds.rotate(-54, 36.4, 0, r=1, os=1, fo=1)
    if cmds.objExists('arrows'):
        cmds.delete('arrows')
    cmds.select(['pPlane1', 'spotLight1'])
    intersect()
Ejemplo n.º 23
0
def demo():
    cmds.file(f=1, new=1)
    cmds.polyPlane(w=50, h=50)
    cmds.rotate(1.555, -6.203, 6.393, r=1, os=1, fo=1)
    cmds.spotLight()
    cmds.move(14.142, 26.414, 18.0)
    cmds.rotate(-54, 36.4, 0, r=1, os=1, fo=1)
    if cmds.objExists('arrows'):
        cmds.delete('arrows')
    cmds.select(['pPlane1', 'spotLight1'])
    intersect()
Ejemplo n.º 24
0
 def editGeometry(self, size = 12, divisions = 50, *args):
     selection = args
     if not len(args):
         selection = cmds.ls(sl = True)
     for sel in selection:
         if sel in self.curves:
             cmds.polyPlane(self.curves[sel]['shape'], e = True, h = size, w = size)
             cmds.polyExtrudeEdge(self.curves[sel]['extrudeNde'], e=True,divisions = divisions)
             plane = self.curves[sel]['geometry']
             self.createUv(mesh = plane)
     cmds.select(selection, r = True)
Ejemplo n.º 25
0
 def CreateDeformer(self):
     if not mc.pluginInfo('hotOceanDeformer.mll', q=True, l=True):
         mc.loadPlugin('hotOceanDeformer.mll')
     mc.polyPlane(n='OceanPreview',
                  w=20,
                  h=20,
                  sx=150,
                  sy=150,
                  ax=[0, 1, 0],
                  cuv=2,
                  ch=1)
     mc.deformer(type='hotOceanDeformer')
Ejemplo n.º 26
0
    def __create_cloth_mesh(self, sub_x, sub_y, len_x, len_y, pivot_loc):
        cmds.polyPlane(name='m_cloth_mesh', sx=sub_x, sy=sub_y, w=len_x, h=len_y)
 
        clus_grp = cmds.group(em=True, n='vtx_cluster_GRP')
        mesh_vtx = cmds.ls('m_cloth_mesh.vtx[:]', fl=True)
        for vtx in mesh_vtx:
            cur_clus = cmds.cluster(vtx)
            cmds.setAttr('%sHandle.visibility' % cur_clus[0], False)
            cmds.parent(cur_clus, clus_grp)
            cmds.setAttr('%sHandle.translate' % cur_clus[0], pivot_loc[0], pivot_loc[1], pivot_loc[2])
            self.m_vtx_clus.append(cur_clus[1])
        self.__get_cloth_vtx_pos()
Ejemplo n.º 27
0
def create_plane():
    global mesh_width
    mesh_width = cmds.intSliderGrp('input_width', query=True, value=True)
    global mesh_length
    mesh_length = cmds.intSliderGrp('input_length', query=True, value=True)
    global mesh_sub
    mesh_sub = cmds.intSliderGrp('input_sub', query=True, value=True)

    # Create a polygonal mesh
    global mesh_name
    mesh_name = "worldMesh"
    cmds.polyPlane(sx=mesh_sub, sy=mesh_sub,  w=mesh_width, h=mesh_length, n=mesh_name)
Ejemplo n.º 28
0
def initializeRibbon(initWidth):
	mc.polyPlane(sx = 240, sy = 2.0, n = "ribbonTemp", w = initWidth, h = 0.165)
	mc.rename("polyPlane1", "ribbonTempHistory")
	mc.polySoftEdge( a = 180)
	mc.lattice( n = 'ribbon', cp = True, dv = (2, 4, 2), objectDentered = True, ldv = (2, 3, 2), outsideLattice = True )
        mc.hide()
	mc.select('ribbonTempHistory.vtx[1]', r=True )
	mc.ChamferVertex()
	mc.rename( "polyChamfer1", "tempChamfer" )
	mc.seAttr( 'tempChamfer.width', 1)
	mc.delete( 'ribbonTemp.vtx[72]' )
	return
Ejemplo n.º 29
0
def newScene():

	cmds.polyPlane(n="floor", h=30, w=30, sx=1, sy=1)
	cmds.polyCylinder(n="src", h=5, r=0.2)
	cmds.move(0,2.5,0, 'src', a = True)
	cmds.duplicate("src", n="temp")
	cmds.duplicate("src", n="dest")
	cmds.move(-8,0,0, "src", r=True)
	cmds.move(8,0,0, "dest", r=True)
	assignNewMaterial('floorMaterial', [0.3, 0.2, 0], 'floor')
	assignNewMaterial('pegMaterial', [0,0,0], 'src')
	assignMaterial('pegMaterial', 'temp')
	assignMaterial('pegMaterial', 'dest')
Ejemplo n.º 30
0
def createPlanes():
    global LENGTH
    total = LENGTH
    pos = 0
    input_file.close()
    while total > 1000:
        waves = cmds.polyPlane(w=10, h=1, sx=1000, sy=7)
        cmds.move(10 * pos, x=True)
        pos += 1
        total -= 1000

    waves = cmds.polyPlane(w=10, h=1, sx=total, sy=7)
    cmds.move(10 * pos, x=True)
Ejemplo n.º 31
0
def construct_surface():
    status = True 
    global sizeX, sizeY, Height
    widthPlaneX = mc.floatSliderGrp(widthX,q=True,value = True)
    widthPlaneZ = mc.floatSliderGrp(widthZ,q=True,value = True)    
    if status == True:
        mc.polyPlane(sx=widthPlaneX, sy=widthPlaneZ)
        
    mc.scale(scaleX,0.0,scaleZ)
    mc.rename("pPlane1", "Landscape_0")
    #Freeze scale transformation
    mc.makeIdentity(s=True, a=True)
    return sizeX, sizeY
Ejemplo n.º 32
0
def forward ( turtle, _length):        
    newPosition = [ turtle.position[0] + (turtle.heading[0]* _length)  , turtle.position[1] + (turtle.heading[1] * _length), turtle.position[2] + (turtle.heading[2] * _length)]   
    if turtle.pen == True:
        cmds.curve(p = [turtle.position, newPosition ], d = 1, name = 'curve' + str(turtle.curveNum) ) 
        if turtle.fill[0] == 'poly':
            cmds.polyPlane (name = 'plane' + str(turtle.curveNum), w = turtle.size, h = turtle.size, sx = 1, sy = 1)           
            cmds.setAttr ( 'plane' + str(turtle.curveNum) + '.translate', turtle.position[0], turtle.position[1], turtle.position[2], type = 'double3' )   
            cmds.polyExtrudeFacet ( 'plane' + str(turtle.curveNum) , inc = 'curve'+ str(turtle.curveNum) )
            cmds.setAttr ( 'polyExtrudeFace'+ str(turtle.curveNum + 1) + '.taper' , turtle.sf)    #taper branch
        elif turtle.fill[0] == 'nurbs':
            cmds.circle( center = turtle.position, radius = turtle.size, normal = turtle.heading, sections = 1,  name = 'circle' + str(turtle.curveNum) )
            cmds.extrude ( 'circle' + str(turtle.curveNum), 'curve' + str(turtle.curveNum), et = 2, upn = True, scale = turtle.sf, name = 'plane' + str(turtle.curveNum))         
    turtle.curveNum += 1            #increment curve num        
    turtle.position = newPosition   #update position 
def createHoneyPiece(n):
    planeName = 'plane'+str(n)
    cmds.polyPlane(w=20, h=20, sx=12, sy=12, n=planeName)
    edgeNum = 26
    modVal = 1;
    edgeArray = []
    for i in range(52):
        edgeArray.append(planeName+'.e['+str(edgeNum)+']');
        edgeNum += 2
        if(edgeNum == 51):
            edgeNum = 101
        if(edgeNum==50):
            edgeNum = 49
        if(edgeNum == 126):
            edgeNum = 176
        if(edgeNum==125):
            edgeNum = 124
        if(edgeNum==201):
            edgeNum = 251
        if(edgeNum==200):
            edgeNum = 199
        if(edgeNum==275):
            edgeNum = 274
    cmds.polyBevel(edgeArray, offset=1,offsetAsFraction=1,autoFit=1,segments=1,worldSpace=1,uvAssignment=0,fillNgons=1,mergeVertices=1,mergeVertexTolerance=0.0001,smoothingAngle=30,miteringAngle=180,angleTolerance=180,ch=1)
    cmds.select( clear=True)
    del edgeArray[:]
    for i in range(532, 620):
        cmds.select(planeName+'.e['+str(i)+']', toggle=True);
    size = 36;
    edgeNum = 31
    counter = 0
    for i in range(size):
        cmds.select(planeName+'.e['+str(edgeNum)+']', toggle=True);
        edgeNum += 2
        counter += 1
        if(counter == 12):
            counter = 0
            edgeNum += 7;
    cmds.delete();
    for i in range(12):
         cmds.select(planeName+'.f['+str(i)+']', toggle=True);
    for i in range(96, 108):
         cmds.select(planeName+'.f['+str(i)+']', toggle=True);
    for i in range(1,8):
        cmds.select(planeName+'.f['+str(i*12)+']', toggle=True);
    for i in range(1,8):
        cmds.select(planeName+'.f['+str(i*12+11)+']', toggle=True);
    cmds.delete();
    cmds.select(planeName);
Ejemplo n.º 34
0
def block(_name, _area, _amount, _paveSize, _paveList, _roadWidth, _gap,
          _suburbs):

    cmds.polyPlane(name=_name, sx=1, sy=1)
    cmds.polyColorPerVertex(_name, r=0, g=1, b=0)
    cmds.xform(_name, piv=[-.5, 0, -.5])
    cmds.move(0.5, 0, 0.5, _name, r=True)
    cmds.scale(
        (_amount * (_area[0] + _gap)) + (2 * (_roadWidth + _paveSize)), 1,
        (_amount * (_area[0] + _gap)) + (2 * (_roadWidth + _paveSize)), _name)
    cmds.xform(_name,
               piv=[((_area[0] + 4.5) * _amount) / 2, 0,
                    ((_area[1] + 4.5) * _amount) / 2])
    if _suburbs == False:
        paving(_name, _area, _amount, _paveSize, _roadWidth, _paveList, _gap)
Ejemplo n.º 35
0
    def modify_terrain(self, deformation_method):
        """
        This function deletes previous terrain and creates another one with same parameters.
            Parameters:
                deformation_method (int): The desired method to deform the grid.
        """
        cmds.delete(self.gridObject)

        cmds.polyPlane(name=self.gridObject,
                       width=self.gridDimensions,
                       height=self.gridDimensions,
                       sx=self.gridSubdivisions,
                       sy=self.gridSubdivisions)

        self.deform_terrain(deformation_method)
Ejemplo n.º 36
0
def make_cubes(place_string, animation, height_scale):
    #places=get_state_data(place_string)
    places=get_country_data(place_string)
    for location in places:
        #NEED GROUPING FUNCTION
        new_plane = cmds.polyPlane(n= location[3], height=0.01, width =0.01, axis=[0,0,1], sh= 1, sw=1, ch=False)
        #print (new_plane)
        cmds.polyMoveVertex(new_plane[0]+".vtx[0:3]", tz=57.2965, ch=False)
        cmds.setAttr(new_plane[0]+".rx",-1*float(location[1]))
        cmds.setAttr(new_plane[0]+".ry", float(location[2]))
        cmds.polyExtrudeFacet(new_plane[0]+".f[0]", kft=True, ltz=float(location[-1][-1])*height_scale)
        connections = cmds.listConnections(new_plane[0]+"Shape")
        extrude_node = connections[1]

        #print (location[3])

        #GET DAILY CASE DATA FROM LIST
        case_numbers = location[5]
        timer = 0

        if animation:
            #ITERATE OVER DAILY NUMBERS AND SET EXTRUSION KEYFRAMES
            for number in case_numbers:
                #CHECK TO SEE IF NEW KEYFRAME NEEDED
                index = timer
                if index == 0:
                    cmds.setKeyframe(extrude_node+".ltz", time = 0, value = (float(case_numbers[(timer)])*height_scale))
                    timer = timer+1
                else:
                    if case_numbers[index]==case_numbers[index-1]:
                        #NO KEYFRAME NEEDED
                        timer = timer+1
                    else:
                        cmds.setKeyframe(extrude_node+".ltz", time = (timer+1)*6, value = (float(case_numbers[(timer)])*height_scale))
                        timer = timer+1
    def testStaticVisibility(self):
        poly1  = MayaCmds.polyPlane(sx=2, sy=2, w=1, h=1, ch=0)[0]
        group1 = MayaCmds.group()
        group2 = MayaCmds.createNode("transform")
        MayaCmds.select(group1, group2)
        group3 = MayaCmds.group()

        group4 = (MayaCmds.duplicate(group1, rr=1))[0]
        group5 = MayaCmds.group()

        MayaCmds.select(group3, group5)
        root = MayaCmds.group(name='root')

        MayaCmds.setAttr(group1 + '.visibility', 0)
        MayaCmds.setAttr(group2 + '.visibility', 0)
        MayaCmds.setAttr(group5 + '.visibility', 0)

        self.__files.append(util.expandFileName('staticVisibilityTest.abc'))
        MayaCmds.AbcExport(j='-wv -root %s -file %s' % (root, self.__files[-1]))

        MayaCmds.AbcImport(self.__files[-1], m='open')
        self.failIf(MayaCmds.getAttr(group1+'.visibility'))
        self.failIf(MayaCmds.getAttr(group2+'.visibility'))
        self.failIf(MayaCmds.getAttr(group5+'.visibility'))

        self.failUnless(MayaCmds.getAttr(group1+'|'+poly1+'.visibility'))
        self.failUnless(MayaCmds.getAttr(group4+'|'+poly1+'.visibility'))
        self.failUnless(MayaCmds.getAttr(group3+'.visibility'))
        self.failUnless(MayaCmds.getAttr(group4+'.visibility'))
        self.failUnless(MayaCmds.getAttr(root+'.visibility'))
Ejemplo n.º 38
0
def bestFitPlaneCreate(ptList,upVector=(0,1,0)):
	'''
	Create a best fit plane from a specified set of points.
	@param ptList: List of points to calculate best fit plane from.
	@type ptList: list
	@param upVector: Up vector for orientation reference.
	@type upVector: tuple or list
	'''
	
	# Calculate Plane Center and Normal
	p = glTools.tools.center.centerPoint_average(ptList)
	pt = OpenMaya.MVector(p[0],p[1],p[2])
	n = bestFitPlaneNormal(ptList)
	norm = OpenMaya.MVector(n[0],n[1],n[2])
	
	# Build rotation matrix
	mat = glTools.utils.matrix.buildRotation(norm,upVector,'y','x')
	rot = glTools.utils.matrix.getRotation(mat,'xyz')
	
	# Create Plane
	plane = mc.polyPlane(w=1,h=1,sx=1,sy=1,ax=[0,1,0],cuv=2,ch=False)[0]
	
	# Position Plane
	mc.rotate(rot[0],rot[1],rot[2],plane,os=True,a=True)
	mc.move(pt[0],pt[1],pt[2],plane,ws=True,a=True)
	
	# Return result
	return plane
Ejemplo n.º 39
0
def createBuilding(position, blockSize, buildingSize):
    building = cmd.polyCube(sx=1, sy=1, sz=1, w=buildingSize[0], h=buildingSize[1], d=buildingSize[2])
    buildingBlock = cmd.polyPlane(sx=1, sy=1, w=blockSize[0], h=blockSize[1])
    #lamp = cmd.pointLight(decayRate=2, intensity=50, useRayTraceShadows=True)
    #cmd.move(6,2,0, lamp)
    
    buildingRig = cmd.circle(center=[0,0,0], normal=[0,1,0], radius=10, n='buildingRig')
    cmd.addAttr(buildingRig, longName='buildingHeight', shortName='bh', defaultValue=1, minValue=1, maxValue=20, attributeType='long')
    
    bbox = cmd.exactWorldBoundingBox(building)
    cmd.xform(building, piv=[0, bbox[1], 0], ws=True)
    cmd.move(0, -bbox[1], 0, building)
    cmd.makeIdentity(building, apply=True, t=True, r=True, s=True)
    cmd.delete(building, constructionHistory=True)
    cmd.delete(buildingBlock, constructionHistory=True)
    cmd.delete(buildingRig, constructionHistory=True)
    
    buildingGroup = cmd.group(em=True, name='building_1')
    buildingRig_group = cmd.parent(buildingRig[0], buildingGroup)
    cmd.parent(building[0], buildingGroup)
    cmd.parent(buildingBlock[0], buildingGroup)
    #cmd.parent(lamp, buildingGroup)
    
    cmd.connectAttr(buildingRig_group[0]+'.bh', building[0]+'.scaleY')
    x = position[0] * blockSize[0]
    y = position[1] * blockSize[1]
    cmd.move(x, 0, y, buildingGroup)
    height = math.floor(r.uniform(1, 10))
    cmd.setAttr(buildingRig_group[0]+'.bh', height)
    cmd.setAttr(buildingRig_group[0]+'.visibility', False)    
    return buildingGroup
Ejemplo n.º 40
0
 def visualize_plane(self, name='visualiserPlane', position=None):
     """
     visualizes this plane
     :param name: <str>
     :param position: <tuple>
     :return:
     """
     visualizer_plane = cmds.polyPlane(name=name, width=self.magnitude, height=self.magnitude,
                                       axis=[self.normal().x, self.normal().y, self.normal().z],
                                       constructionHistory=False)
     # cmds.toggle(visualizer_plane, state=True, template=True)
     if not position:
         if self.normal().x != 0:
             # automatically compute a position where we find x for if y and z were 0
             position = Vector(-self.distance() / self.normal().x, 0, 0)
         elif self.normal().y != 0:
             # automatically compute a position where we find y for if x and z were 0
             position = Vector(0, -self.distance() / self.normal().y, 0)
         elif self.normal().z != 0:
             # automatically compute a position where we find z for if x and y were 0
             position = Vector(0, 0, -self.distance() / self.normal().z)
         else:
             cmds.warning("Invalid plane normal, all components are 0")
     transform_utils.match_position_transform(visualizer_plane, position.position)
     return visualizer_plane
    def testSubD(self):
        trans = MayaCmds.polyPlane(n='plane', sx=1, sy=1, ch=False)[0]
        shape = MayaCmds.pickWalk(d='down')[0]
        MayaCmds.addAttr(attributeType='bool', defaultValue=1, keyable=True,
            longName='SubDivisionMesh')
        MayaCmds.select(trans+'.vtx[0:3]', r=True)
        MayaCmds.move(0, 1, 0, r=True)
        MayaCmds.currentTime(1, update=True)
        MayaCmds.setKeyframe()
        MayaCmds.currentTime(2, update=True)
        MayaCmds.move(0, 5, 0, r=True)
        MayaCmds.setKeyframe()

        self.__files.append(util.expandFileName('testSubDInterpolation.abc'))
        MayaCmds.AbcExport(j='-fr 1 2 -root %s -file %s' % (trans, self.__files[-1]))
        MayaCmds.AbcImport(self.__files[-1], mode='open')

        MayaCmds.currentTime(1.004, update=True)
        ty = MayaCmds.getAttr(shape+'.vt[0]')[0][1]
        self.failUnlessAlmostEqual(1.02, ty)

        setTime = MayaCmds.currentTime(1.422, update=True)
        alpha = (setTime - 1) / (2 - 1)
        ty = MayaCmds.getAttr(shape+'.vt[0]')[0][1]
        self.failUnlessAlmostEqual(ty, (1-alpha)*1.0+alpha*6.0, 3)
Ejemplo n.º 42
0
def create_body(length=2, width=1):
    # Create a plane that represents the car body.
    # Return the transform node name.
    body = cmds.polyPlane(w=length, h=width, name="body")
    arPolyNoise(body[0], 0.20)

    return body[0]
Ejemplo n.º 43
0
    def testStaticVisibility(self):
        poly1 = MayaCmds.polyPlane(sx=2, sy=2, w=1, h=1, ch=0)[0]
        group1 = MayaCmds.group()
        group2 = MayaCmds.createNode("transform")
        MayaCmds.select(group1, group2)
        group3 = MayaCmds.group()

        group4 = (MayaCmds.duplicate(group1, rr=1))[0]
        group5 = MayaCmds.group()

        MayaCmds.select(group3, group5)
        root = MayaCmds.group(name='root')

        MayaCmds.setAttr(group1 + '.visibility', 0)
        MayaCmds.setAttr(group2 + '.visibility', 0)
        MayaCmds.setAttr(group5 + '.visibility', 0)

        self.__files.append(util.expandFileName('staticVisibilityTest.abc'))
        MayaCmds.AbcExport(j='-wv -root %s -file %s' %
                           (root, self.__files[-1]))

        MayaCmds.AbcImport(self.__files[-1], m='open')
        self.failIf(MayaCmds.getAttr(group1 + '.visibility'))
        self.failIf(MayaCmds.getAttr(group2 + '.visibility'))
        self.failIf(MayaCmds.getAttr(group5 + '.visibility'))

        self.failUnless(MayaCmds.getAttr(group1 + '|' + poly1 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group4 + '|' + poly1 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group3 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group4 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(root + '.visibility'))
Ejemplo n.º 44
0
def createDebugVisualizerPlane(plane, position = None, name = None):
    if(plane is None):
        return None

    #TODO: for now this creates a plane that ends up affecting the scene history, so undo/redo actions end up recreating the plane
    #figure out how to draw this plane without this happening
    debugPlane = cmds.polyPlane(name = name if name else "debugPlane", width=100, height=100, axis=[plane.normal().x, plane.normal().y, plane.normal().z], constructionHistory=False)
    cmds.toggle(debugPlane, state=True, template=True)  #make plane unselectable and undeletable so users can't accidentally delete it and break things

    createPos = om.MVector()

    if(position is None):
        if(plane.normal().x != 0):
            #automatically compute a position where we find x for if y and z were 0
            createPos = om.MVector(-plane.distance() / plane.normal().x, 0, 0)
        elif(plane.normal().y != 0):
            #automatically compute a position where we find y for if x and z were 0
            createPos = om.MVector(0, -plane.distance() / plane.normal().y, 0)
        elif(plane.normal().z != 0):
            #automatically compute a position where we find z for if x and y were 0
            createPos = om.MVector(0, 0, -plane.distance() / plane.normal().z)
        else:
            print("Invalid plane normal, all components are 0")
    else:
        createPos = position  

    cmds.xform(debugPlane, absolute=True, worldSpace=True, translation=[createPos.x, createPos.y, createPos.z])

    return debugPlane
Ejemplo n.º 45
0
def create_table():
    # Create a table mesh that collides with nCloth
    cmds.polyPlane(name = "table", w = TABLE_SIZE, h = TABLE_SIZE)
    cmds.select(clear = True)
    # table material settings
    mel.eval('select -r table;')
    mel.eval('shadingNode -asShader lambert;')
    mel.eval('rename lambert2 "table_mat";')
    mel.eval('sets -renderable true -noSurfaceShader true' + \
        '-empty -name -table_matSG;')
    mel.eval('connectAttr -f table_mat.outColor table_matSG.surfaceShader;')
    mel.eval('setAttr "table_mat.color" -type double3 0 0 0;')
    mel.eval('setAttr "table_mat.ambientColor" -type double3 0 0 0;')
    mel.eval('select -r table ; sets -e -forceElement table_matSG;')
    cmds.select("table")
    mel.eval("makeCollideNCloth")
Ejemplo n.º 46
0
def ShapeInverterCmdold(base=None, corrective=None, name=None):
    mc.undoInfo(openChunk=True)
    if not base or not corrective:
        sel = mc.ls(sl=True)
        base, corrective = sel
    shapes = mc.listRelatives(base, children=True, shapes=True)
    for s in shapes:
        if mc.getAttr("%s.intermediateObject" % s) and mc.listConnections("%s.worldMesh" % s, source=False):
            origMesh = s
            break
    deformed = mc.polyPlane(ch=False)[0]
    mc.connectAttr("%s.worldMesh" % origMesh, "%s.inMesh" % deformed)
    mc.setAttr("%s.intermediateObject" % origMesh, 0)
    mc.delete(deformed, ch=True)
    mc.setAttr("%s.intermediateObject" % origMesh, 1)
    if not name:
        name = "%s_inverted#" % corrective
    invertedShape = duplicateMesh(base, name=name)
    deformer = mc.deformer(invertedShape, type="ShapeInverter")[0]
    mc.ShapeInverterCmd(baseMesh=base, invertedShape=invertedShape, ShapeInverterdeformer=deformer, origMesh=deformed)
    # correctiveShape = duplicateMesh(base,name=corrective+"_corrective#")
    # mc.connectAttr('%s.outMesh' % getShape(correctiveShape), '%s.correctiveMesh' % deformer)
    # transferMesh(corrective,[correctiveShape])
    mc.connectAttr("%s.outMesh" % getShape(corrective), "%s.correctiveMesh" % deformer)
    mc.setAttr("%s.activate" % deformer, True)
    mc.delete(deformed)
    bdingBx = mc.polyEvaluate(corrective, boundingBox=True)
    xDifVal = bdingBx[0][1] - bdingBx[0][0]
    # mc.move(xDifVal*1.10,correctiveShape,r=True,moveX=True)
    mc.move(xDifVal * 2.20, invertedShape, r=True, moveX=True)
    mc.undoInfo(closeChunk=True)
    return invertedShape  # ,correctiveShape
Ejemplo n.º 47
0
def bestFitPlane(ptList,upVector=(0,1,0)):
	'''
	'''
	# Initialize plane normal
	norm = OpenMaya.MVector()
	pt = OpenMaya.MVector()
	
	# Calculate plane
	for i in range(len(ptList)):
		
		prev = OpenMaya.MVector(ptList[i-1][0],ptList[i-1][1],ptList[i-1][2])
		curr = OpenMaya.MVector(ptList[i][0],ptList[i][1],ptList[i][2])
		norm += OpenMaya.MVector((prev.z + curr.z) * (prev.y - curr.y), (prev.x + curr.x) * (prev.z - curr.z), (prev.y + curr.y) *  (prev.x - curr.x))
		pt += curr
	
	# Normalize result
	norm.normalize()
	pt /= len(ptList)
	
	# Build rotation matrix
	mat = glTools.utils.matrix.buildRotation(norm,upVector,'y','x')
	rot = glTools.utils.matrix.getRotation(mat,'xyz')
	
	# Create Plane
	plane = mc.polyPlane(w=1,h=1,sx=1,sy=1,ax=[0,1,0],cuv=2,ch=False)[0]
	
	# Position Plane
	mc.rotate(rot[0],rot[1],rot[2],plane,os=True,a=True)
	mc.move(pt[0],pt[1],pt[2],plane,ws=True,a=True)
	
	# Return result
	return plane
Ejemplo n.º 48
0
    def createPlane(*args):
        import math
        path = cmds.textField(Window_global.txf_imagePath, q=1, tx=1)
        width = cmds.floatField(Window_global.floatf_planeWidth, q=1, v=1)
        height = cmds.floatField(Window_global.floatf_planeHeight, q=1, v=1)
        plane = cmds.polyPlane(w=height, h=width, cuv=1, sw=1, sh=1)

        radioSelObject = cmds.radioCollection(Window_global.radio_dir,
                                              q=1,
                                              sl=1).split('|')[-1]
        items = cmds.radioCollection(Window_global.radio_dir, q=1, cia=1)
        items = map(lambda x: x.split("|")[-1], items)
        selIndex = items.index(radioSelObject)

        directions = [(90, 90, 0), (0, 0, 0), (90, 0, 0), (90, -90, 0),
                      (180, 0, 0), (90, 180, 0)]

        rotValue = directions[selIndex]
        cmds.rotate(rotValue[0], rotValue[1], rotValue[2], plane)

        lambert = cmds.shadingNode('lambert', asShader=1)
        shadingGrp = cmds.sets(name="%sSG" % lambert,
                               renderable=1,
                               noSurfaceShader=1,
                               empty=1)
        cmds.connectAttr(lambert + ".outColor",
                         shadingGrp + ".surfaceShader",
                         f=1)
        cmds.sets(plane, e=1, forceElement=shadingGrp)
        fileNode = cmds.shadingNode('file', asTexture=1)
        cmds.connectAttr(fileNode + ".outColor", lambert + ".color", f=1)
        cmds.setAttr(fileNode + ".fileTextureName", path, type="string")
    def testAnimVisibility(self):
        poly1  = MayaCmds.polyPlane( sx=2, sy=2, w=1, h=1, ch=0)[0]
        group1 = MayaCmds.group()
        group2 = MayaCmds.createNode("transform")
        MayaCmds.select(group1, group2)
        group3 = MayaCmds.group()

        group4 = (MayaCmds.duplicate(group1, rr=1))[0]
        group5 = MayaCmds.group()

        MayaCmds.select(group3, group5)
        root = MayaCmds.group(name='root')

        MayaCmds.setKeyframe(group1 + '.visibility', v=0, t=[1, 4])
        MayaCmds.setKeyframe(group2 + '.visibility', v=0, t=[1, 4])
        MayaCmds.setKeyframe(group5 + '.visibility', v=0, t=[1, 4])

        MayaCmds.setKeyframe(group1 + '.visibility', v=1, t=2)
        MayaCmds.setKeyframe(group2 + '.visibility', v=1, t=2)
        MayaCmds.setKeyframe(group5 + '.visibility', v=1, t=2)

        self.__files.append(util.expandFileName('animVisibilityTest.abc'))
        MayaCmds.AbcExport(j='-wv -fr 1 4 -root %s -file %s' %
            (root, self.__files[-1]))

        MayaCmds.AbcImport(self.__files[-1], mode='open')

        MayaCmds.currentTime(1, update = True)
        self.failIf(MayaCmds.getAttr(group1 + '.visibility'))
        self.failIf(MayaCmds.getAttr(group2 + '.visibility'))
        self.failIf(MayaCmds.getAttr(group5 + '.visibility'))

        self.failUnless(MayaCmds.getAttr(group1 + '|' + poly1 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group4 + '|' + poly1 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group3 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group4 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(root+'.visibility'))

        MayaCmds.currentTime(2, update = True)
        self.failUnless(MayaCmds.getAttr(group1 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group2 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group5 + '.visibility'))

        self.failUnless(MayaCmds.getAttr(group1 + '|' + poly1 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group4 + '|' + poly1 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group3 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group4 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(root + '.visibility'))

        MayaCmds.currentTime(4, update = True )
        self.failIf(MayaCmds.getAttr(group1 + '.visibility'))
        self.failIf(MayaCmds.getAttr(group2 + '.visibility'))
        self.failIf(MayaCmds.getAttr(group5 + '.visibility'))

        self.failUnless(MayaCmds.getAttr(group1 + '|' + poly1 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group4 + '|' + poly1 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group3 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(group4 + '.visibility'))
        self.failUnless(MayaCmds.getAttr(root+'.visibility'))
 def CreateShadowPlane():
     #Get the bounding box of the group
     RenderLayerManagerClass.ShowModel(Visibility = True)
     bbx = cmds.xform(cmds.getAttr("CMSettings.ModelName"), bb = True, q = True)
     RenderLayerManagerClass.ShowModel(Visibility = False)
     
     #Get the x-z diagonal
     diagonal = math.sqrt((bbx[3] - bbx[0])*(bbx[3] - bbx[0]) + (bbx[5] - bbx [2])*(bbx[5] - bbx [2])) 
     diagonal = math.sqrt((bbx[4]-bbx[1])*(bbx[4]-bbx[1]) + diagonal*diagonal)
     
     #Check to see if the plane already exists
     if not cmds.objExists("ShadowPlane"):
         #create the shadow plane
         cmds.polyPlane( name = "ShadowPlane", width = 1.5*diagonal, height = 1.5*diagonal, subdivisionsX = 1, subdivisionsY = 1 )
         
     cmds.editRenderLayerGlobals(currentRenderLayer = "defaultRenderLayer")
     cmds.sets( "ShadowPlane", forceElement = "ShadowSG", e = True)
Ejemplo n.º 51
0
def createPatchMesh(vertices, normals):
  width = len(vertices)
  height = len(vertices[0])
  
  cmds.polyPlane(n="tp", sx=width-1, sy=height-1, ax=[0, 0, 1])
  
  for j in range(height):
    for i in range(width):
      cmds.select("tp.vtx[%s]" % (j*width+i), r=True)
      cmds.move(vertices[i][j][0], vertices[i][j][1], vertices[i][j][2], a=True)
      cmds.polyNormalPerVertex(xyz=normals[i][j].tolist())

  normalZ = cmds.polyInfo("tp.f[0]", fn=True)[0].split()[-1]
  if normalZ[0]=="-":
    cmds.polyNormal("tp", normalMode=0, userNormalMode=0, ch=1);
  
  cmds.rename("tp", "patch1")
  cmds.select(cl=True)
def createParticleSystem_2():
    # Creates a point emitter, with a collide plane and some PP attributes

    cmds.playbackOptions(maxTime=180)

    emitter = cmds.emitter(dx=1, dy=0, dz=0, sp=0.1, pos=(0, 5, 0),rate=20)[0]

    # nParticle creation depends on an optionVar value, make sure we use the default one
    cmds.optionVar( sv=("NParticleStyle","Points") )

    particleSystem, particleSystemShape = cmds.nParticle(n="nParticle_test_2")
    cmds.setAttr('%s.lfm' % particleSystemShape, 2.0) # random range
    cmds.setAttr('%s.lifespan' % particleSystemShape, 3)
    cmds.setAttr('%s.lifespanRandom' % particleSystemShape, 4)
    cmds.setAttr('%s.friction' % particleSystemShape, 0.01)
    cmds.setAttr('%s.bounce' % particleSystemShape, 0.5)
    cmds.setAttr('%s.rotationFriction' % particleSystemShape, 0.98)
    cmds.setAttr('%s.pointMass' % particleSystemShape, 4)
    cmds.setAttr('%s.computeRotation' % particleSystemShape, True)
    cmds.setAttr('%s.particleRenderType' % particleSystemShape, 7) # Blobby, to see radius
    cmds.setAttr('%s.selfCollide' % particleSystemShape, True)
    cmds.connectDynamic( particleSystemShape, em=emitter)


    # add Custom Attributes
    # rgb
    if not cmds.objExists( "%s.rgbPP" % particleSystemShape):
        cmds.addAttr( particleSystemShape ,ln="rgbPP",dt="vectorArray")
    else:
        # Disconnect possible thing in rgbPP
        input = cmds.connectionInfo("%s.rgbPP" % particleSystemShape,sourceFromDestination=True)
        if input:
            cmds.disconnectAttr(input,"%s.rgbPP" % particleSystemShape)

    cmds.dynExpression( particleSystem, s="\nfloat $r = rand(1.0);float $g = rand(1.0);float $b = rand(1.0);\n%s.rgbPP = <<$r,$g,$b>>;" % particleSystemShape, c=True)

    # radius
    if not cmds.objExists( "%s.radiusPP" % particleSystemShape):
        cmds.addAttr( particleSystemShape, ln="radiusPP",dt="doubleArray")
    cmds.dynExpression( particleSystem, s="seed(%s.id);\n%s.radiusPP = .2 + time * .2 * rand(.2,1.5)" % (particleSystemShape,particleSystemShape), runtimeAfterDynamics=True)

    # rotatePP (enabled by "compute rotation", the attribute would be created by attribut editor's first constrcution in a gui maya)
    if not cmds.objExists( "%s.rotationPP" % particleSystemShape):
        cmds.addAttr( particleSystemShape, ln="rotationPP",dt="vectorArray")

    # add collision plane
    plane = cmds.polyPlane( w=30,h=30,sx=10,sy=10,ax=[0, 1, .5], cuv=2)
    cmds.select(plane[0])
    maya.mel.eval("makePassiveCollider")
    cmds.select(clear=True)
    cmds.setAttr( "nRigidShape1.friction", 0.25)
    cmds.setAttr( "nRigidShape1.stickiness", 0.0)

    return particleSystem, particleSystemShape
 def buildRoof(self):
     cmds.select(clear = True)
     if(self.roofType == 1):
         cmds.polyPlane(w=self.dim[0],h=self.dim[2], sx=1, sy=1, n = 'roof' + str(self.idx))
         cmds.move(self.pos[0], self.dim[1] + 0.0*self.roofHeight, self.pos[2], r=1)
         cmds.select('roof'+str(self.idx)+'.f[1]')
         cmds.polyExtrudeFacet(s=[0.9,1.0,0.9], t=[0.0, self.roofHeight, 0.0])
     else:
         cmds.polyCube(w=self.dim[0], h=self.roofHeight, d=self.dim[2], n = 'roof' + str(self.idx))
         cmds.move(self.pos[0], self.dim[1] + 0.5*self.roofHeight, self.pos[2], r=1)
         if(self.dim[2] < self.dim[0] ):
             cmds.select('roof' + str(self.idx) + '.vtx[2:3]')
             cmds.move(0, 0, -0.5 * self.dim[2], r=1)
             cmds.select('roof' + str(self.idx) + '.vtx[4:5]')
             cmds.move(0, 0, 0.5 * self.dim[2], r=1)
         else:
             cmds.select(['roof' + str(self.idx) + '.vtx[2]', 'roof' + str(self.idx) + '.vtx[4]'])
             cmds.move(0.5 * self.dim[0], 0, 0, r=1)
             cmds.select(['roof' + str(self.idx) + '.vtx[3]', 'roof' + str(self.idx) + '.vtx[5]'])
             cmds.move(-0.5 * self.dim[0], 0, 0, r=1)
Ejemplo n.º 54
0
	def createPolyPlane(self, name, w, h, size) : 
		# 10000 px = 1 unit
		w = (float(w)/1000)*float(size)
		h = (float(h)/1000)*float(size)

		name = '%s_ply' % name.split('.')[0]

		poly = mc.polyPlane(w = 2, h = 2, sx = 4, sy = 4, ax = [0, 0, 0], cuv = 2, ch = 1, n = name)
		mc.xform(poly[0], ws = True, s = (w, h, 1.0))
		mc.makeIdentity(poly[0], apply=True, t = 1, r = 1, s = 1, n = 0)

		return poly
Ejemplo n.º 55
0
def panelOnSelection():
    sel = cmds.ls(sl=1, fl=True)
    if len(sel) == 4:
        p = cmds.polyPlane(w=1, h=1, sx=1, sy=1, ax=(0, 1, 0), cuv=2, ch=1)[0]
        # vtx = cmds.polyEvaluate(p, v=1)
        j = 0
        for i in sel:
            pos = cmds.xform(i, q=True, ws=True, rp=True)
            cmds.xform(p + '.vtx[' + str(j) + ']', ws=True, t=pos)
            j = j + 1
    else:
        message('Select 4 objects', maya=True)
Ejemplo n.º 56
0
def prepare():
    get_ui_values()
    selection = cmds.ls(sl=True)
    cmds.polyPlane(name = "REFPLANE", axis = [0,0,1], width = 1, height = float(resolution_y)/resolution_x, subdivisionsX=1, subdivisionsY=1)
    cmds.move(0.5,float(resolution_y)/resolution_x/2,0)
    ###CREATE ATTRIBUTES
    for obj in selection:
        shape = cmds.listRelatives(obj, shapes=True)
        if (cmds.objectType(shape, isType='pointLight') or cmds.objectType(shape, isType='spotLight')) and cmds.getAttr(obj + '.visibility'):
            cmds.select(shape[0])            
            if not 'hqzLightStart' in cmds.listAttr():
                cmds.addAttr(attributeType = 'float', niceName='HQZ Light Start', longName='hqzLightStart', shortName='hqzls', defaultValue=0, keyable=True)
            if not 'hqzLightEnd' in cmds.listAttr():
                cmds.addAttr(attributeType = 'float', niceName='HQZ Light End', longName='hqzLightEnd', shortName='hqzle', defaultValue=0, keyable=True)
            if not 'hqzSpectralLight' in cmds.listAttr():
                cmds.addAttr(attributeType = 'bool', niceName='HQZ Spectral Light', longName='hqzSpectralLight', shortName='hqzsl', defaultValue=True, keyable=True)
            if not 'hqzSpectralStart' in cmds.listAttr():
                cmds.addAttr(attributeType = 'float', niceName='HQZ Spectral Start', longName='hqzSpectralStart', shortName='hqzss', defaultValue=400, minValue=400, maxValue=700, keyable=True)
            if not 'hqzSpectralEnd' in cmds.listAttr():
                cmds.addAttr(attributeType = 'float', niceName='HQZ Spectral End', longName='hqzSpectralEnd', shortName='hqzse', defaultValue=700, minValue=400, maxValue=700, keyable=True)

        if cmds.objectType(shape, isType='spotLight') and cmds.getAttr(obj + '.visibility'):
            try:
                cmds.setAttr(obj+'.rotateX', 0)
                cmds.setAttr(obj+'.rotateY', -90)
                cmds.setAttr(obj+'.rotateY', lock = True)
                cmds.setAttr(obj+'.rotateX', lock = True)
            except:
                pass
            
        if cmds.objectType(shape, isType='mesh') and (cmds.getAttr(obj + '.v')):
            cmds.select(shape[0])
            if not 'hqzMaterial' in cmds.listAttr():
                cmds.addAttr(attributeType = 'byte', niceName='HQZ Material', longName='hqzMaterial', shortName='hqzmat', defaultValue = 0, keyable = True)
            cmds.polySoftEdge(obj, a = 180, ch = 0)
    
    try:
        cmds.select(selection, replace=True)
    except:
        pass
Ejemplo n.º 57
0
 def _polyPlaneAtSelection(self):
     try:
         sel = cmds.ls(sl=True, fl=True, r=True)
         nodeType = cmds.nodeType(sel[0])
         if nodeType == "transform":
             pivot = cmds.xform(sel[0], q=True, ws=True, rp=True)
             cmds.polyPlane()
             plane = cmds.ls(sl=True, r=True)[0]
             cmds.setAttr(plane + ".translate", *pivot)
             cmds.CenterPivot()
         elif nodeType == "mesh":
             sel = cmds.ls(sl=True, fl=True, r=True)
             verts = [cmds.xform(i, q=True, ws=True, t=True) for i in sel]
             xs = [i[0] for i in verts]
             ys = [i[1] for i in verts]
             zs = [i[2] for i in verts]
             pos = [sum(xs) / len(sel),
                    sum(ys) / len(sel),
                    sum(zs) / len(sel)]
             cmds.polyPlane()
             plane = cmds.ls(sl=True, r=True)[0]
             cmds.setAttr(plane + ".translate", *pos)
             cmds.CenterPivot
     except IndexError:
         cmds.polyPlane()
    def buildScene(self):
        MayaCmds.file(new=True, force=True)

        MayaCmds.namespace(addNamespace='foo')
        MayaCmds.namespace(addNamespace='bar')
        MayaCmds.createNode('transform', name='foo:a')
        MayaCmds.createNode('transform', name='bar:a')
        MayaCmds.createNode('transform', name='a')
        MayaCmds.polyPlane(sx=1, sy=1, w=1, h=1, ch=0, n='foo:b')
        MayaCmds.polyPlane(sx=1, sy=1, w=1, h=1, ch=0, n='bar:b')
        MayaCmds.polyPlane(sx=1, sy=1, w=1, h=1, ch=0, n='b')
        MayaCmds.parent('foo:b', 'foo:a')
        MayaCmds.parent('bar:b', 'bar:a')
        MayaCmds.parent('b', 'a')

        MayaCmds.select('foo:b.vtx[0:8]')
        MayaCmds.setKeyframe(t=[1, 4])
        MayaCmds.scale(0.1, 0.1, 0.1, r=True)
        MayaCmds.setKeyframe(t=2)

        MayaCmds.select('bar:b.vtx[0:8]')
        MayaCmds.setKeyframe(t=[1, 4])
        MayaCmds.scale(2, 2, 2, r=True)
        MayaCmds.setKeyframe(t=2)

        MayaCmds.select('b.vtx[0:8]')
        MayaCmds.setKeyframe(t=[1, 4])
        MayaCmds.scale(5, 5, 5, r=True)
        MayaCmds.setKeyframe(t=2)