示例#1
0
    def setUp(self):
        self.temp = tempfile.mkdtemp(prefix='referencesTest')
        print "created temp dir: %s" % self.temp

        # Refs:
        #  sphere.ma
        #    (no refs)
        #  cube.ma
        #    :sphere => sphere.ma
        #  cone.ma
        #    :cubeInCone => cube.ma
        #      :cubeInCone:sphere => sphere.ma
        #  master.ma
        #    :sphere1 => sphere.ma
        #    :sphere2 => sphere.ma
        #    :cube1 => cube.ma
        #      :cube1:sphere => sphere.ma
        #    :cone1 => cone.ma
        #      :cone1:cubeInCone => cube.ma
        #        :cone1:cubeInCone:sphere => sphere.ma

        # create sphere file
        print "sphere file"
        #        cmds.file(new=1, f=1)
        pm.newFile(f=1)
        sphere = pm.polySphere()
        # We will use this to test failed ref edits...
        pm.addAttr(sphere, ln='zombieAttr')
        self.sphereFile = pm.saveAs(os.path.join(self.temp, 'sphere.ma'), f=1)

        # create cube file
        print "cube file"
        pm.newFile(f=1)
        pm.polyCube()
        pm.createReference(self.sphereFile, namespace='sphere')
        pm.PyNode('sphere:pSphere1').attr('translateX').set(2)
        self.cubeFile = pm.saveAs(os.path.join(self.temp, 'cube.ma'), f=1)

        # create cone file
        print "cone file"
        pm.newFile(f=1)
        pm.polyCone()
        pm.createReference(self.cubeFile, namespace='cubeInCone')
        pm.PyNode('cubeInCone:pCube1').attr('translateZ').set(2)
        pm.PyNode('cubeInCone:sphere:pSphere1').attr('translateZ').set(2)
        self.coneFile = pm.saveAs(os.path.join(self.temp, 'cone.ma'), f=1)

        print "master file"
        pm.newFile(f=1)
        self.sphereRef1 = pm.createReference(self.sphereFile,
                                             namespace='sphere1')
        pm.PyNode('sphere1:pSphere1').attr('translateY').set(2)
        self.sphereRef2 = pm.createReference(self.sphereFile,
                                             namespace='sphere2')
        pm.PyNode('sphere2:pSphere1').attr('translateY').set(4)
        self.cubeRef1 = pm.createReference(self.cubeFile, namespace='cube1')
        pm.PyNode('cube1:sphere:pSphere1').attr('translateY').set(6)
        pm.PyNode('cube1:pCube1').attr('translateY').set(6)
        self.coneRef1 = pm.createReference(self.coneFile, namespace='cone1')
        self.masterFile = pm.saveAs(os.path.join(self.temp, 'master.ma'), f=1)
示例#2
0
    def setUp(self):
        self.temp = tempfile.mkdtemp(prefix='referencesTest')
        print "created temp dir: %s" % self.temp

        # Refs:
        #  sphere.ma
        #    (no refs)
        #  cube.ma
        #    :sphere => sphere.ma
        #  cone.ma
        #    :cubeInCone => cube.ma
        #      :cubeInCone:sphere => sphere.ma
        #  master.ma
        #    :sphere1 => sphere.ma
        #    :sphere2 => sphere.ma
        #    :cube1 => cube.ma
        #      :cube1:sphere => sphere.ma
        #    :cone1 => cone.ma
        #      :cone1:cubeInCone => cube.ma
        #        :cone1:cubeInCone:sphere => sphere.ma

        # create sphere file
        print "sphere file"
#        cmds.file(new=1, f=1)
        pm.newFile(f=1)
        sphere = pm.polySphere()
        # We will use this to test failed ref edits...
        pm.addAttr(sphere, ln='zombieAttr')
        self.sphereFile = pm.saveAs( os.path.join( self.temp, 'sphere.ma' ), f=1 )

        # create cube file
        print "cube file"
        pm.newFile(f=1)
        pm.polyCube()
        pm.createReference( self.sphereFile, namespace='sphere' )
        pm.PyNode('sphere:pSphere1').attr('translateX').set(2)
        self.cubeFile = pm.saveAs( os.path.join( self.temp, 'cube.ma' ), f=1 )

        # create cone file
        print "cone file"
        pm.newFile(f=1)
        pm.polyCone()
        pm.createReference( self.cubeFile, namespace='cubeInCone' )
        pm.PyNode('cubeInCone:pCube1').attr('translateZ').set(2)
        pm.PyNode('cubeInCone:sphere:pSphere1').attr('translateZ').set(2)
        self.coneFile = pm.saveAs( os.path.join( self.temp, 'cone.ma' ), f=1 )

        print "master file"
        pm.newFile(f=1)
        self.sphereRef1 = pm.createReference( self.sphereFile, namespace='sphere1' )
        pm.PyNode('sphere1:pSphere1').attr('translateY').set(2)
        self.sphereRef2 = pm.createReference( self.sphereFile, namespace='sphere2' )
        pm.PyNode('sphere2:pSphere1').attr('translateY').set(4)
        self.cubeRef1 = pm.createReference( self.cubeFile, namespace='cube1' )
        pm.PyNode('cube1:sphere:pSphere1').attr('translateY').set(6)
        pm.PyNode('cube1:pCube1').attr('translateY').set(6)
        self.coneRef1 = pm.createReference( self.coneFile, namespace='cone1' )
        self.masterFile = pm.saveAs(os.path.join(self.temp, 'master.ma'), f=1)
示例#3
0
    def setUp(self):
        print "getting temp dir"
        self.temp = os.path.join(tempfile.gettempdir(), 'referencesTest')
        if not os.path.isdir(self.temp):
            os.makedirs(self.temp)
        
        # create sphere file
        print "sphere file"
#        cmds.file(new=1, f=1)
        pm.newFile(f=1)
        sphere = pm.polySphere()
        # We will use this to test failed ref edits...
        pm.addAttr(sphere, ln='zombieAttr')
        self.sphereFile = pm.saveAs( os.path.join( self.temp, 'sphere.ma' ), f=1 )
        
        # create cube file
        print "cube file"
        pm.newFile(f=1)
        pm.polyCube()
        pm.createReference( self.sphereFile, namespace='sphere' )
        pm.PyNode('sphere:pSphere1').attr('translateX').set(2)
        self.cubeFile = pm.saveAs( os.path.join( self.temp, 'cube.ma' ), f=1 )
        
        # create cone file
        print "cone file"
        pm.newFile(f=1)
        pm.polyCone()
        pm.createReference( self.cubeFile, namespace='cubeInCone' )
        pm.PyNode('cubeInCone:pCube1').attr('translateZ').set(2)
        pm.PyNode('cubeInCone:sphere:pSphere1').attr('translateZ').set(2)
        self.coneFile = pm.saveAs( os.path.join( self.temp, 'cone.ma' ), f=1 )
        
        print "master file"
        pm.newFile(f=1)
        self.sphereRef1 = pm.createReference( self.sphereFile, namespace='sphere1' )
        pm.PyNode('sphere1:pSphere1').attr('translateY').set(2)
        self.sphereRef2 = pm.createReference( self.sphereFile, namespace='sphere2' )
        pm.PyNode('sphere2:pSphere1').attr('translateY').set(4)
        self.cubeRef1 = pm.createReference( self.cubeFile, namespace='cube1' )
        pm.PyNode('cube1:sphere:pSphere1').attr('translateY').set(6)
        pm.PyNode('cube1:pCube1').attr('translateY').set(6)
        self.coneRef1 = pm.createReference( self.coneFile, namespace='cone1' )
示例#4
0
    def setUp(self):
        print "getting temp dir"
        self.temp = os.path.join(tempfile.gettempdir(), 'referencesTest')
        if not os.path.isdir(self.temp):
            os.makedirs(self.temp)
        
        # create sphere file
        print "sphere file"
#        cmds.file(new=1, f=1)
        pm.newFile(f=1)
        sphere = pm.polySphere()
        # We will use this to test failed ref edits...
        pm.addAttr(sphere, ln='zombieAttr')
        self.sphereFile = pm.saveAs( os.path.join( self.temp, 'sphere.ma' ), f=1 )
        
        # create cube file
        print "cube file"
        pm.newFile(f=1)
        pm.polyCube()
        pm.createReference( self.sphereFile, namespace='sphere' )
        pm.PyNode('sphere:pSphere1').attr('translateX').set(2)
        self.cubeFile = pm.saveAs( os.path.join( self.temp, 'cube.ma' ), f=1 )
        
        # create cone file
        print "cone file"
        pm.newFile(f=1)
        pm.polyCone()
        pm.createReference( self.cubeFile, namespace='cubeInCone' )
        pm.PyNode('cubeInCone:pCube1').attr('translateZ').set(2)
        pm.PyNode('cubeInCone:sphere:pSphere1').attr('translateZ').set(2)
        self.coneFile = pm.saveAs( os.path.join( self.temp, 'cone.ma' ), f=1 )
        
        print "master file"
        pm.newFile(f=1)
        self.sphereRef1 = pm.createReference( self.sphereFile, namespace='sphere1' )
        pm.PyNode('sphere1:pSphere1').attr('translateY').set(2)
        self.sphereRef2 = pm.createReference( self.sphereFile, namespace='sphere2' )
        pm.PyNode('sphere2:pSphere1').attr('translateY').set(4)
        self.cubeRef1 = pm.createReference( self.cubeFile, namespace='cube1' )
        pm.PyNode('cube1:sphere:pSphere1').attr('translateY').set(6)
        pm.PyNode('cube1:pCube1').attr('translateY').set(6)
        self.coneRef1 = pm.createReference( self.coneFile, namespace='cone1' )
def randPrims(numPrims, maxSize, minX, maxX, minY, maxY, minZ, maxZ, minSize=0.1): 
	prims = []
	
	for m in range(numPrims):
	# roll a random whole number between 0 to 4:
		p = random.randrange(0,5)
		if p == 0:
	# roll a random number between 0 and max sizes for all parameters
			radiusSphere = random.uniform(minSize, maxSize)
			x = random.uniform(minX, maxX)
			y = random.uniform(minY, maxY)
			z = random.uniform(minZ, maxZ)
			# store the object in a variable temporarily so it's easier to append it to the list
			n = pm.polySphere(r=radiusSphere)[0]
			pm.move(n, x, y, z)
			prims.append(n) 
		# create elif statements in case we roll 1, 2, 3 or 4
		elif p == 1:
			volCube = random.uniform(minSize, maxSize)
			x = random.uniform(minX, maxX)
			y = random.uniform(minY, maxY)
			z = random.uniform(minZ, maxZ)
			n = pm.polyCube(w=volCube, h=volCube, d=volCube)[0]
			pm.move(n, x, y, z)
			prims.append(n)
		elif p == 2:
			radiusCyl = random.uniform(minSize, maxSize)
			heightCyl = random.uniform(minSize, maxSize)
			x = random.uniform(minX, maxX)
			y = random.uniform(minY, maxY)
			z = random.uniform(minZ, maxZ)
			n = pm.polyCylinder(h=heightCyl, r=radiusCyl)[0]
			pm.move(n, x, y, z)
			prims.append(n)
		elif p == 3:
			radiusCone = random.uniform(minSize, maxSize)
			heightCone = random.uniform(minSize, maxSize)
			x = random.uniform(minX, maxX)
			y = random.uniform(minY, maxY)
			z = random.uniform(minZ, maxZ)
			n = pm.polyCone(h=heightCone, r=radiusCone)[0]
			pm.move(n, x, y, z)
			prims.append(n)
		elif p == 4:
			widthPlane = random.uniform(minSize, maxSize)
			heightPlane = random.uniform(minSize, maxSize)
			x = random.uniform(minX, maxX)
			y = random.uniform(minY, maxY)
			z = random.uniform(minZ, maxZ)
			n = pm.polyPlane(h=heightPlane, w=widthPlane)[0]
			pm.move(n, x, y, z)
			prims.append(n)
			
	return prims
示例#6
0
def vecVizPoint(startPoint, endPoint, name="vecViz"):
    '''
    Crates cone represenatation of vector between start and endpoint

    Args:
        vector:
        tfm:
        name:

    Returns:

    '''
    """Visual aid for Vectors"""

    startVec = om.MVector(startPoint[0], startPoint[1], startPoint[2])
    endVec = om.MVector(endPoint[0], endPoint[1], endPoint[2])
    vec = endVec - startVec

    _logger.debug('vec length is %s'%vec.length())


    grp = pm.group(em=True)
    loc = pm.spaceLocator()

    #cone for visulization
    height = vec.length()
    #pivot of cone is in center. for nicer look we shift it to base
    pointer = pm.polyCone(name=name, sx=4, r=0.25, h=height)[0]
    pm.xform(pointer,  piv=(0,(-1*height/2),0), t=(0,(height/2),0),ro=(0,0,-90), os=1)
    pm.makeIdentity(pointer, a=1)


    #move locator to vector and cone to tfm
    loc.setTranslation(endPoint)
    pointer.setTranslation(startPoint)

    #aim constrain cone to look at locator
    pm.delete(pm.aimConstraint(loc,pointer,aimVector=(1,0,0), mo=0))

    # clean up
    pm.delete(loc)

    return pointer
示例#7
0
def vecViz(vector, startTranform=[0,0,0], name="vecViz"):
    '''
    Crates cone represenatation of vector between start and endpoint

    Args:
        vector:
        tfm:
        name:

    Returns:

    '''
    """Visual aid for Vectors"""
    startPoint = om.MVector(startTranform[0], startTranform[1], startTranform[2])
    endPoint = vector
    vec = vector


    loc = pm.spaceLocator(n=name)

    #cone for visulization
    height = vec.length()
    #pivot of cone is in center. for nicer look we shift it to base
    pointer = pm.polyCone(name=name+'_pointer', sx=4, r=0.25, h=height)[0]
    pm.xform(pointer,  piv=(0,(-1*height/2),0), t=(0,(height/2),0),ro=(0,0,-90), os=1)
    pm.makeIdentity(pointer, a=1)


    #move locator to vector and cone to tfm
    loc.setTranslation(endPoint)


    #aim constrain cone to look at locator
    pm.delete(pm.aimConstraint(loc,pointer,aimVector=(1,0,0), mo=0))

    # clean up
    pm.parent(loc,pointer)
    pointer.setTranslation(startPoint)

    return pointer
示例#8
0
def create_shapes(*args):
    print('This will create shapes')
    num = slider1.getValue()
    print('Number of shapes to be created:', num)

    i = 0
    while i < num:
        value = float(i) / num
        angle = random.randint(0, 359)
        radius = random.uniform(0.5, 2)
        height = random.uniform(0.5, 1)
        x, y, z = pm.pointOnCurve('curve1', pr=value, turnOnPercentage=True)

        x1 = random.uniform(x - 3, x + 3)
        y1 = random.uniform(y - 3, y + 3)
        z1 = random.uniform(z - 3, z + 3)

        shape = options.getValueArray4()
        j = random.randint(0, 3)
        if shape[j] == True:
            if j == 0:
                figure = pm.polyTorus(r=radius, sr=0.25)
                pm.move(x1, y1, z1, figure)
                i += 1
            elif j == 1:
                figure = pm.polyCone(sx=1, sy=1.5, sz=0.5, r=radius, h=height)
                pm.move(x1, y1, z1, figure)
                i += 1
            elif j == 2:
                figure = pm.polySphere(r=radius)
                pm.move(x1, y1, z1, figure)
                i += 1
            elif j == 3:
                figure = pm.polyCylinder(r=radius, h=height)
                pm.move(x1, y1, z1, figure)
                i += 1
            pm.select(figure)
            pm.rotate(angle, 0, 0, r=True)
            pm.select(clear=True)
示例#9
0
    def _create_instance_cones(self, instance_name):
        self._assert_prequisites_completed(instance_name, "cones")

        xz_angle_step_rad = (2 * np.pi) / self.cones_to_complete_circle
        for i in range(self.cones_num):
            # try omitting cone
            spawn_chance = (i / float(self.cones_num)) * random.uniform(
                0.9, 0.99)
            should_drop = random.random() < spawn_chance
            if should_drop:
                continue
            cone_name = "cone_%d" % i
            # random radius & ratio
            height = random.uniform(self.min_height, self.max_height)
            radius = random.uniform(self.min_radius, self.max_radius)

            # position & rotation
            cone_height = i * self.height_step
            xz_index = i % self.cones_to_complete_circle
            xz_angle = xz_index * xz_angle_step_rad

            x = math.sin(xz_angle) * (self.pole_radius + height / 5.0)
            z = math.cos(xz_angle) * (self.pole_radius + height / 5.0)
            y = cone_height + (random.random() - 0.5) * 2.0
            y_rot = angle_vect2d([x, z])

            # spawn cone and move/rotate
            cone = pm.polyCone(constructionHistory=True,
                               radius=radius,
                               height=height,
                               sx=12,
                               sy=2,
                               name=cone_name)

            pm.move(cone_name, [x, y, z])
            pm.rotate(cone_name, [90, y_rot, 0])
        self._mark_stage_completed(instance_name, "cones")
示例#10
0
 def setUp(self):
     cmds.file(new=1, f=1)
     self.sphere = pm.polySphere()[0]
     self.cube = pm.polyCube()[0]
     self.cone = pm.polyCone()[0]