Ejemplo n.º 1
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.º 2
0
def resetVtx(*args):
    selList = cmds.ls(sl = True)

    # progress window
    cmds.progressWindow(title = 'Reset Vertex', minValue = 0, maxValue = len(selList), progress = 0, status = 'Stand by', isInterruptable = True)

    for sel in selList:
        if cmds.progressWindow(q = True, isCancelled = True):
        	break

        cmds.progressWindow(e = True, progress = selList.index(sel), status = 'Working on \'%s\'' %(sel))

        if not cmds.listRelatives(sel, path = True, s = True, ni = True):
            continue
        else:
            # Reset vertex
            try:
                cmds.polyMoveVertex(sel, localTranslate = (0, 0, 0))
            except:
                pass

    cmds.progressWindow(e = True, progress = 0, status = 'Reset Vertex Work Done.')
    cmds.progressWindow(endProgress = True)

    cmds.select(selList, r = True)
Ejemplo n.º 3
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 applyNoise(object, vert, amount):
    noise_x = random.uniform(0, amount)
    noise_y = random.uniform(0, amount)
    noise_z = random.uniform(0, amount)
    cmds.polyMoveVertex(object + ".vtx[" + str(vert) + "]",
                        translateX=noise_x,
                        translateY=noise_y,
                        translateZ=noise_z)
    def repair(cls, instance):
        """Repair the meshes by 'baking' offsets into the input mesh"""

        invalid = cls.get_invalid(instance)

        # TODO: Find a better way to reset values whilst preserving offsets
        with pyblish_maya.maintained_selection():
            for mesh in invalid:
                cmds.polyMoveVertex(mesh, constructionHistory=False)
    def repair(self, instance):
        """Repair the meshes by 'baking' offsets into the input mesh"""
        meshes = cmds.ls(instance, type='mesh', dag=True, long=True)
        invalid = [mesh for mesh in meshes if self.is_invalid(mesh)]

        # TODO: Find a better way to reset values whilst preserving offsets
        with pyblish_maya.maintained_selection():
            for mesh in invalid:
                cmds.polyMoveVertex(mesh, constructionHistory=False)
Ejemplo n.º 7
0
    def testBlendShapesExport(self):
        # NOTE: (yliangsiew) Basic blendshape export test.
        om.MFileIO.newFile(True)
        parent = cmds.group(name="root", empty=True)
        base, _ = cmds.polyCube(name="base")
        cmds.parent(base, parent)
        target, _ = cmds.polyCube(name="blend")
        cmds.parent(target, parent)
        cmds.polyMoveVertex('{}.vtx[0:2]'.format(target), s=(1.0, 1.5, 1.0))

        cmds.blendShape(target, base, automatic=True)

        cmds.select(base, replace=True)
        temp_file = os.path.join(self.temp_dir, 'blendshape.usda')
        cmds.mayaUSDExport(f=temp_file, v=True, sl=True, ebs=True, skl="auto")

        stage = Usd.Stage.Open(temp_file)
        prim = stage.GetPrimAtPath("/root/base/blendShape")
        offsets = prim.GetAttribute("offsets").Get()

        for i, coords in enumerate(offsets):
            coords = list(coords)  # convert from GfVec3
            self.assertEqual(coords, [0, -0.25 if i < 2 else 0.25, 0])

        """
        Sample BlendShape prim:

        def BlendShape "blendShape"
        {
            uniform vector3f[] normalOffsets = [(0, 0, 0), (0, 0, 0), (0, 0, 0)]
            uniform vector3f[] offsets = [(0, -0.25, 0), (0, -0.25, 0), (0, 0.25, 0)]
            uniform int[] pointIndices = [0, 1, 2]
        }
        """

        # NOTE: (yliangsiew) Test simple inbetween setup.
        om.MFileIO.open(self.scene_path, None, True)
        cmds.select("basic_cube_2_inbetweens_no_anim|base", r=True)
        cmds.mayaUSDExport(f=temp_file, v=True, sl=True, ebs=True, skl="auto", skn="auto")
        stage = Usd.Stage.Open(temp_file)
        prim = stage.GetPrimAtPath("/basic_cube_2_inbetweens_no_anim/base/pCube2")
        blendShape = UsdSkel.BlendShape(prim)
        inbetweens = blendShape.GetInbetweens()
        self.assertEqual(len(inbetweens), 2)  # NOTE: (yliangsiew) This particular setup has two additional inbetweens.

        # NOTE: (yliangsiew) Test simple multiple targets setup.
        om.MFileIO.open(self.scene_path, None, True)
        cmds.select("basic_cube_4_blendshapes_no_anim|base", r=True)
        cmds.mayaUSDExport(f=temp_file, v=True, sl=True, ebs=True, skl="auto", skn="auto")
        stage = Usd.Stage.Open(temp_file)
        prim = stage.GetPrimAtPath("/basic_cube_4_blendshapes_no_anim/base")
        blendShapes = prim.GetChildren()
        for bs in blendShapes:
            self.assertEqual(bs.GetTypeName(), 'BlendShape')
Ejemplo n.º 8
0
def run():
    objs = cmds.ls(type='mesh')
    meshList = []
    for obj in objs:
        par = cmds.listRelatives(obj, p=True)[0]
        if par not in meshList:
            meshList.append(par)
    for mesh in meshList:
        cmds.polyMoveVertex('%s.vtx[*]' % mesh,
                            constructionHistory=1,
                            random=0)
    cmds.select(cl=True)
Ejemplo n.º 9
0
 def fixIt(self):
     mSel = OpenMaya.MSelectionList()
     for n, e in enumerate(self.errors):
         if cmds.objExists(e.longName):
             obj = e.longName
             mSel.add(obj)
             try:
                 cmds.polyMoveVertex(obj,
                                     lt=(0, 0, 0),
                                     nodeState=1,
                                     ch=False)
             except RuntimeError:
                 pass
Ejemplo n.º 10
0
def fixIt(plug, path):
    # fix most vertices
    cmds.polyMoveVertex(path, lt=(0, 0, 0), nodeState=1, ch=False)

    # Sometimes the above comand doesn't fix very small number such as 0.000.....1
    # So manually reset those numbers to 0
    dataHandle = plug.asMDataHandle()
    arrayDataHandle = OpenMaya.MArrayDataHandle(dataHandle)
    while not arrayDataHandle.isDone():
        outputHandle = arrayDataHandle.outputValue()
        outputHandle.set3Float(0.0, 0.0, 0.0)
        arrayDataHandle.next()
    plug.setMDataHandle(dataHandle)
    plug.destructHandle(dataHandle)
Ejemplo n.º 11
0
 def run(self):
     selected = mc.ls(sl=1)
     if not selected:
         self.fail_check(u"先手动选中模型大组")
         return
     selected = mc.ls(sl=1)[0]
     meshes = mc.listRelatives(selected, ad=1, type="mesh")
     for mesh in meshes:
         vtx_num = mc.polyEvaluate(mesh, vertex=1)
         if not vtx_num:
             continue
         vertexes = "%s.vtx[0:%s]" % (mesh, vtx_num - 1)
         mc.polyMoveVertex(vertexes, ld=(0, 0, 0))
         mc.select(clear=1)
     mc.select(selected, r=1)
     self.pass_check(u"所有的点已清零")
Ejemplo n.º 12
0
 def __init__(self, numberOfVertices=10):
     if not funnyPlane.plane:
         funnyPlane.plane = mc.polyPlane(sx=10, sy=10, w=10, h=10)[0]
     numVertices = mc.polyEvaluate(funnyPlane.plane, vertex=True)
     self.vertexList = []
     self.positions = []
     if numberOfVertices < numVertices:
         self.vertexList = random.sample(range(numVertices),
                                         numberOfVertices)
         for vertex in self.vertexList:
             position = mc.pointPosition(funnyPlane.plane + ".vtx[" +
                                         str(vertex) + "]")
             self.positions.append(position)
             mc.polyMoveVertex(funnyPlane.plane + ".vtx[" + str(vertex) +
                               "]",
                               translateY=2)
Ejemplo n.º 13
0
def randomizePlaneVerts(minElField, maxElField, *args):  
    minY = cmds.intField(minElField, query=True, value=True)
    maxY = cmds.intField(maxElField, query=True, value=True) 
    if cmds.ls(selection = True) != []:
        # Generate terrain
        terrainPlane = cmds.ls(selection = True)[0]
        numVerts = cmds.polyEvaluate(terrainPlane, vertex = True)
        print terrainPlane
        for vert in xrange(numVerts):
            randY = random.uniform(minY, maxY)
            vertName = terrainPlane + ".vtx[" + str(vert) + "]"
            currentVertPos = cmds.xform(vertName, query = True, worldSpace = True, translation = True)
            #print currentVertPos
            cmds.polyMoveVertex(vertName, translateY=randY)
        cmds.polySmooth(terrainPlane, kb=1 )
        numVerts = cmds.polyEvaluate(terrainPlane, vertex = True)
    else:
        cmds.error("Select a plane to use.")
Ejemplo n.º 14
0
def make_planes():
    coords = []

    n = raw_input("North")
    w = raw_input("West")

    coords.append([n, w])

    for location in coords:
        new_plane = cmds.polyPlane(height=1,
                                   width=1,
                                   axis=[0, 0, 1],
                                   sh=1,
                                   sw=1,
                                   n="GEO_PLANE_N" +
                                   str(location[0]).zfill(3) + "W" +
                                   str(location[1]).zfill(3))
        print(new_plane)
        cmds.polyMoveVertex(new_plane[0] + ".vtx[0:3]", tz=57.2965067401)
        cmds.setAttr(new_plane[0] + ".rx", -1 * float(location[0]))
        cmds.setAttr(new_plane[0] + ".ry", -1 * float(location[1]))
Ejemplo n.º 15
0
def createOffsetMesh(inputObject, offsetValue = -0.5 ):
    """
    Creates a duplicate mesh offset inward from the input mesh.
    Construction history is live on the polyMoveVertex node so the localTranslate attrs 
    can be adjusted after running this function.
    
    createOffsetMesh('pCylinder1')
    """
    
    offsetObj = cmds.duplicate( inputObject, rr=1, name=(inputObject+'_offset') )
    offsetVtx = cmds.polyMoveVertex(offsetObj[0], constructionHistory=1, random=0 )
    cmds.setAttr( (offsetVtx[0]+'.localTranslateZ'), -0.5)
    return offsetObj[0]
Ejemplo n.º 16
0
    def quartzRock(self, nameGroup, rocks, radiusDistr, minScale, maxScale):
        """Creates the requested quartz style rocks """

        rocksGroup = cmds.group(empty=True, name=nameGroup)

        for r in range(rocks):

            sx = random.uniform(1, 4)
            sy = random.uniform(1, 4)
            sz = random.uniform(1, 4)
            height = random.uniform(1, 3)
            width = random.uniform(1, 3)
            xR = random.uniform(-90, 90)
            yR = random.uniform(-90, 90)
            zR = random.uniform(-90, 90)
            xLT = random.uniform(-0.1, 0.1)
            yLT = random.uniform(-0.1, 0.1)
            zLT = random.uniform(-0.1, 0.1)

            xPos = random.uniform(-radiusDistr, radiusDistr)
            zPos = random.uniform(-radiusDistr, radiusDistr)

            scale = random.uniform((minScale * 0.35), (maxScale * 0.35))

            rock = cmds.polyCube(name="quartz#",
                                 height=height,
                                 width=width,
                                 sx=sx,
                                 sy=sy,
                                 sz=sz)
            polyVtx = cmds.polyMoveVertex(ch=True,
                                          ran=3.0,
                                          lt=(0.05, 0.02, 0.07))
            #polyVtx = cmds.polyMoveVertex(ch= True, ran=3.0,lt=(xLT,yLT,zLT))
            cmds.polySmooth(dv=1)
            cmds.select(rock)
            cmds.xform(r=True, ro=(xR, yR, zR))
            cmds.move(xPos, 0, zPos)
            cmds.scale(scale, scale, scale)
            cmds.makeIdentity(apply=True, t=True, r=True, s=True, pn=True)
            cmds.delete(ch=True)
Ejemplo n.º 17
0
    def boulderRock(self, nameGroup, rocks, radiusDistr, minScale, maxScale):
        """Creates the requested boulder style rocks """

        rocksGroup = cmds.group(empty=True, name=nameGroup)

        for r in range(rocks):

            xPos = random.uniform(-radiusDistr, radiusDistr)
            zPos = random.uniform(-radiusDistr, radiusDistr)

            xDim = random.uniform(1.0, 5.0)
            yDim = random.uniform(1.0, 5.0)
            zDim = random.uniform(1.0, 5.0)
            randomElements = ['1', '2', '3']
            randomDim = random.choice(randomElements)
            xLT = random.uniform(-0.2, 0.3)
            yLT = random.uniform(-0.2, 0.3)
            zLT = random.uniform(-0.2, 0.3)

            rock = cmds.polyCube(name="boulder#")
            cmds.parent(rock, rocksGroup)
            cmds.move(xPos, 0, zPos)

            if randomDim == '1':
                cmds.scale(xDim, yDim, zDim)
            elif randomDim == '2':
                cmds.scale(xDim, xDim, xDim)
            else:
                cmds.scale(xDim, xDim, zDim)

            cmds.polySmooth(dv=1)
            polyVtx = cmds.polyMoveVertex(ch=True, ran=3.0, lt=(xLT, yLT, zLT))
            cmds.polySmooth(dv=1)

            rockScale = random.uniform((minScale * 0.5), (maxScale * 0.5))
            cmds.scale(rockScale, rockScale, rockScale)
            cmds.delete(ch=True)
Ejemplo n.º 18
0
    def stalagmiteRock(self, nameGroup, rocks, radiusDistr, minScale,
                       maxScale):
        """Creates the requested stalagmite style rocks"""

        rocksGroup = cmds.group(empty=True, name=nameGroup)

        for r in range(rocks):

            xPos = random.uniform(-radiusDistr, radiusDistr)
            zPos = random.uniform(-radiusDistr, radiusDistr)

            list1 = (2, 3, 4, 5, 6, 7, 8)
            list2 = (3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
            list3 = (4, 5, 6, 7, 8)
            radius = random.choice(list1)
            height = random.choice(list2)
            sx = random.choice(list3)
            sy = random.choice(list3)
            xLT = random.uniform(-0.3, 0.3)
            yLT = random.uniform(-0.3, 0.3)
            zLT = random.uniform(-0.3, 0.3)

            rock = cmds.polyCone(name="stalagmite#",
                                 radius=radius,
                                 height=height,
                                 sx=sx,
                                 sy=sy)
            cmds.parent(rock, rocksGroup)
            cmds.xform(rock, piv=(0, -(height / 2), 0), ws=True)
            cmds.move(xPos, height / 2, zPos)
            polyVtx = cmds.polyMoveVertex(ch=True, ran=3.0, lt=(xLT, yLT, zLT))
            rockScale = random.uniform((minScale * 0.25), (maxScale * 0.25))
            cmds.select(rock)
            cmds.scale(rockScale, rockScale, rockScale)
            cmds.polySmooth(dv=1)
            cmds.delete(ch=True)
Ejemplo n.º 19
0
def doRemovePivotOffsets(node, returnToPos=False, currentAssetCategory="environments"):
    '''
    Freezes transforms and removes pivot offsets.
    @paran node: One top GRP node.
    '''
    nodeParent = None
    currentNode = node
    dividerTypes = ["GRP", "CPF", "CPO", "CPD"]
    
    divider = ""
    nodeParts = node.rpartition("|")[2].split("_")
    for nodePart in nodeParts:
        if nodePart in dividerTypes:
            divider = nodePart
    
    tempParent = cmds.createNode("transform", name="tempParent")
    tempChildren = cmds.createNode("transform", name="tempChildren")
    
    
    # Parent to world.
    if divider:
        nodeParent = cmds.listRelatives(currentNode, parent=True, path=True)
        if nodeParent:
            currentNode = cmds.parent(currentNode, world=True)[0]
        
    # Freeze top node.
    pos = cmds.xform(currentNode, query=True, worldSpace=True, absolute=True, rotatePivot=True)
    rot = cmds.getAttr("%s.r" % currentNode)[0]
    scl = cmds.getAttr("%s.s" % currentNode)[0]
    
    # Move back to origin, relative to pivot.
    cmds.setAttr("%s.r" % currentNode, 0, 0, 0)
    cmds.setAttr("%s.s" % currentNode, 1, 1, 1)
    if not currentAssetCategory == "characters":
        cmds.move(0,0,0, currentNode, rotatePivotRelative=True)
    else:
        cmds.setAttr("%s.t" % currentNode, 0, 0, 0)
        if returnToPos:
            cmds.createNode("transform", name="tempCharReset")
            cmds.delete(cmds.parentConstraint(currentNode, "tempCharReset", mo=False))
            cmds.createNode("transform", name="tempCharZero")
            cmds.parent("tempCharZero", "tempCharReset")
        
    # Freeze transformations.
    cmds.makeIdentity(currentNode, apply=True, translate=True, rotate=True, scale=True, normal=False)
    
    # Get children GEO.
    nodeList = [x for x in (cmds.listRelatives(currentNode, path=True, allDescendents=True) or []) if cmds.nodeType(x) == "transform"]
    for nodeName in nodeList:
        cmds.polyMoveVertex(nodeName, localTranslate=(0,0,0), constructionHistory=False)
        cmds.select(clear=True)
        
    cmds.delete(currentNode, constructionHistory=True)    
    
    # Freeze children.
    for nodeName in nodeList:
        children = cmds.listRelatives(nodeName, children=True, path=True)
        if not children:
            cmds.delete(nodeName)
            continue
        else:
            for child in children:
                if cmds.nodeType(child) == "transform":
                    cmds.parent(child, tempChildren)
            
        nodeNameParent = cmds.listRelatives(nodeName, parent=True, path=True)
        pivotPos = cmds.xform(nodeName, query=True, worldSpace=True, rotatePivot=True)
        cmds.move(0,0,0, nodeName, rotatePivotRelative=True)
        
        if nodeNameParent:
            nodeName = cmds.parent(nodeName, tempParent)[0]
            
        cmds.makeIdentity(nodeName, apply=True, translate=True, rotate=True, scale=True, normal=False)
        cmds.polyMoveVertex(nodeName, localTranslate=(0,0,0), constructionHistory=False)
        cmds.select(clear=True)
        cmds.delete(nodeName, constructionHistory=True)
        
        if nodeNameParent:
            parentedNodes = cmds.listRelatives(tempParent, children=True, path=True)
            nodeName = cmds.parent(parentedNodes, nodeNameParent)[0]
        
        childNodes = cmds.listRelatives(tempChildren, children=True, path=True)
        
        cmds.setAttr("%s.t" % nodeName, pivotPos[0], pivotPos[1], pivotPos[2])
        if childNodes:
            cmds.parent(childNodes, nodeName)
    
    cmds.delete(tempParent, tempChildren)
    
    # Move top node back
    if returnToPos:
        if not currentAssetCategory == "characters":
            cmds.xform(currentNode, worldSpace=True, absolute=True, translation=pos)
        else:
            cmds.xform("tempCharReset", worldSpace=True, absolute=True, translation=pos)
            cmds.delete(cmds.parentConstraint("tempCharZero", currentNode, mo=False))
            cmds.delete("tempCharReset")
            
        cmds.setAttr("%s.r" % currentNode, rot[0], rot[1], rot[2])
        cmds.setAttr("%s.s" % currentNode, scl[0], scl[1], scl[2])
        
        if nodeParent:
            try:
                cmds.parent(currentNode, nodeParent)
            except:
                pass
            
    return currentNode
Ejemplo n.º 20
0
 def vertexMove(self, min, max):
     for vertex in self.vertexList:
         position = random.uniform(min, max)
         mc.polyMoveVertex(funnyPlane.plane + ".vtx[" + str(vertex) + "]",
                           translateY=position)
Ejemplo n.º 21
0
 def vertexRevert(self):
     for i, vertex in enumerate(self.vertexList):
         print "stuff"
         mc.polyMoveVertex(funnyPlane.plane + ".vtx[" + str(vertex) + "]",
                           translateY=self.positions[i][1],
                           ws=True)
Ejemplo n.º 22
0
    def reshapeD(*pArgs):
        name = cmds.textField(fileName, q=True, text=True)
        if len(name) > 0:
            try:
                '''The returned amount for smoothing and strength modifier'''
                smooth = cmds.intSliderGrp(smoothSlider, q=True, value=True)
                strength = cmds.intSliderGrp(
                    strengthSlider, q=True, value=True) + 1
                if (smooth > 0):
                    cmds.polySmooth(selection, dv=smooth + 1)
                if (strength == 0):
                    strength = .5
                '''The number of vertices in the selected object'''
                numOfVertex = cmds.polyEvaluate(v=True)
                print('The number of vertices for ' + str(selection[0]) +
                      ' is ' + str(numOfVertex))
                cmds.delete(ch=True)
                '''For each vertex'''
                for i in range(numOfVertex):
                    '''defines the vertex'''
                    vertex = cmds.ls(str(selection[0]) + '.vtx[' + str(i) +
                                     ']',
                                     fl=1)
                    print('Current vertex: ' + str(vertex))
                    '''The location/coordinates of the vertex'''
                    vertexLocation = cmds.pointPosition(vertex)
                    x = vertexLocation[0]
                    y = vertexLocation[1]
                    z = vertexLocation[2]
                    #print('X: '+ str(x))
                    #print('Y: '+ str(y))
                    #print('Z: '+ str(z))
                    '''The UV value of the specific vertex'''
                    UVValues = cmds.polyEditUV(
                        cmds.polyListComponentConversion(vertex, toUV=True)[0],
                        query=True)
                    #print('The UV location ' + str(UVValues))
                    '''Color for the height map of the found vertex'''
                    color = 0
                    color = cmds.colorAtPoint(name,
                                              u=UVValues[0],
                                              v=UVValues[1])
                    #print('color: '+str(color[0]))
                    #print(x+color[0])
                    #print(y+color[0])
                    #print(z+color[0])
                    '''Adjusts the location of the vertex based on the heighmap color 0-1'''
                    cmds.polyMoveVertex(
                        vertex,
                        translate=(x + (x * color[0] * strength),
                                   y + (y * color[0] * strength),
                                   z + (z * color[0] * strength)))
                    #print('.........')
                '''Deletes the history and deletes the UI menu'''
                cmds.delete(ch=True)
                cmds.deleteUI(HeightWindow)

            except:
                cmds.deleteUI(HeightWindow)
                cmds.confirmDialog(
                    title='Incorrect File Name',
                    message='The file name for the material is incorrect',
                    button=['Ok'])
Ejemplo n.º 23
0
	def createHouse(self,scaleX, scaleY, scaleZ, r,g,b, numOfHouses):
		
		# Create new scene every time program runs
		mc.file(new = True, force = True) 
		"""
                Below, we create the roof for the house
                """
                # Roof
                roof = mc.polyPyramid(n='roof')
                mc.scale(28.147,12.410,28.373)
                mc.move(1.167, 32.273, 0)
                mc.setAttr('roof.ry', 45)
                colorLambert = mc.shadingNode('lambert', asShader=True) 
                mc.select(roof)
                
                # ColorLambert and HyperShade are for setting color of the object
                mc.setAttr((colorLambert + '.color'), 0.5725, 0.1686, 0.129, type = 'double3')
                mc.hyperShade(assign=colorLambert)
                mc.polyMoveVertex('roof.vtx[0:1]', tx=-25.3)
                mc.polyMoveVertex('roof.vtx[4]', tx=-10.3)
                
                # Roof 2
                roof2 = mc.polyPyramid(n='roof2')
                mc.scale(28.147,12.410,28.373)
                mc.move(1.167, 28.601, -28.944)
                mc.setAttr('roof2.rx', -20.000)
                mc.setAttr('roof2.ry', 43.000)
                mc.setAttr('roof2.rz', -13.500)
                colorLambert = mc.shadingNode('lambert', asShader=True) 
                mc.select(roof2)
                mc.setAttr((colorLambert + '.color'), 0.5725, 0.1686, 0.129, type = 'double3')
                mc.hyperShade(assign=colorLambert)
                mc.polyMoveVertex('roof2.vtx[0:1]', tx=-25.3)
                mc.polyMoveVertex('roof2.vtx[4]', tx=-10.3)
                
                """
                Below, we create the windows for the house
                """
                # Windows
                
                # Front top above garage
                for i in range(1):
                        windows = mc.polyCube(n='windowsFrontTop')
                        mc.scale(0.420, 5.886, 9.002)
                        mc.move(11.975, 23.622, -10.279 * -i)
                        colorLambert = mc.shadingNode( 'lambert', asShader=True ) 
                        mc.select(windows)
                        mc.setAttr((colorLambert + '.color'), 0, 0, 0, type = 'double3' )
                        mc.hyperShade(assign=colorLambert)
                
                # Left Side on 2nd story
                for i in range(0,2):
                        windows = mc.polyCube(n='windowsRightSideBottom')
                        mc.scale(0.420, 3.325, 5.290)
                        mc.rotate(0,90,0)
                        mc.move(-15.612 * i, 23.622, 13.253)
                        colorLambert = mc.shadingNode( 'lambert', asShader=True ) 
                        mc.select(windows)
                        mc.setAttr((colorLambert + '.color'), 0, 0, 0, type = 'double3' )
                        mc.hyperShade(assign=colorLambert)
                
                # Rear windows on 2nd story
                for i in range(-1,1):
                        windows = mc.polyCube(n='windowsFrontBottom')
                        mc.scale(0.420, 3, 2.940)
                        mc.move(-33.978, 23.622, 8.921 * -i)
                        colorLambert = mc.shadingNode( 'lambert', asShader=True ) 
                        mc.select(windows)
                        mc.setAttr((colorLambert + '.color'), 0, 0, 0, type = 'double3' )
                        mc.hyperShade(assign=colorLambert)
                        
                # 2 end windows near Front Door
                for i in range(2):
                        frontDoorEndWindow = mc.polyCube(n='frontDoorEndWindow')
                        mc.scale(0.627, 4.665, 2.428)
                        mc.move(-4.546, 13.984, -27.740 - (10*i))
                        colorLambert = mc.shadingNode( 'lambert', asShader=True ) 
                        mc.select(frontDoorEndWindow)
                        mc.setAttr((colorLambert + '.color'), 0, 0, 0, type = 'double3' )
                        mc.hyperShade(assign=colorLambert)
                
                # Window near Front Door
                for i in range(1):
                        frontDoorWindow = mc.polyCube(n='frontDoorWindow')
                        mc.scale(0.627, 4.665, 7.094)
                        mc.move(-4.546, 13.984, -32.742)
                        colorLambert = mc.shadingNode( 'lambert', asShader=True ) 
                        mc.select(frontDoorWindow)
                        mc.setAttr((colorLambert + '.color'), 0.412, 0.412, 0.412, type = 'double3' )
                        mc.hyperShade(assign=colorLambert)
                        
                                
                # Rear window near ground floor bedroom
                for i in range(1):
                        windowsRearBottomNearBedroom = mc.polyCube(n='windowsRearBottomNearBedroom')
                        mc.scale(0.420, 3, 6.388)
                        mc.move(-33.978, 14.686, -19.139)
                        colorLambert = mc.shadingNode( 'lambert', asShader=True ) 
                        mc.select(windowsRearBottomNearBedroom)
                        mc.setAttr((colorLambert + '.color'), 0, 0, 0, type = 'double3' )
                        mc.hyperShade(assign=colorLambert)
                
                # Rear window near kitchen
                for i in range(1):
                        windowsRearBottomNearKitchen = mc.polyCube(n='windowsRearBottomNearKitchen')
                        mc.scale(0.420, 7.818, 4.556)
                        mc.move(-33.978, 10.546, -36.449)
                        colorLambert = mc.shadingNode( 'lambert', asShader=True ) 
                        mc.select(windowsRearBottomNearKitchen)
                        mc.setAttr((colorLambert + '.color'), 0, 0, 0, type = 'double3' )
                        mc.hyperShade(assign=colorLambert)
        
                """
                Below, we create the main and right side of the building for the house
                """
                # main building
                building = mc.polyCube(n='building')
                mc.scale(25.963, 26.190, 45.551)
                mc.move(-10.958, 14.810, 0)
                mc.setAttr('building.ry', 90)
                colorLambert = mc.shadingNode( 'lambert', asShader=True ) 
                mc.select(building)
                mc.setAttr((colorLambert + '.color'), r, g, b, type = 'double3' )
                mc.hyperShade(assign=colorLambert)
                mc.polySplitVertex('building.vtx[2:5]')
                
                # Right side of building
                rightSide = mc.polyCube(n='rightSide')
                mc.scale(28.082, 7.793, 29.276)
                mc.rotate(0,90,0)
                mc.move(-19.041, 5.623, -26.999)
                colorLambert = mc.shadingNode('lambert', asShader=True) 
                mc.select(rightSide)
                mc.setAttr((colorLambert + '.color'), r, g, b, type = 'double3' )
                mc.hyperShade(assign=colorLambert)
                mc.polyMoveVertex('rightSide.vtx[2]', 'rightSide.vtx[4]', ty=18.4)
                mc.polyMoveVertex('rightSide.vtx[3]', 'rightSide.vtx[5]', ty=10)
                mc.polyMoveVertex('rightSide.vtx[3]', ty=1)
                mc.polyMoveVertex('rightSide.vtx[5]', ty=1)
                
                """
                Below, we create the front doors and the garage door
                """
                # 2 Front Doors
                for i in range(2):
                        frontDoor = mc.polyCube(n='frontDoor')
                        mc.scale(0.627, 8.678, 4.392)
                        mc.move(-4.546, 6.086, -15.466 - (4.5*i))
                        colorLambert = mc.shadingNode( 'lambert', asShader=True ) 
                        mc.select(frontDoor)
                        mc.setAttr((colorLambert + '.color'), 0.5, 0, 0, type = 'double3' )
                        mc.hyperShade(assign=colorLambert)
                
                # Garage Door
                for i in range(1):	
                        garageDoor = mc.polyCube(n='garageDoor')
                        mc.move(11.982,6.060 + (2.35*i),0)
                        mc.scale(0.277, 8.664, 18.652)
                        mc.select(garageDoor)
                        
                
                # polyUnite() will gather the objects and will merge all of them together. This allows to scale the entire house without having to worry about modifying the coordinates of the windows, roof, and other components of the house
                house = mc.polyUnite('rightSide', 'building','garageDoor', 'windowsRightSideBottom', 'windowsRightSideBottom1', 'windowsFrontBottom1', 'windowsFrontTop', 'frontDoorEndWindow1', 'roof', 'frontDoor1', 'frontDoor', 'roof2','windowsFrontBottom','windowsRearBottomNearKitchen','windowsRearBottomNearBedroom','frontDoorWindow','frontDoorEndWindow', n='house')
                
                # Scale the house from the random x,y,z sizes
                mc.scale(scaleX,scaleY,scaleZ, house)
                
                """for i in range(numOfHouses):
                	mc.duplicate('house', smartTransform=True)
                	mc.xform(house, translation=[i * 10, i, i * 5])"""
                return house # Now we return the object
Ejemplo n.º 24
0
def make_cubes(place_string, animation, height_scale, time_scale):
    #RUN ON STATE OR COUNTRY
    #places=get_state_data(place_string)
    places=get_country_data(place_string)

    #CREATE NEW PLANE NAMED AFTER LOCATION
    for location in places:
        #NEED GROUPING FUNCTION
        new_cube = cmds.polyCube(
            n= location[0]+"-BAR",
            height = .25,
            width = .25,
            depth = .25,
            axis=[0,0,1],
            ch=False)

        shape_node = cmds.listRelatives( new_cube[0], children=True )
        #ADD ATTRIBUTE CASES AND POP TO DRIVE ANIMATION AND COLOR
        cmds.addAttr(shape_node[0], shortName='cases', longName='mtoa_constant_cases', defaultValue=0.0, minValue=0.0, maxValue=1000000 )
        cmds.addAttr(shape_node[0], shortName='pop', longName='mtoa_constant_population', defaultValue=0, minValue=0, maxValue=20000000 )
        cmds.addAttr(shape_node[0], shortName='day', longName='mtoa_constant_daily', defaultValue=0.0, minValue=0.0, maxValue=1000000 )
        cmds.addAttr(shape_node[0], shortName='avg', longName='mtoa_constant_average', defaultValue=0.0, minValue=0.0, maxValue=1000000 )

        cmds.setAttr(shape_node[0]+".cases", float(location[-1][-1]))
        cmds.setAttr(shape_node[0]+".pop", float(location[-2]))

        #MOVE PLANE TO EDGE OF EARTH (57.2965067401 MAYA UNITS)
        cmds.polyMoveVertex(new_cube[0]+".vtx[0:7]", tz=earth_scale, ch=False)



        #ROTATE TO LAT LON POSITION
        #cmds.rotate(-1*float(location[1]), float(location[2]), 0, new_cube[0], objectSpace=True)
        #cmds.expression( string = new_cube[0]+".rx ="+str(-1*float(location[1])))
        #cmds.expression( string = new_cube[0]+".ry ="+str(float(location[1])))

        cmds.setAttr(new_cube[0]+".rx",-1*float(location[1]))
        cmds.setAttr(new_cube[0]+".ry", float(location[2]))
        cmds.xform(new_cube[0], cp=1, a=1)

        #2*(((3V)/(4.0*3.1415926))**(1.0/3.0))
        #death_scalar = 1.611661654
        case_scalar = 0.25
        cmds.expression( string = new_cube[0]+".sx = "+str(case_scalar)+" * pow(("+shape_node[0]+".cases),(1.0/3.0))")
        cmds.expression( string = new_cube[0]+".sy = "+str(case_scalar)+" * pow(("+shape_node[0]+".cases),(1.0/3.0))")
        cmds.expression( string = new_cube[0]+".sz = "+str(case_scalar)+" * pow(("+shape_node[0]+".cases),(1.0/3.0))")

        #GROUP GEOMETRY BASED ON STATE
        #CHECK TO SEE IF STATE GROUP ALREADY EXISTS
        bar_location = location[0].split(", ")[1].replace(" ", "")
        if cmds.ls(str(bar_location)):
            cmds.parent(new_cube, bar_location)
        else:

            cmds.group(new_cube, name = bar_location)

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

        #TO RUN IF ANIMATION ARG SET IN FUNCTION CALL
        if animation:
            #ITERATE OVER DAILY NUMBERS AND SET EXTRUSION KEYFRAMES
            for number in case_numbers:
                #CHECK TO SEE IF NEW KEYFRAME NEEDED
                index = timer
                #BASE CASE
                if index == 0:
                    cmds.setKeyframe(shape_node[0]+".day", time = 0, value = 0)
                    cmds.setKeyframe(shape_node[0]+".avg", time = 0, value = 0)
                    cmds.setKeyframe(shape_node[0]+".cases", time = 0, value = (float(case_numbers[(timer)])))
                    timer = timer+1
                else:
                    average_cases = 0

                    today = (float(case_numbers[(timer)]))-(float(case_numbers[(timer)-1]))

                    if (timer-2)< 0:
                        day_1 = 0
                    else:
                        day_1 = (float(case_numbers[(timer-1)]))-(float(case_numbers[(timer)-2]))

                    if (timer-3)< 0:
                        day_2 = 0
                    else:
                        day_2 = (float(case_numbers[(timer-2)]))-(float(case_numbers[(timer)-3]))

                    if (timer-4)< 0:
                        day_3 = 0
                    else:
                        day_3 = (float(case_numbers[(timer-3)]))-(float(case_numbers[(timer)-4]))

                    if (timer-5)< 0:
                        day_4 = 0
                    else:
                        day_5 = (float(case_numbers[(timer-4)]))-(float(case_numbers[(timer)-5]))

                    if (timer-6)< 0:
                        day_5 = 0
                    else:
                        day_5 = (float(case_numbers[(timer-5)]))-(float(case_numbers[(timer)-6]))

                    if (timer-7)< 0:
                        day_6 = 0
                    else:
                        day_6 = (float(case_numbers[(timer-6)]))-(float(case_numbers[(timer)-7]))


                    average_cases = (today + day_1 + day_2 + day_3 + day_4 + day_5 + day_6)/7

                    cmds.setKeyframe(shape_node[0]+".day", time = (timer)*time_scale, value = today)
                    cmds.setKeyframe(shape_node[0]+".avg", time = (timer)*time_scale, value = average_cases)
                    cmds.setKeyframe(shape_node[0]+".cases", time = (timer)*time_scale, value = (float(case_numbers[(timer)])))
                    timer = timer+1
Ejemplo n.º 25
0
def polyMoveVertex(*args, **kwargs):
    res = cmds.polyMoveVertex(*args, **kwargs)
    if not kwargs.get('query', kwargs.get('q', False)):
        res = _factories.maybeConvert(res, _general.PyNode)
    return res
Ejemplo n.º 26
0
    def fix(self, report, params):
        obj_name = report.node().name()

        cmds.polyMoveVertex(obj_name, ch=1)

        return True
penteToit = 2.0
hauteurToit = 1.0

toit = cmds.polyCube(width=largeurMarche,
                     depth=epaisseurMarche,
                     height=hauteurToit,
                     subdivisionsDepth=2,
                     name='toit')
cmds.move(
    11.967, hauteurSocle + hauteurCylindre + hauteurCube +
    hauteuFriseGrecqueBordures + hauteuFriseGrecqueInterieur +
    hauteuFriseGrecqueBordures1 + hauteurToit / 2, 11.967, 'toit')

#Création de la pente du toit
cmds.polyMoveVertex('toit.vtx[4]', ty=penteToit)
cmds.polyMoveVertex('toit.vtx[5]', ty=penteToit)

cmds.attrFieldSliderGrp(label="Taille X du toit",
                        min=0.1,
                        max=10.0,
                        at='toit.sx')
cmds.attrFieldSliderGrp(label="Taille Y du toit",
                        min=0.1,
                        max=10.0,
                        at='toit.sy')
cmds.attrFieldSliderGrp(label="Taille Z du toit",
                        min=0.1,
                        max=10.0,
                        at='toit.sz')
Ejemplo n.º 28
0
        if random.random() > 0.8:
            brick = cmds.polyCube(w=0.2 + (random.random() * 0.4),
                                  h=0.3,
                                  d=0.2 + (random.random() * 0.4))
            vtxPos = cmds.xform(str(shape) + ".pnts[" + str(i) + "]",
                                query=True,
                                translation=True,
                                worldSpace=True)
            cmds.move(vtxPos[0] + (random.random() - 0.5) * 0.1,
                      vtxPos[1] + (random.random() - 0.5) * 0.05,
                      vtxPos[2] + (random.random() - 0.5) * 0.1,
                      brick,
                      absolute=True)
            cmds.rotate((random.random() - 0.5) * 5.0,
                        (random.random() - 0.5) * 5.0,
                        (random.random() - 0.5) * 5.0, brick)

            brickShape = cmds.listRelatives(brick, shapes=True)
            for brickVertices in brickShape:
                vertexNormalList = cmds.ls(brickVertices + '.e[*]', fl=True)
                for vertexRotation in vertexNormalList:
                    cmds.polyMoveVertex(vertexRotation,
                                        t=(0.0, 0.0, 0.0),
                                        random=0.1)
                    if random.random() > 0.4:
                        cmds.polyBevel(vertexRotation,
                                       offset=0.05,
                                       worldSpace=True)

    cmds.delete(smoothnode)
Ejemplo n.º 29
0
                 ['waist_joint_center_geo', 'chest_center_geo'])
waist.defineFather(root)

# LEFT ARM
# ----------------
# Shoulder_left
create_joint('shoulder', l, [0.187, 1.451, 0])
shoulder_left = BodyPart('shoulder', l, 'shoulder_joint_left_crv',
                         'shoulder_joint_left_geo')
shoulder_left.defineFather(waist)

# Arm_left
arm_left_geo = cmds.polyCylinder(name='arm_left_geo', r=0.04, h=0.27, sy=4)
cmds.move(0.189, 1.291, 0)
cmds.rotate(0, 0, 0.054)
cmds.polyMoveVertex('arm_left_geo.vtx[80:99]', sx=0.8, sz=0.8)
cmds.polyMoveVertex('arm_left_geo.vtx[0:19]', sx=0.7, sz=0.7)
shoulder_left.appendGeos(arm_left_geo[0])

# Elbow_left
create_joint('elbow', l, [0.190, 1.128, 0])
elbow_left = BodyPart('elbow', l, 'elbow_joint_left_crv',
                      'elbow_joint_left_geo')
elbow_left.defineFather(shoulder_left)

# Forearm_left
forearm_left_geo = cmds.polyCylinder(name='forearm_left_geo',
                                     r=0.037,
                                     h=0.265,
                                     sy=4)
cmds.move(0.195, 0.979, 0)
Ejemplo n.º 30
0
import maya.cmds as cmds

sel = cmds.ls(sl=1, fl=1)
print sel

for i in sel:
    cmds.polyMoveVertex( i, ws= 0, tx=2.0 )
Ejemplo n.º 31
0
def regenerateTarget(blendShape, target, base="", connect=False):
    """
    Regenerate target geometry for the specified blendShape target.
    @param blendShape: BlendShape to regenerate target geometry for
    @type blendShape: str
    @param target: BlendShape target to regenerate target geometry for
    @type target: str
    @param base: BlendShape base geometry to regenerate target geometry from
    @type base: str
    @param connect: Reconnect regenerated target geometry to target input
    @type connect: bool
    """
    # ==========
    # - Checks -
    # ==========

    if not glTools.utils.blendShape.isBlendShape(blendShape):
        raise Exception('Object "' + blendShape + '" is not a valid blendShape!')
    if not glTools.utils.blendShape.hasTarget(blendShape, target):
        raise Exception('BlendShape "' + blendShape + '" has no target "' + target + '"!')
    if base and not glTools.utils.blendShape.hasBase(blendShape, base):
        raise Exception('BlendShape "' + blendShape + '" has no base geometry "' + base + '"!')

    # Check Existing Live Target Geometry
    if glTools.utils.blendShape.hasTargetGeo(blendShape, target, base=base):
        targetGeo = glTools.utils.blendShape.getTargetGeo(blendShape, target, baseGeo=base)
        print('Target "" for blendShape "" already has live target geometry! Returning existing target geometry...')
        return targetGeo

    # Get Base Geometry - Default to base index [0]
    if not base:
        base = glTools.utils.blendShape.getBaseGeo(blendShape)[0]
    baseIndex = glTools.utils.blendShape.getBaseIndex(blendShape, base)

    # Get Target Index
    targetIndex = glTools.utils.blendShape.getTargetIndex(blendShape, target)

    # ==============================
    # - Regenerate Target Geometry -
    # ==============================

    # Initialize Target Geometry
    targetGeo = cmds.duplicate(base, n=target)[0]

    # Delete Unused Shapes
    for targetShape in cmds.listRelatives(targetGeo, s=True, pa=True):
        if cmds.getAttr(targetShape + ".intermediateObject"):
            cmds.delete(targetShape)

    # Get Target Deltas and Components
    wtIndex = 6000
    targetDelta = cmds.getAttr(
        blendShape
        + ".inputTarget["
        + str(baseIndex)
        + "].inputTargetGroup["
        + str(targetIndex)
        + "].inputTargetItem["
        + str(wtIndex)
        + "].inputPointsTarget"
    )
    targetComp = cmds.getAttr(
        blendShape
        + ".inputTarget["
        + str(baseIndex)
        + "].inputTargetGroup["
        + str(targetIndex)
        + "].inputTargetItem["
        + str(wtIndex)
        + "].inputComponentsTarget"
    )
    for i in xrange(len(targetComp)):
        # Get Component Delta
        d = targetDelta[i]
        # Apply Component Delta
        cmds.move(d[0], d[1], d[2], targetGeo + "." + targetComp[i], r=True, os=True)

    # Freeze Vertex Transforms
    cmds.polyMoveVertex(targetGeo)
    cmds.delete(targetGeo, ch=True)

    # ===========================
    # - Connect Target Geometry -
    # ===========================

    if connect:
        cmds.connectAttr(
            targetGeo + ".outMesh",
            blendShape
            + ".inputTarget["
            + str(baseIndex)
            + "].inputTargetGroup["
            + str(targetIndex)
            + "].inputTargetItem["
            + str(wtIndex)
            + "].inputGeomTarget",
            f=True,
        )

    # =================
    # - Return Result -
    # =================

    return targetGeo
Ejemplo n.º 32
0
def make_cubes(place_string, animation, height_scale, time_scale):
    #RUN ON STATE OR COUNTRY
    #places=get_state_data(place_string)
    places = get_country_data(place_string)

    #CREATE NEW PLANE NAMED AFTER LOCATION
    for location in places:
        #NEED GROUPING FUNCTION
        new_cube = cmds.polyCube(n=location[0] + "-BAR",
                                 height=.25,
                                 width=.25,
                                 depth=.25,
                                 axis=[0, 0, 1],
                                 ch=False)

        #ADD ATTRIBUTE DEATHS TO DRIVE ANIMATION AND COLOR
        cmds.addAttr(shortName='d',
                     longName='deaths',
                     defaultValue=0.0,
                     minValue=0.0,
                     maxValue=1000000)
        cmds.setAttr(new_cube[0] + ".deaths", float(location[-1][-1]))
        cmds.polySmooth(new_cube[0], dv=2, ch=False)

        #MOVE PLANE TO EDGE OF EARTH (57.2965067401 MAYA UNITS)
        cmds.polyMoveVertex(new_cube[0] + ".vtx[0:97]",
                            tz=earth_scale,
                            ch=False)

        #ROTATE TO LAT LON POSITION
        #cmds.rotate(-1*float(location[1]), float(location[2]), 0, new_cube[0], objectSpace=True)
        #cmds.expression( string = new_cube[0]+".rx ="+str(-1*float(location[1])))
        #cmds.expression( string = new_cube[0]+".ry ="+str(float(location[1])))

        cmds.setAttr(new_cube[0] + ".rx", -1 * float(location[1]))
        cmds.setAttr(new_cube[0] + ".ry", float(location[2]))
        cmds.xform(new_cube[0], cp=1, a=1)

        #2*(((3V)/(4.0*3.1415926))**(1.0/3.0))
        #death_scalar = 1.611661654
        death_scalar = 2
        cmds.expression(string=new_cube[0] + ".sx = " + str(death_scalar) +
                        " * pow(((.75)*" + new_cube[0] +
                        ".deaths/3.141592654),(1.0/3.0))")
        cmds.expression(string=new_cube[0] + ".sy = " + str(death_scalar) +
                        " * pow(((.75)*" + new_cube[0] +
                        ".deaths/3.141592654),(1.0/3.0))")
        cmds.expression(string=new_cube[0] + ".sz = " + str(death_scalar) +
                        " * pow(((.75)*" + new_cube[0] +
                        ".deaths/3.141592654),(1.0/3.0))")

        #GROUP GEOMETRY BASED ON STATE
        #CHECK TO SEE IF STATE GROUP ALREADY EXISTS
        bar_location = location[0].split(", ")[1].replace(" ", "_")
        if cmds.ls(str(bar_location)):
            cmds.parent(new_cube, bar_location)
        else:

            cmds.group(new_cube, name=bar_location)

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

        #TO RUN IF ANIMATION ARG SET IN FUNCTION CALL
        if animation:
            #ITERATE OVER DAILY NUMBERS AND SET EXTRUSION KEYFRAMES
            for number in case_numbers:
                #CHECK TO SEE IF NEW KEYFRAME NEEDED
                index = timer
                #BASE CASE
                if index == 0:
                    cmds.setKeyframe(new_cube[0] + ".deaths",
                                     time=0,
                                     value=(float(case_numbers[(timer)])))
                    timer = timer + 1
                else:
                    cmds.setKeyframe(new_cube[0] + ".deaths",
                                     time=(timer) * time_scale,
                                     value=(float(case_numbers[(timer)])))
                    timer = timer + 1
Ejemplo n.º 33
0
        c.setAttr(name + '.translateZ',
                  i * (tireRadius * 2) - (tireRadius * 3))
        c.setAttr(name + '.translateX', tireTranslation[j])

# body made with the coolest for
body = 'body'
c.polyCube(sx=4, sy=2, sz=1, d=5.25, h=3, w=4, n=body)
c.setAttr(body + '.translateY', 0.5)
bodyRadius = 0.5
zFactor = [1, -1]
for j in range(len(zFactor)):
    for i in range(0, 15):
        rads = (360.0 / 8) * (3.1416 / 180)
        x = -1 * bodyRadius * math.cos(rads * (i % 5))
        z = zFactor[j] * bodyRadius * math.sin(rads * (i % 5))
        c.polyMoveVertex(body + '.vtx[' + str(i + 15 * j) + ']', tx=x)
        c.polyMoveVertex(body + '.vtx[' + str(i + 15 * j) + ']', tz=z)
        if i in (5, 6, 7, 8, 9):
            c.polyMoveVertex(body + '.vtx[' + str(i + 15 * j) + ']',
                             tz=3 * zFactor[j])

# head of tank
head = 'head'
headRadius = 0.5
c.polyCube(sx=4, sy=1, sz=1, d=3, h=1.0, w=4, n=head)
c.setAttr(head + '.translateY', 2.6)
c.setAttr(head + '.translateZ', -1)

for i in range(10, 20):
    rads = (360.0 / 8) * (3.1416 / 180)
    z = -1 * headRadius * math.sin(rads * (i % 5))
Ejemplo n.º 34
0
def regenerateTarget(blendShape, target, base='', connect=False):
    """
    Regenerate target geometry for the specified blendShape target.
    @param blendShape: BlendShape to regenerate target geometry for
    @type blendShape: str
    @param target: BlendShape target to regenerate target geometry for
    @type target: str
    @param base: BlendShape base geometry to regenerate target geometry from
    @type base: str
    @param connect: Reconnect regenerated target geometry to target input
    @type connect: bool
    """
    # ==========
    # - Checks -
    # ==========

    if not glTools.utils.blendShape.isBlendShape(blendShape):
        raise Exception('Object "' + blendShape +
                        '" is not a valid blendShape!')
    if not glTools.utils.blendShape.hasTarget(blendShape, target):
        raise Exception('BlendShape "' + blendShape + '" has no target "' +
                        target + '"!')
    if base and not glTools.utils.blendShape.hasBase(blendShape, base):
        raise Exception('BlendShape "' + blendShape +
                        '" has no base geometry "' + base + '"!')

    # Check Existing Live Target Geometry
    if glTools.utils.blendShape.hasTargetGeo(blendShape, target, base=base):
        targetGeo = glTools.utils.blendShape.getTargetGeo(blendShape,
                                                          target,
                                                          baseGeo=base)
        print(
            'Target "" for blendShape "" already has live target geometry! Returning existing target geometry...'
        )
        return targetGeo

    # Get Base Geometry - Default to base index [0]
    if not base: base = glTools.utils.blendShape.getBaseGeo(blendShape)[0]
    baseIndex = glTools.utils.blendShape.getBaseIndex(blendShape, base)

    # Get Target Index
    targetIndex = glTools.utils.blendShape.getTargetIndex(blendShape, target)

    # ==============================
    # - Regenerate Target Geometry -
    # ==============================

    # Initialize Target Geometry
    targetGeo = cmds.duplicate(base, n=target)[0]

    # Delete Unused Shapes
    for targetShape in cmds.listRelatives(targetGeo, s=True, pa=True):
        if cmds.getAttr(targetShape + '.intermediateObject'):
            cmds.delete(targetShape)

    # Get Target Deltas and Components
    wtIndex = 6000
    targetDelta = cmds.getAttr(blendShape + '.inputTarget[' + str(baseIndex) +
                               '].inputTargetGroup[' + str(targetIndex) +
                               '].inputTargetItem[' + str(wtIndex) +
                               '].inputPointsTarget')
    targetComp = cmds.getAttr(blendShape + '.inputTarget[' + str(baseIndex) +
                              '].inputTargetGroup[' + str(targetIndex) +
                              '].inputTargetItem[' + str(wtIndex) +
                              '].inputComponentsTarget')
    for i in xrange(len(targetComp)):
        # Get Component Delta
        d = targetDelta[i]
        # Apply Component Delta
        cmds.move(d[0],
                  d[1],
                  d[2],
                  targetGeo + '.' + targetComp[i],
                  r=True,
                  os=True)

    # Freeze Vertex Transforms
    cmds.polyMoveVertex(targetGeo)
    cmds.delete(targetGeo, ch=True)

    # ===========================
    # - Connect Target Geometry -
    # ===========================

    if connect:
        cmds.connectAttr(targetGeo + '.outMesh',
                         blendShape + '.inputTarget[' + str(baseIndex) +
                         '].inputTargetGroup[' + str(targetIndex) +
                         '].inputTargetItem[' + str(wtIndex) +
                         '].inputGeomTarget',
                         f=True)

    # =================
    # - Return Result -
    # =================

    return targetGeo
Ejemplo n.º 35
0
    def __init__(self, cookie, size, count, layer_group):
        # determine size based on selected cookie object
        scaled = cookie * size

        # create cube and set as base, track its count
        p = pcore.polyCube(sx=1,
                           sy=1,
                           sz=1,
                           h=scaled,
                           w=scaled,
                           d=scaled,
                           name='chip#',
                           n='chip{}'.format(count))[0]
        self.base = p
        self.count = count

        cmds.parent('chip{}'.format(count), layer_group)

        p0 = p.vtx[0]
        p1 = p.vtx[1]
        p2 = p.vtx[2]
        p3 = p.vtx[3]
        p4 = p.vtx[4]
        p5 = p.vtx[5]
        p6 = p.vtx[6]
        p7 = p.vtx[7]

        # randomly move vertices
        cmds.polyMoveVertex(
            'chip{}.vtx[0]'.format(count),
            translate=[
                p0.getPosition().x + random.uniform(0, scaled / 4),
                p0.getPosition().y + random.uniform(0, scaled / 8),
                p0.getPosition().z + random.uniform(0, scaled / 4)
            ])

        cmds.polyMoveVertex(
            'chip{}.vtx[1]'.format(count),
            translate=[
                p1.getPosition().x + random.uniform(0, scaled / 4),
                p1.getPosition().y + random.uniform(0, scaled / 4),
                p1.getPosition().z + random.uniform(0, scaled / 4)
            ])

        cmds.polyMoveVertex(
            'chip{}.vtx[2]'.format(count),
            translate=[
                p2.getPosition().x + random.uniform(0, scaled / 4),
                p2.getPosition().y + random.uniform(0, scaled / 4),
                p2.getPosition().z + random.uniform(0, scaled / 4)
            ])

        cmds.polyMoveVertex(
            'chip{}.vtx[3]'.format(count),
            translate=[
                p3.getPosition().x + random.uniform(0, scaled / 4),
                p3.getPosition().y + random.uniform(0, scaled / 4),
                p3.getPosition().z + random.uniform(0, scaled / 4)
            ])

        cmds.polyMoveVertex(
            'chip{}.vtx[4]'.format(count),
            translate=[
                p4.getPosition().x + random.uniform(0, scaled / 4),
                p4.getPosition().y + random.uniform(0, scaled / 4),
                p4.getPosition().z + random.uniform(0, scaled / 4)
            ])

        cmds.polyMoveVertex(
            'chip{}.vtx[5]'.format(count),
            translate=[
                p5.getPosition().x + random.uniform(0, scaled / 4),
                p5.getPosition().y + random.uniform(0, scaled / 4),
                p5.getPosition().z + random.uniform(0, scaled / 4)
            ])

        cmds.polyMoveVertex(
            'chip{}.vtx[6]'.format(count),
            translate=[
                p6.getPosition().x + random.uniform(0, scaled / 4),
                p6.getPosition().y + random.uniform(0, scaled / 4),
                p6.getPosition().z + random.uniform(0, scaled / 4)
            ])

        cmds.polyMoveVertex(
            'chip{}.vtx[7]'.format(count),
            translate=[
                p7.getPosition().x + random.uniform(0, scaled / 4),
                p7.getPosition().y + random.uniform(0, scaled / 4),
                p7.getPosition().z + random.uniform(0, scaled / 4)
            ])

        scaling = random.uniform(1.5, 2.0)
        scalingZ = random.uniform(1.0, 1.5)

        pcore.scale(scaling, scaling, scalingZ)