Ejemplo n.º 1
0
 def toggle(self, *args):
     """
     Toggles the how to use UI
     """
     if not cmds.window(self._window, exists=True):
         self._buildUi()
         self._changeInfo()
     cmds.toggleWindowVisibility(self._window)
def importTextures():
    global vars
    
    path = cmds.textField(vars['path'], q=1, tx=1)
    meshSuffix = vars['meshSuffix']
    mapPrefix = cmds.textField(vars['mapPrefix'], q=1, tx=1)
    mapSuffix = cmds.textField(vars['mapSuffix'], q=1, tx=1)
    imageType = cmds.textField(vars['imageType'], q=1, tx=1)
    
    maps = {}
    for mp in vars['maps']:
        en = cmds.checkBox(vars['maps'][mp]['Enabled'], q=1, v=1)
        id = cmds.textField(vars['maps'][mp]['ID'], q=1, tx=1)
        maps[mp] = {'Enabled': en, 'ID': id}
        #print maps[mp]
    
    missingTextures = []

    meshList = {False: cmds.listRelatives(cmds.ls(g=True), p=True, pa=True), True: cmds.ls(sl = True)}[cmds.radioButton(vars["target"]["Selected"], q=1, sl=1)]
    
    window = cmds.window()
    cmds.columnLayout()
    progressControl = cmds.progressBar(maxValue=len(meshList), width=300)
    cmds.showWindow(window) 

    for mesh in meshList:

        mesh = {0: mesh}.get(len(meshSuffix), mesh[:-len(meshSuffix)]) # remove suffix if applicable
        material = mesh + "_Mtl" #create a material for selected mesh
        print '============================================================'
        print 'Creating material: ' + material + '...'
        print '============================================================'
        cmds.shadingNode('aiStandardSurface', asShader=True, name=material) #plus a shading node
        cmds.sets(renderable=True,  noSurfaceShader=True, empty=True, name= material + "_SG")
        cmds.connectAttr(material + '.outColor', material + '_SG.surfaceShader', force=True)
        cmds.select(mesh)
        cmds.hyperShade(assign=material)

        print " "
        
        if maps['Color']['Enabled']:
            textureFile = path + mapPrefix + mesh + mapSuffix + maps['Color']['ID'] + "." + imageType
            if cmds.file( textureFile, q=True, ex=True ):
                connectMap(textureFile, material, 'Color')
            else:
                missingTextures.append(textureFile)
        if maps['Metalness']['Enabled']:
            textureFile = path + mapPrefix + mesh + mapSuffix + maps['Metalness']['ID'] + "." + imageType        
            if cmds.file( textureFile, q=True, ex=True ):
                connectMap(path + mapPrefix + mesh + mapSuffix + maps['Metalness']['ID'] + "." + imageType, material, 'Metalness')
            else:
                missingTextures.append(textureFile)
        if maps['Specular']['Enabled']:
            textureFile = path + mapPrefix + mesh + mapSuffix + maps['Specular']['ID'] + "." + imageType
            if cmds.file( textureFile, q=True, ex=True ):
                connectMap(path + mapPrefix + mesh + mapSuffix + maps['Specular']['ID'] + "." + imageType, material, 'Specular')
            else:
                missingTextures.append(textureFile)
        if maps['Normal']['Enabled']:
            textureFile = path + mapPrefix + mesh + mapSuffix + maps['Normal']['ID'] + "." + imageType
            if cmds.file( textureFile, q=True, ex=True ):
                connectMap(path + mapPrefix + mesh + mapSuffix + maps['Normal']['ID'] + "." + imageType, material, 'Normal')
            else:
                missingTextures.append(textureFile)

        cmds.progressBar(progressControl, edit=True, step=1)

    cmds.progressBar(progressControl, edit=True, step=1)
    cmds.refresh()
    cmds.toggleWindowVisibility(window)
    
    msg=""
   
    if len(missingTextures)!=0:
        msg = msg + missingTextures[0] + '\n'
        for mt in missingTextures[1:]:
            msg = msg + mt + '\n'
        displayMissing(msg)
Ejemplo n.º 3
0
def run(max_iteration, size, c):
    """
	Generates a visualization of the Julia set by printing cubes in space in Maya
	Parameters:
		max_Iteration - maximum number of cubes to print 
		size - the size of our printing canvas
		c - constant complex variable of the formula z = z*z + c, which affects the result
	"""
    # Initialize scene
    cmds.file(new=True, force=True)
    cmds.lookThru('top')
    cmds.grid(toggle=False)

    # Setup window for progress bar
    window = cmds.window()
    cmds.columnLayout()
    progressControl = cmds.progressBar(maxValue=size**2, width=300)
    cmds.showWindow(window)

    # Create shades of grey to paint cubes with based on depth
    for i in range(max_iteration + 1):
        shader = cmds.shadingNode("blinn",
                                  asShader=True,
                                  name="shader" + str(i))
        attr = shader + ".color"
        cmds.setAttr(attr, i / float(max_iteration), i / float(max_iteration),
                     i / float(max_iteration))

    # Specify real and imaginary range of image
    re_min, re_max = -2.0, 2.0
    im_min, im_max = -2.0, 2.0
    scX = (abs(re_min) + abs(re_max)) / size
    scZ = (abs(im_min) + abs(im_max)) / size

    # Generate evenly spaced values over real and imaginary ranges
    real_range = numpy.arange(re_min, re_max, (re_max - re_min) / size)
    imag_range = numpy.arange(im_max, im_min, (im_min - im_max) / size)

    # Run through the grid of our canvas size (size X size)
    for im in imag_range:
        for re in real_range:
            # Initialize z (according to complex plane) and number of iterations
            z = complex(re, im)
            iteration = 0

            # While z is within our space boundaries and we have not exceeded our maximum iteration:
            while abs(z) < 10 and iteration < max_iteration:
                z = z * z + c
                iteration += 1

            # Draw appropriate cube in space
            cmds.polyCube(n="cube" + str(im) + str(re))
            cmds.move(im, 0, re)
            cmds.scale(scX, 0.1, scZ)
            cmds.hyperShade(assign="shader" + str(iteration))

            # Update progress bar and viewport
            cmds.progressBar(progressControl, edit=True, step=1)
            cmds.viewFit('top', all=True)
            cmds.dolly('top', os=1.5)
            cmds.refresh()

    # Update progress bar and viewport
    cmds.progressBar(progressControl, edit=True, step=1)
    cmds.refresh()
    cmds.toggleWindowVisibility(window)
def run(max_iteration, size, c):
    """
	Generates a visualization of the Mandelbrot set by printing cubes in space in Maya
	Parameters:
		max_Iteration - maximum number of cubes to print 
		size - the size of our printing canvas
		c - complex variable of the formula z = z*z + c, which affects the result
	"""
    # Initialize scene
    cmds.file(new=True, force=True)
    cmds.lookThru('top')
    cmds.grid(toggle=False)

    # Setup window for progress bar
    window = cmds.window()
    cmds.columnLayout()
    progressControl = cmds.progressBar(maxValue=size**2, width=300)
    cmds.showWindow(window)

    # Create shades of grey to paint cubes with based on depth
    for i in range(max_iteration + 1):
        shader = cmds.shadingNode("blinn",
                                  asShader=True,
                                  name="shader" + str(i))
        attr = shader + ".color"
        cmds.setAttr(attr, i / float(max_iteration), i / float(max_iteration),
                     i / float(max_iteration))

    # Set center of complex plane
    x_center = c.real
    y_center = c.imag
    # Run through the grid of our canvas size (size X size)
    for i in range(size):
        for j in range(size):
            # Re-evaluate c according to current 'pixel' to be drawn
            c = complex(x_center + 4.0 * float(i - size / 2) / size,
                        y_center + 4.0 * float(j - size / 2) / size)

            # Initialize z and number of iterations
            z = 0 + 0j
            iteration = 0

            # While z is within our space boundaries and we have not exceeded our maximum iteration:
            while (abs(z) <= 2.0 and iteration < max_iteration):
                z = z**2 + c  # Re-evaluate z, based on formula z = z*z + c
                iteration += 1

            # Draw appropriate cube in space
            cmds.polyCube(n="cube" + str(i) + str(j))
            cmds.move(i, 0, j)
            cmds.hyperShade(assign="shader" + str(iteration))

            # Update progress bar and viewport
            cmds.progressBar(progressControl, edit=True, step=1)
            cmds.viewFit('top', all=True)
            cmds.dolly('top', os=1.5)
            cmds.refresh()
    # Update progress bar and viewport
    cmds.progressBar(progressControl, edit=True, step=1)
    cmds.refresh()
    cmds.toggleWindowVisibility(window)
def sphereWinVis(*args):
    cmds.toggleWindowVisibility("Sphere")
    cmds.toggleWindowVisibility("Create_Geometirc_Primitive_Objects")
def cubeWindow(*args):
    cmds.showWindow("Cube")
    cmds.toggleWindowVisibility("Create_Geometirc_Primitive_Objects")
def run(max_Iteration, size):
	"""
	Generates a visualization of the Barnsley Fern by printing spheres in space in Maya
	Parameters:
		max_Iteration - maximum number of cubes to print 
		size - the size of our printing canvas
	"""
	# Initialize scene
	cmds.file(new = True, force = True)
	cmds.lookThru( 'top' )
	cmds.grid(toggle=False)
	
	# Setup window for progress bar
	window = cmds.window()
	cmds.columnLayout()
	progressControl = cmds.progressBar(maxValue=max_Iteration, width=300)
	cmds.showWindow(window)
	
	# Create shader to paint spheres with
	shader=cmds.shadingNode("blinn",asShader=True, name = "shader" + str(1))
	attr = shader + ".color"
	cmds.setAttr (attr, 1,1,1)
	
	# Setup matrix A containing appropriate affine transformations
	A=[]
	mat=[[0.0,0.0,0.0,0.16,0.0,0.0,0.01],
		[0.85,0.04,-0.04,0.85,0.0,1.6,0.85],
		[0.2,-0.26,0.23,0.22,0.0,1.6,0.07],
		[-0.15,0.28,0.26,0.24,0.0,0.44,0.07]]
	# Set starting point (x,y) = (0,0)
	x=0.0
	y=0.0
	
	# Draw max_Iteration number of spheres
	for iteration in range(max_Iteration):
		# Select random transformation to compute
		p=random.random()
		if p <= mat[0][6]:
			i=0
		elif p <= mat[0][6] + mat[1][6]:
			i=1
		elif p <= mat[0][6] + mat[1][6] + mat[2][6]:
			i=2
		else:
			i=3
		# Compute above transformation:
		x0 = x * mat[i][0] + y * mat[i][1] + mat[i][4]
		y  = x * mat[i][2] + y * mat[i][3] + mat[i][5]
		x = x0
		
		# Draw corresponding sphere in space
		cmds.polySphere(n="sp"+str(iteration))
		cmds.move(size*x,0,-size*y)
		cmds.scale(0.5,0.5,0.5)  
		cmds.hyperShade(assign="shader"+str(1))
		
		# Update progress bar and viewport
		cmds.progressBar(progressControl, edit=True, step=1)
		cmds.viewFit( 'top', all=True )
		cmds.dolly( 'top', os=1.5 )
		cmds.refresh()
		
	# Update progress bar and viewport
	cmds.progressBar(progressControl, edit=True, step=1)
	cmds.refresh()
	cmds.toggleWindowVisibility(window)
def run(max_Iteration, size):
    """
	Generates a visualization of a region of the Apollonean Gasket by printing spheres in space in Maya
	Parameters:
		max_Iteration - maximum number of cubes to print 
		size - the size of our printing canvas
	"""
    # Initialize scene
    cmds.file(new=True, force=True)
    cmds.lookThru('top')
    cmds.grid(toggle=False)

    # Setup window for progress bar
    window = cmds.window()
    cmds.columnLayout()
    progressControl = cmds.progressBar(maxValue=max_Iteration, width=300)
    cmds.showWindow(window)

    # Initialize fractal variables
    s = math.sqrt(3.0)

    def f(z):
        return 3.0 / (1.0 + s - z) - (1.0 + s) / (2.0 + s)

    ifs = [
        "f(z)", "f(z) * complex(-1.0, s) / 2.0",
        "f(z) * complex(-1.0, -s) / 2.0"
    ]
    xa = -0.6
    xb = 0.9
    ya = -0.75
    yb = 0.75
    z = complex(0.0, 0.0)

    # Create shader to paint spheres with
    shader = cmds.shadingNode("blinn", asShader=True, name="shader" + str(1))
    attr = shader + ".color"
    cmds.setAttr(attr, 1, 1, 1)

    # Draw max_Iteration number of spheres
    for i in range(max_Iteration):
        # Compute z and kx, ky
        z = eval(ifs[random.randint(0, 2)])
        kx = int((z.real - xa) / (xb - xa) * (size - 1))
        ky = int((z.imag - ya) / (yb - ya) * (size - 1))
        # Update progress bar
        cmds.progressBar(progressControl, edit=True, step=1)
        # If kx and kz are within our drawing canvas draw sphere:
        if kx >= 0 and kx < size and ky >= 0 and ky < size:
            cmds.polySphere(n="sp" + str(i))
            cmds.move(kx, 0, ky)
            cmds.scale(0.5, 0.5, 0.5)
            cmds.hyperShade(assign="shader" + str(1))

            # Update viewport
            cmds.viewFit('top', all=True)
            cmds.dolly('top', os=1.5)
            cmds.refresh()

    # Update progress bar and viewport
    cmds.progressBar(progressControl, edit=True, step=1)
    cmds.refresh()
    cmds.toggleWindowVisibility(window)
Ejemplo n.º 9
0
def run(max_Iteration, size):
    """
	Generates a visualization of the Sierpinski triangle by printing cubes in space in Maya
	Parameters:
		max_Iteration - maximum number of cubes to print 
		size - the size of our printing canvas
	"""
    # Initialize scene
    cmds.file(new=True, force=True)
    cmds.lookThru('top')
    cmds.grid(toggle=False)

    # Setup window for progress bar
    window = cmds.window()
    cmds.columnLayout()
    progressControl = cmds.progressBar(maxValue=max_Iteration, width=300)
    cmds.showWindow(window)

    # Create shader to paint spheres with
    shader = cmds.shadingNode("blinn", asShader=True, name="shader" + str(1))
    attr = shader + ".color"
    cmds.setAttr(attr, 1, 1, 1)

    # Calculates the midpoint of point1 and point2 and returns result
    def midpoint(point1, point2):
        return [(point1[0] + point2[0]) / 2, (point1[1] + point2[1]) / 2]

    # Set starting point for Sierpinski algorithm
    curr_point = [0, 0]

    # Define an equilateral triangle in space
    v1 = [0, 0]
    v2 = [1, 0]
    v3 = [.5, np.sqrt(3) / 2]

    # Draw max_Iteration number of spheres
    for i in range(max_Iteration):
        val = randint(0, 2)  # Select random vertex of our equilateral triangle
        # Calculate midpoint of above vertex and our current point:
        if val == 0:
            curr_point = midpoint(curr_point, v1)
        if val == 1:
            curr_point = midpoint(curr_point, v2)
        if val == 2:
            curr_point = midpoint(curr_point, v3)

        # Draw corresponding sphere in space
        cmds.polySphere(n="sp" + str(i))
        cmds.move(size * curr_point[0], 0, size * curr_point[1])
        cmds.scale(0.5, 0.5, 0.5)
        cmds.hyperShade(assign="shader" + str(1))

        # Update progress bar and viewport
        cmds.progressBar(progressControl, edit=True, step=1)
        cmds.viewFit('top', all=True)
        cmds.dolly('top', os=1.5)
        cmds.refresh()
    # Update progress bar and viewport
    cmds.progressBar(progressControl, edit=True, step=1)
    cmds.refresh()
    cmds.toggleWindowVisibility(window)
import maya.cmds as cmds
from P_maya_c7_poseMgr import *

# create an instance
pwin = AR_PoseManagerWindow()
# create the window
pwin.create()
# toggle the visibility of the window (self.window) here when using docking
cmds.toggleWindowVisibility(pwin.window)
# add a pane for docking
layout1 = cmds.paneLayout(configuration='single')
# add dockControl
dock = cmds.dockControl(label=pwin.title, width=pwin.size[0], allowedArea='all', area='right', floating=False, content=layout1)
cmds.control(pwin.window, edit=True, parent=layout1)