Exemple #1
0
 def runFlakeGen(self,state):
     '''
     Executes the code to generate snowflakes and starts the progress window using the variables defined in snowflakeUI.flakeGenUI and starts the progress window
     '''
     cmds.progressWindow(title='SnowFX',
                                   progress=0,
                                   status='Starting up...')
     try:
         particles=makeSnowflakes.makeSnowflakes(cmds.intField(self.flakeNumber,v=1,q=1),
                                                                   cmds.floatField(self.flakeRadius,v=1,q=1),
                                                                   cmds.intField(self.flakeRadiusVar,v=1,q=1),
                                                                   cmds.canvas(self.colour1,rgb=1,q=1),
                                                                   cmds.canvas(self.colour2,rgb=1,q=1),
                                                                   cmds.floatField(self.transparency,v=1,q=1),
                                                                   cmds.floatField(self.glow,v=1,q=1))
         for i in range(0,len(particles)):
             cmds.move(0,0,cmds.floatField(self.flakeRadius,v=1,q=1)*2*i,particles[i])
         group = cmds.group(em=1,n='snowFX')
         for x in particles:
             cmds.parent(x,group)
         cmds.progressWindow(ep=1)
     except Exception, err:
         sys.stderr.write('ERROR: %s\n' % str(err))
         cmds.progressWindow(ep=1)
         errorPopup('Something went wrong :( \n Check the script editor for detials')
Exemple #2
0
 def updateColorTemperature(self, *args, **kwargs):
     try:
         temperature = cmds.getAttr(self.nodeAttr('aiColorTemperature'))
         colorTemp = cmds.arnoldTemperatureToColor(temperature)
         cmds.canvas(self.canvasName, edit=True, rgbValue=colorTemp)
     except:
         pass
Exemple #3
0
    def createPreviewLayout(self):

        print("ML Log: createPreviewLayout")
        # Create tab layout.
        tabLayout = cmds.tabLayout(borderStyle="full")

        # Add horizontal and vertical flow layouts and
        # spacers to center the image in the preview area.
        flowLayout = cmds.flowLayout("RPRPreviewArea")
        cmds.canvas("RPRHSpacer", width=1, height=1)

        cmds.flowLayout("RPRPreviewFlow", vertical=True)
        cmds.canvas("RPRVSpacer", width=1, height=1)

        cmds.iconTextStaticLabel("RPRPreviewImage",
                                 style='iconOnly',
                                 width=1,
                                 height=1)
        cmds.setParent('..')

        cmds.setParent('..')
        cmds.setParent('..')
        cmds.setParent('..')

        # Assign the top flow layout to the tab.
        cmds.tabLayout(tabLayout,
                       edit=True,
                       tabLabel=((flowLayout, 'Preview')))
Exemple #4
0
 def updateColorTemperature(self, *args, **kwargs):
     try:
         temperature = cmds.getAttr(self.nodeAttr('aiColorTemperature'))
         colorTemp = cmds.arnoldTemperatureToColor(temperature)
         cmds.canvas(self.canvasName, edit=True, rgbValue=colorTemp)
     except:
         pass
Exemple #5
0
 def createLightColorTemperatureUI(self, attrName):
     cmds.setUITemplate('attributeEditorPresetsTemplate', pushTemplate=True)
     isEnabled = True
     isEnabled = cmds.getAttr(self.nodeAttr('aiUseColorTemperature'))
     aeUtils.attrBoolControlGrp(
         self.checkBoxName,
         attribute=self.nodeAttr('aiUseColorTemperature'),
         label='Use Color Temperature',
         changeCommand=self.updateUseColorTemperature)
     cmds.setParent('..')
     cmds.rowLayout(numberOfColumns=2,
                    columnWidth2=(80, 220),
                    adjustableColumn=2,
                    columnAttach=[(1, 'left', 0), (2, 'left', -10)])
     cmds.canvas(self.canvasName, width=65, height=12)
     cmds.attrFieldSliderGrp(self.sliderName,
                             label='Temperature',
                             width=220,
                             attribute=self.nodeAttr('aiColorTemperature'),
                             enable=isEnabled,
                             precision=0,
                             columnWidth=[(1, 70), (2, 70), (3, 80)],
                             changeCommand=self.updateColorTemperature)
     cmds.setParent('..')
     colorTemp = cmds.arnoldTemperatureToColor(
         cmds.getAttr(self.nodeAttr('aiColorTemperature')))
     cmds.canvas(self.canvasName, edit=True, rgbValue=colorTemp)
     cmds.setUITemplate(popTemplate=True)
Exemple #6
0
def colorPicker(light, index, *args):
	sel_light = cmds.listRelatives(cmds.textField(light + 'name', q=True, tx=True), s=True)[0]
	currColor = cmds.getAttr(sel_light + '.color')
	cmds.colorEditor(rgbValue=currColor[0])
	if cmds.colorEditor(query=True, result=True):
		values = cmds.colorEditor(query=True, rgb=True)
		cmds.setAttr(sel_light + '.color', *values)
		cmds.canvas(swatches[index], e=True, rgbValue=cmds.getAttr(sel_light + '.color')[0])
Exemple #7
0
 def updateLightColorTemperatureUI(self, attrName):
     isEnabled = True
     isEnabled = cmds.getAttr(self.nodeAttr('aiUseColorTemperature'))
     aeUtils.attrBoolControlGrp(self.checkBoxName, edit=True, attribute=self.nodeAttr('aiUseColorTemperature'), 
                                changeCommand=self.updateUseColorTemperature)
     cmds.attrFieldSliderGrp(self.sliderName, edit=True, 
                             attribute=self.nodeAttr('aiColorTemperature'), enable=isEnabled,
                             changeCommand=self.updateColorTemperature)
     colorTemp = cmds.arnoldTemperatureToColor(cmds.getAttr(self.nodeAttr('aiColorTemperature')))
     cmds.canvas(self.canvasName, edit=True, rgbValue=colorTemp)
Exemple #8
0
 def _editColor(self):
     color = utility.LineartosRGB(
         cmds.canvas('colorDisplay', q=1, rgbValue=1))
     cmds.colorEditor(rgb=color)
     if cmds.colorEditor(query=True, result=True):
         rgbV = cmds.colorEditor(query=True, rgb=True)
         rgbV = utility.sRGBtoLinear(rgbV)
         cmds.canvas('colorDisplay', e=1, rgbValue=rgbV)
         functions.applyCurvesColor(utility.LineartosRGB(rgbV))
     else:
         print('Editor was dismissed')
def valueChange2(args):
    '''
    Updates the canvas colours for the end of the colour range when the value
    is changed.
    
    args: Dummy argument needed to satisfy the command interface.
    On exit: The value canvas has been updated
    to reflect the change in value.
    '''
    newValue = cmds.floatSliderGrp("value2", query = True, value = True)
    cur = cmds.canvas("valueCanvas2", query = True, hsvValue = True)    
    cmds.canvas("valueCanvas2", edit = True, hsvValue = (cur[0]*360, cur[1],newValue))
Exemple #10
0
    def showColorEditor(self, *args):

        rgbaColor = cmds.colorEditor()

        test = rgbaColor.split("  ")
        color_R = test[0]
        color_G = test[1]
        color_B = test[2].partition(" ")[0]

        cmds.canvas(self.widgets["swatch"],
                    edit=1,
                    rgbValue=(float(color_R), float(color_G), float(color_B)))
Exemple #11
0
def saturationChange2(args):
    '''
    Updates the canvas colours for the end of the colour range when the
    saturation is changed.
    
    args: Dummy argument needed to satisfy the command interface.  
    On exit: The saturation and value canvases have been updated
    to reflect the change in saturation.
    '''
    newSaturation = cmds.floatSliderGrp("saturation2", query = True, value = True)
    cur = cmds.canvas("valueCanvas2", query = True, hsvValue = True)
    cmds.canvas("saturationCanvas2", edit = True, hsvValue = (cur[0]*360, newSaturation,1))    
    cmds.canvas("valueCanvas2", edit = True, hsvValue = (cur[0]*360, newSaturation,cur[2]))    
Exemple #12
0
def color_picker(light, index, *args):
    """brings up the color picker UI to select a color for a light"""
    sel_light = cmds.listRelatives(cmds.textField(light + 'name',
                                                  q=True,
                                                  tx=True),
                                   s=True)[0]
    curr_color = cmds.getAttr(sel_light + '.color')
    cmds.colorEditor(rgbValue=curr_color[0])
    if cmds.colorEditor(query=True, result=True):
        values = cmds.colorEditor(query=True, rgb=True)
        cmds.setAttr(sel_light + '.color', *values)
        cmds.canvas(swatches[index],
                    e=True,
                    rgbValue=cmds.getAttr(sel_light + '.color')[0])
Exemple #13
0
 def updateLightColorTemperatureUI(self, attrName):
     isEnabled = True
     isEnabled = cmds.getAttr(self.nodeAttr('aiUseColorTemperature'))
     aeUtils.attrBoolControlGrp(
         self.checkBoxName,
         edit=True,
         attribute=self.nodeAttr('aiUseColorTemperature'),
         changeCommand=self.updateUseColorTemperature)
     cmds.attrFieldSliderGrp(self.sliderName,
                             edit=True,
                             attribute=self.nodeAttr('aiColorTemperature'),
                             enable=isEnabled,
                             changeCommand=self.updateColorTemperature)
     colorTemp = cmds.arnoldTemperatureToColor(
         cmds.getAttr(self.nodeAttr('aiColorTemperature')))
     cmds.canvas(self.canvasName, edit=True, rgbValue=colorTemp)
Exemple #14
0
 def createLightColorTemperatureUI(self, attrName):
     cmds.setUITemplate('attributeEditorPresetsTemplate', pushTemplate=True)
     isEnabled = True
     isEnabled = cmds.getAttr(self.nodeAttr('aiUseColorTemperature'))
     aeUtils.attrBoolControlGrp(self.checkBoxName, attribute=self.nodeAttr('aiUseColorTemperature'),
                                label='Use Color Temperature', changeCommand=self.updateUseColorTemperature)
     cmds.setParent('..')        
     cmds.rowLayout(numberOfColumns=2, columnWidth2=(80,220), adjustableColumn=2, columnAttach=[(1, 'left', 0), (2, 'left', -10)])
     cmds.canvas(self.canvasName, width=65, height=12)
     cmds.attrFieldSliderGrp(self.sliderName, label='Temperature', width=220, 
                             attribute=self.nodeAttr('aiColorTemperature'),
                             enable=isEnabled,
                             precision=0, columnWidth=[(1, 70), (2, 70), (3, 80)], changeCommand=self.updateColorTemperature)
     cmds.setParent('..')
     colorTemp = cmds.arnoldTemperatureToColor(cmds.getAttr(self.nodeAttr('aiColorTemperature')))
     cmds.canvas(self.canvasName, edit=True, rgbValue=colorTemp)
     cmds.setUITemplate(popTemplate=True)
Exemple #15
0
    def set_aiColorTemperature(self):
        print(self.tempertaure)
        temperature = cmds.intSliderGrp(self.tempertaure, q=True, value=True)
        colorTemp = cmds.arnoldTemperatureToColor(temperature)
        displayColor = colorTemp
        if maya.mel.eval("exists \"colorManagementConvert\""):
            displayColor = cmds.colorManagementConvert(toDisplaySpace=colorTemp)

        displayColor[0] = min(max(displayColor[0], 0.0), 1.0)
        displayColor[1] = min(max(displayColor[1], 0.0), 1.0)
        displayColor[2] = min(max(displayColor[2], 0.0), 1.0)
        cmds.canvas(self.canvasName, edit=True, rgbValue=displayColor)
        for light in self.current_selected_lights:
            try:
                cmds.setAttr("%s.aiColorTemperature" % light, temperature)
            except:
                continue
    def createInfoLayout(self):

        # Create tab and form layouts.
        tabLayout = cmds.tabLayout(innerMarginWidth=8,
                                   innerMarginHeight=8,
                                   borderStyle="full")
        formLayout = cmds.formLayout(numberOfDivisions=100)
        importButton = cmds.button(label="Import",
                                   command=self.importSelectedMaterial)
        importImagesCheck = cmds.checkBox(
            "RPRImportImagesCheck",
            label="Import images to project",
            value=self.importImagesEnabled(),
            changeCommand=self.importImagesChanged)

        # Add the RPR logo.
        logoBackground = cmds.canvas("RPRLogoBackground", rgbValue=[0, 0, 0])
        logo = cmds.iconTextStaticLabel("RPRLogo",
                                        style='iconOnly',
                                        image="RadeonProRenderLogo.png",
                                        width=1,
                                        height=1)

        # Add material info text.
        columnLayout = cmds.columnLayout(rowSpacing=5)

        cmds.text(label="Category:", font="boldLabelFont")
        cmds.text("RPRCategoryText", recomputeSize=False)
        cmds.canvas(height=10)
        cmds.text(label="Name:", font="boldLabelFont")
        cmds.text("RPRNameText", recomputeSize=False)
        cmds.canvas(height=10)
        cmds.text(label="File name:", font="boldLabelFont")
        cmds.text("RPRFileNameText", recomputeSize=False)
        cmds.canvas(height=10)

        cmds.setParent('..')
        cmds.setParent('..')
        cmds.setParent('..')

        # Assign the form to the tab.
        cmds.tabLayout(tabLayout, edit=True, tabLabel=((formLayout, 'Info')))

        # Lay out components within the form.
        cmds.formLayout(formLayout,
                        edit=True,
                        attachControl=[(columnLayout, 'top', 10, logo),
                                       (importImagesCheck, 'bottom', 10,
                                        importButton)],
                        attachForm=[(logo, 'left', 8), (logo, 'right', 8),
                                    (logo, 'top', 8),
                                    (logoBackground, 'left', 8),
                                    (logoBackground, 'right', 8),
                                    (logoBackground, 'top', 8),
                                    (importButton, 'left', 10),
                                    (importButton, 'bottom', 10),
                                    (importButton, 'right', 10),
                                    (columnLayout, 'left', 10),
                                    (columnLayout, 'right', 10),
                                    (importImagesCheck, 'left', 10)])
	def definePointButtons(self):
		first = True


		for config in self.pointsMap :
			if not first:
				cmds.setParent("..")

			cmds.rowLayout(numberOfColumns=5)

			cmds.canvas(h=3,w=3,backgroundColor=self.pointsMap[config]["color"])
			cmds.separator(visible=0,w=2)
			self.definePointButton(config)
			cmds.separator(visible=0,w=5)
			#cmds.canvas(h=60,w=1,backgroundColor=self.pointsMap[config]["color"])
			self.defineStateButton(config)

			first = False
Exemple #18
0
 def flakeGenUI(self,state):
     '''
     Creates the UI containing options to generate snowflakes
     
     Initialises the following variables
     self.flakeNumber    : Number of snowflake particles to generate
     self.flakeRadius    : Average radius of snowflake particles
     self.flakeRadiusVar : Variation from average radius as a percentage
     self.colour1        : Canvas showing one end of the particle colour range
     self.colour2        : Canvas showing the other end of the particle colour range
     self.transparency   : Alpha value for the snowflake material
     self.glow           : Glow value for the snowflake material
     '''
     if state == 1:
         self.tmpFrame3 = cmds.rowColumnLayout(numberOfColumns=1,parent=self.snowFXOptionsFrame)
         cmds.frameLayout(label='Particles',cll=1)
         cmds.rowColumnLayout(numberOfColumns=2,cs=[(1,5),(2,5)],cw=[(1,350),(2,118)],cal=[(1,'right'),(2,'left')])
         
         cmds.text(label='Number of Snowflakes')
         self.flakeNumber = cmds.intField(minValue=0,width=60,v=10)
         cmds.text(label='Snowflake Radius')
         self.flakeRadius = cmds.floatField(minValue=0,width=60,pre=3,v=0.5)
         cmds.text(label='Snowflake Radius Variation (%)')
         self.flakeRadiusVar = cmds.intField(minValue=0,maxValue=100,width=60,v=20)
         cmds.text(label='Colour Range 1')
         self.colour1 = cmds.canvas( rgb=(0.82,0.87,0.94),width = 60,height=20,pc=self.updateColour1)
         cmds.text(label='Colour Range 2')
         self.colour2 = cmds.canvas( rgb=(0.83,0.82,0.92),width = 60,height=20,pc=self.updateColour2)
         cmds.text(label='Transparency')
         self.transparency = cmds.floatField(minValue=0,maxValue=1,width=60,pre=3,v=0.6)
         cmds.text(label='Glow Intensity')
         self.glow = cmds.floatField(minValue=0,maxValue=1,width=60,pre=3,v=0.15)
         cmds.setParent('..')
         cmds.setParent('..')
         
         cmds.button(label='Generate',width=100,c=self.runFlakeGen)
         cmds.setParent('..')
     else:
         cmds.deleteUI(self.tmpFrame3)
     return
Exemple #19
0
    def create(self):
        # destroy the window if it already exists
        try:
            pm.deleteUI(self.WINDOW_NAME, window=True)
        except:
            pass
        # draw the window
        with pm.window(self.WINDOW_NAME) as res_window:
            with pm.columnLayout(adjustableColumn=True):
                cmds.checkBox(label='Use Color Temperature', onCommand=pm.Callback(self.test, True),
                              offCommand=pm.Callback(self.test, False))
                self.canvasName = cmds.canvas(rgbValue=(1, 0, 1), width=100, height=20)
                self.tempertaure = cmds.intSliderGrp(field=True, label='Temperature', minValue=0, maxValue=15000,
                                                     fieldMinValue=1000,
                                                     fieldMaxValue=100000000376832, value=6500, enable=False,
                                                     changeCommand=pm.Callback(self.set_aiColorTemperature))
                pm.separator(style='in', height=4)
                self.exposure = cmds.floatSliderGrp(label='Exposure', field=True, minValue=-5.0, maxValue=5.0,
                                                    fieldMinValue=-100.0,
                                                    fieldMaxValue=100.0, value=5,
                                                    changeCommand=pm.Callback(self.set_float_attr, exposure=True))

                pm.separator(style='in', height=4)
                self.sample = cmds.intSliderGrp(field=True, label='Samples', minValue=0, maxValue=10,
                                                fieldMinValue=0,
                                                fieldMaxValue=20, value=1,
                                                changeCommand=pm.Callback(self.set_int_attr, sample=True))
                self.radius = cmds.floatSliderGrp(label='Radius', field=True, minValue=0, maxValue=10.0,
                                                  fieldMinValue=0,
                                                  fieldMaxValue=100.0, value=0,
                                                  changeCommand=pm.Callback(self.set_float_attr, radius=True))
                cmds.checkBox(label='Normalize',value=True, onCommand=pm.Callback(self.checkbox,"n",True),
                              offCommand=pm.Callback(self.checkbox,"n", False))

                pm.separator(style='in', height=4)
                cmds.checkBox(label='Cast Shadows',value=True, onCommand=pm.Callback(self.checkbox,"cs",True),
                              offCommand=pm.Callback(self.checkbox,"cs", False))
                self.shadow_density = cmds.floatSliderGrp(label='Shadow Density', field=True, minValue=0, maxValue=1,
                                    fieldMinValue=0, fieldMaxValue=1, value=1.0,
                                                          changeCommand=pm.Callback(self.set_float_attr, shadow_density=True))

                pm.separator(style='in', height=4)
                cmds.checkBox(label='Cast Volumetric Shadows',value=True, onCommand=pm.Callback(self.checkbox,"cvs",True),
                              offCommand=pm.Callback(self.checkbox,"cvs", False))
                self.volumeSamples = cmds.intSliderGrp(field=True, label='Volume Sample', minValue=0, maxValue=10,
                                                fieldMinValue=0,
                                                fieldMaxValue=20, value=2,changeCommand=pm.Callback(self.set_int_attr, volumeSamples=True))

                self.status_line = pm.textField(editable=False)
                cmds.button(label=u"刷新选择",command=pm.Callback(self.refresh))
                pm.text(label=u'此面板参数一经修改,就会影响所选灯光中含有对应属性的数值')
            res_window.setWidthHeight((500, 400))
Exemple #20
0
 def makeAllParticles(self):
     '''
     Generates all the required particles
     On End : Returns a list containing the names of all the particles
     '''
     shards=makeSnowflakes.makeShards(cmds.intField(self.shardNumber,v=1,q=1),
                                                       cmds.floatField(self.shardSize,v=1,q=1),
                                                       cmds.intField(self.shardSizeVar,v=1,q=1),
                                                       cmds.canvas(self.colour1,rgb=1,q=1),
                                                       cmds.canvas(self.colour2,rgb=1,q=1),
                                                       cmds.floatField(self.transparency,v=1,q=1),
                                                       cmds.floatField(self.glow,v=1,q=1))
     flakes=makeSnowflakes.makeSnowflakes(cmds.intField(self.flakeNumber,v=1,q=1)+1,
                                                            cmds.floatField(self.flakeRadius,v=1,q=1),
                                                            cmds.intField(self.flakeRadiusVar,v=1,q=1),
                                                            cmds.canvas(self.colour1,rgb=1,q=1),
                                                            cmds.canvas(self.colour2,rgb=1,q=1),
                                                            cmds.floatField(self.transparency,v=1,q=1),
                                                            cmds.floatField(self.glow,v=1,q=1))
     particles = flakes+shards
     cmds.delete(particles[0])
     particles=particles[1:]
     return particles
Exemple #21
0
def hueChange2(args):
    '''
    Updates the canvas colours for the end of the colour range when the hue
    is changed.
    
    args: Dummy argument needed to satisfy the command interface. 
    On exit: The hue, saturation and value canvases have been 
    updated to reflect the change in hue. 
    '''
    newHue = cmds.intSliderGrp("hue2", query = True, value = True)
    cur = cmds.canvas("valueCanvas2", query = True, hsvValue = True)
    cmds.canvas("hueCanvas2", edit = True, hsvValue = (newHue,1,1))
    cmds.canvas("saturationCanvas2", edit = True, hsvValue = (newHue, cur[1],1))    
    cmds.canvas("valueCanvas2", edit = True, hsvValue = (newHue, cur[1],cur[2]))    
Exemple #22
0
    def updatePreviewLayout(self):

        print("ML Log: updatePreviewLayout")
        # Determine the size of the preview area.
        width = cmds.flowLayout("RPRPreviewArea", query=True, width=True)
        height = cmds.flowLayout("RPRPreviewArea", query=True, height=True)

        # Choose the smallest dimension and shrink
        # slightly so the enclosing layouts can shrink.
        size = min(width, height) - 10

        # Calculate the horizontal and vertical
        # offsets required to center the preview image.
        hOffset = max(0, (width - size) / 2.0)
        vOffset = max(0, (height - size) / 2.0)

        # Clamp the size to a minimum of 64.
        newWidth = max(64, width - 10)
        newHeight = max(64, height - 10)
        size = max(64, size)

        # Update the layout and image sizes.
        cmds.flowLayout("RPRPreviewFlow",
                        edit=True,
                        width=newWidth,
                        height=newHeight)
        cmds.iconTextStaticLabel("RPRPreviewImage",
                                 edit=True,
                                 width=size,
                                 height=size)
        cmds.canvas("RPRHSpacer", edit=True, width=hOffset, height=1)
        cmds.canvas("RPRVSpacer", edit=True, width=1, height=vOffset)

        # Update the RPR logo size.
        logoWidth = cmds.iconTextStaticLabel("RPRLogo", query=True, width=True)
        logoHeight = max(min(logoWidth * 0.16, 60), 1)
        cmds.iconTextStaticLabel("RPRLogo", edit=True, height=logoHeight)
        cmds.canvas("RPRLogoBackground", edit=True, height=logoHeight)
Exemple #23
0
    def __init__(self):

        if cmds.window("presetUI", exists=True):
            cmds.deleteUI("presetUI")

        # class var

        self.widgets = {}

        self.widgets["window"] = cmds.window("presetUI",
                                             title="Preset",
                                             w=500,
                                             h=300,
                                             mxb=0,
                                             mnb=0,
                                             sizeable=0)

        self.widgets["mainLayout"] = cmds.columnLayout(w=500, h=300)

        self.widgets["menuBarLayout"] = cmds.menuBarLayout()
        cmds.menu(label='File')
        cmds.menuItem(label='Save Preset', c=partial(self.savePreset))
        cmds.menuItem(label='Load Preset', c=partial(self.loadPreset))

        self.widgets["formLayout"] = cmds.formLayout(w=500, h=300)

        # Create controls

        self.widgets["floatField"] = cmds.floatFieldGrp(numberOfFields=3,
                                                        label="Position",
                                                        value1=0.0,
                                                        value2=0.0,
                                                        value3=0.0)

        self.widgets["floatSlider"] = cmds.floatSliderGrp(label="Example",
                                                          field=True,
                                                          minValue=-10,
                                                          maxValue=10,
                                                          fieldMinValue=-10,
                                                          fieldMaxValue=10,
                                                          value=0)

        self.widgets["radioButtonGrp"] = cmds.radioButtonGrp(
            label="Radio Buttons",
            labelArray3=["Yes", "No", "Maybe"],
            numberOfRadioButtons=3)

        self.widgets["inputTextField"] = cmds.textField(w=300,
                                                        h=30,
                                                        text="Input Directory",
                                                        enable=False)
        self.widgets["outputTextField"] = cmds.textField(
            w=300, h=30, text="Output Directory", enable=False)

        self.widgets["inputDirectoryButton"] = cmds.button(w=30,
                                                           h=30,
                                                           label="...")
        cmds.button(self.widgets["inputDirectoryButton"],
                    edit=1,
                    c=partial(self.inputDirectory))
        self.widgets["outputDirectoryButton"] = cmds.button(w=30,
                                                            h=30,
                                                            label="...")
        cmds.button(self.widgets["outputDirectoryButton"],
                    edit=1,
                    c=partial(self.outputDirectory))

        self.widgets["swatch"] = cmds.canvas(rgbValue=(0, 0, 1), w=50, h=50)
        self.widgets["colorEditor"] = cmds.button(label="Color Editor",
                                                  w=100,
                                                  h=50)
        cmds.button(self.widgets["colorEditor"],
                    edit=1,
                    c=partial(self.showColorEditor))
        self.widgets["checkBox1"] = cmds.checkBox(label='Yes', value=0)
        self.widgets["checkBox2"] = cmds.checkBox(label='No', value=0)

        self.widgets["iconTextCheckBox1"] = cmds.iconTextCheckBox(
            style='iconOnly', image1='spotlight.png', w=40, h=40)
        self.widgets["iconTextCheckBox2"] = cmds.iconTextCheckBox(
            style='iconOnly', image1='sphere.png', w=40, h=40)
        self.widgets["iconTextCheckBox3"] = cmds.iconTextCheckBox(
            style='iconOnly', image1='cube.png', w=40, h=40)
        self.widgets["iconTextCheckBox4"] = cmds.iconTextCheckBox(
            style='iconOnly', image1='cone.png', w=40, h=40)
        self.widgets["iconTextCheckBox5"] = cmds.iconTextCheckBox(
            style='textOnly', label='Toggle', w=40, h=40)

        # Place controls

        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["floatField"], 'top', 10),
                            (self.widgets["floatField"], 'left', -50)])

        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["floatSlider"], 'top', 40),
                            (self.widgets["floatSlider"], "left", -50)])

        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["radioButtonGrp"], 'top', 70),
                            (self.widgets["radioButtonGrp"], 'left', -60)])
        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["inputTextField"], 'top', 100),
                            (self.widgets["inputTextField"], 'left', 5)])
        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["outputTextField"], 'top', 150),
                            (self.widgets["outputTextField"], 'left', 5)])

        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["inputDirectoryButton"], 'top', 100),
                            (self.widgets["inputDirectoryButton"], 'left', 325)
                            ])
        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["outputDirectoryButton"], 'top',
                             150),
                            (self.widgets["outputDirectoryButton"], 'left',
                             325)])

        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["swatch"], 'top', 200),
                            (self.widgets["swatch"], 'left', 20)])
        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["colorEditor"], 'top', 200),
                            (self.widgets["colorEditor"], 'left', 90)])
        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["checkBox1"], 'top', 218),
                            (self.widgets["checkBox1"], 'left', 230)])
        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["checkBox2"], 'top', 218),
                            (self.widgets["checkBox2"], 'left', 290)])

        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["iconTextCheckBox1"], 'top', 10),
                            (self.widgets["iconTextCheckBox1"], 'left', 400)])
        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["iconTextCheckBox2"], 'top', 60),
                            (self.widgets["iconTextCheckBox2"], 'left', 400)])
        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["iconTextCheckBox3"], 'top', 110),
                            (self.widgets["iconTextCheckBox3"], 'left', 400)])
        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["iconTextCheckBox4"], 'top', 160),
                            (self.widgets["iconTextCheckBox4"], 'left', 400)])
        cmds.formLayout(self.widgets["formLayout"],
                        edit=1,
                        af=[(self.widgets["iconTextCheckBox5"], 'top', 210),
                            (self.widgets["iconTextCheckBox5"], 'left', 400)])

        cmds.showWindow(self.widgets["window"])
        cmds.window(self.widgets["window"], edit=1, w=500, h=300)
Exemple #24
0
 def curveFollowUI(self,state):
     '''
     Creates the UI containing options to make a particle trail following a curve
     
     Initialises the following variables
     self.startFrame     : Frame to start particle movement along curve
     self.endFrame       : Frame to finish particle movement along curve
     self.maxDistance    : Maximum distance particles will be from the curve
     self.minDistance    : Maximum distance particles will be from the curve at the nose or tail of the group
     self.length         : Total trail length in frames
     self.nose           : Number of frames to taper to the nose of the trail
     self.turbulenceAmp  : Amplitude of the turbulence animation graph
     self.turbulencePer  : Period of the turbulence animation graph
     self.sourceCurve    : Name of the curve particles will emit from
     self.flakeNumber    : Number of snowflake particles to generate
     self.flakeRadius    : Average radius of snowflake particles
     self.flakeRadiusVar : Variation from average radius as a percentage
     self.shardNumber    : Number of shard particles to generate
     self.shardRadius    : Average radius of shard particles
     self.shardRadiusVar : Variation from average radius as a percentage
     self.colour1        : Canvas showing one end of the particle colour range
     self.colour2        : Canvas showing the other end of the particle colour range
     self.transparency   : Alpha value for the particle material
     self.glow           : Glow value for the particle material
     '''
     if state == 1:
         self.tmpFrame1 = cmds.rowColumnLayout(numberOfColumns=1,parent=self.snowFXOptionsFrame)
         cmds.frameLayout(label='Animation',cll=1)
         cmds.rowColumnLayout(numberOfColumns=2,cs=[(1,5),(2,5)],cw=[(1,350),(2,118)],cal=[(1,'right'),(2,'left')])
         
         cmds.text(label='Start Frame')
         self.startFrame = cmds.intField(minValue=0,width=60)
         cmds.text(label='End Frame')
         self.endFrame = cmds.intField(minValue=0,width=60,v=20)
         cmds.text(label='Max Distance from Curve')
         self.maxDistance = cmds.floatField(minValue=0,width=60,pre=3,v=0.5)
         cmds.text(label='Nose/Tail Distance from Curve')
         self.minDistance = cmds.floatField(minValue=0,width=60,pre=3)
         cmds.text(label='Total Trail Length (frames)')
         self.length = cmds.intField(minValue=0,width=60,v=16)
         cmds.text(label='Nose Length (frames)')
         self.nose = cmds.intField(minValue=0,width=60,v=3)
         cmds.text(label='Tail Length (frames)')
         self.tail = cmds.intField(minValue=0,maxValue=100,width=60,v=10)
         cmds.text(label='Turbulence Amplitude')
         self.turbulenceAmp = cmds.floatField(minValue=0,width=60,pre=3,v=1)
         cmds.text(label='Turbulence Period')
         self.turbulencePer = cmds.intField(minValue=0,width=60,v=12)
         cmds.text(label='Source Curve Name')
         self.sourceCurve = cmds.textField(width=60)
         cmds.text(label='')
         cmds.button(label='Set Selected', c=self.updateSourceCurve)
         cmds.setParent('..')
         cmds.setParent('..')
         cmds.frameLayout(label='Particles',cll=1)
         cmds.rowColumnLayout(numberOfColumns=2,cs=[(1,5),(2,5)],cw=[(1,350),(2,118)],cal=[(1,'right'),(2,'left')])
         
         cmds.text(label='Number of Snowflakes')
         self.flakeNumber = cmds.intField(minValue=0,width=60,v=10)
         cmds.text(label='Snowflake Radius')
         self.flakeRadius = cmds.floatField(minValue=0,width=60,pre=3,v=0.2)
         cmds.text(label='Snowflake Radius Variation (%)')
         self.flakeRadiusVar = cmds.intField(minValue=0,maxValue=100,width=60,v=20)
         cmds.text(label='Number of Shards')
         self.shardNumber = cmds.intField(minValue=0,width=60,v=50)
         cmds.text(label='Shard Size')
         self.shardSize = cmds.floatField(minValue=0,width=60,pre=3,v=0.07)
         cmds.text(label='Shard Size Variation (%)')
         self.shardSizeVar = cmds.intField(minValue=0,width=60,v=20)
         cmds.text(label='Colour Range 1')
         self.colour1 = cmds.canvas( rgb=(0.82,0.87,0.94),width = 60,height=20,pc=self.updateColour1)
         cmds.text(label='Colour Range 2')
         self.colour2 = cmds.canvas( rgb=(0.83,0.82,0.92),width = 60,height=20,pc=self.updateColour2)
         cmds.text(label='Transparency')
         self.transparency = cmds.floatField(minValue=0,maxValue=1,width=60,pre=3,v=0.6)
         cmds.text(label='Glow Intensity')
         self.glow = cmds.floatField(minValue=0,maxValue=1,width=60,pre=3,v=0.15)
         cmds.setParent('..')
         cmds.setParent('..')
         
         cmds.button(label='Generate',width=100,c=self.runCurveFollow)
         cmds.setParent('..')
     else:
         cmds.deleteUI(self.tmpFrame1)
Exemple #25
0
def attrUI(*args):
    """UI for the script"""

    if cmds.window("attrWin", exists=True):
        cmds.deleteUI("attrWin")

    widgets["win"] = cmds.window("attrWin",
                                 t="zbw_attributes",
                                 h=370,
                                 w=250,
                                 s=True)
    widgets["tabLO"] = cmds.tabLayout()
    widgets["channelColLO"] = cmds.columnLayout("Object/Attr Controls",
                                                w=250,
                                                bgc=(.8, .8, .8))

    widgets["lockFrLO"] = cmds.frameLayout(l="Lock/Hide",
                                           cll=True,
                                           w=250,
                                           bgc=(.7, .6, .6))
    widgets["lockColLO"] = cmds.columnLayout(bgc=(.8, .8, .8))
    #lock and hide controls

    #switch to Row column layout to break up the channels
    widgets["attrRCLO"] = cmds.rowColumnLayout(nc=2, cw=([1, 100], [2, 150]))
    widgets["transCB"] = cmds.checkBox(l="Translates",
                                       v=0,
                                       cc=partial(enableChannel, "transCB",
                                                  "translateCBG"))
    widgets["translateCBG"] = cmds.checkBoxGrp(w=150,
                                               cw3=(50, 50, 50),
                                               ncb=3,
                                               l1="TX",
                                               l2="TY",
                                               l3="TZ",
                                               l4="Vis",
                                               va3=(0, 0, 0),
                                               bgc=(.5, .5, .5),
                                               en=False)
    widgets["rotCB"] = cmds.checkBox(l="Rotates",
                                     v=0,
                                     cc=partial(enableChannel, "rotCB",
                                                "rotateCBG"))
    widgets["rotateCBG"] = cmds.checkBoxGrp(w=150,
                                            cw3=(50, 50, 50),
                                            ncb=3,
                                            l1="RX",
                                            l2="RY",
                                            l3="RZ",
                                            l4="Vis",
                                            va3=(0, 0, 0),
                                            bgc=(.5, .5, .5),
                                            en=False)
    widgets["scaleCB"] = cmds.checkBox(l="Scales",
                                       v=1,
                                       cc=partial(enableChannel, "scaleCB",
                                                  "scaleCBG"))
    widgets["scaleCBG"] = cmds.checkBoxGrp(w=150,
                                           cw3=(50, 50, 50),
                                           ncb=3,
                                           l1="SX",
                                           l2="SY",
                                           l3="SZ",
                                           l4="Vis",
                                           va3=(1, 1, 1),
                                           bgc=(.5, .5, .5),
                                           en=True)
    widgets["visCB"] = cmds.checkBox(l="Visibility", v=1)

    #back to frame layout
    cmds.setParent(widgets["lockFrLO"])
    widgets["topOneCLO"] = cmds.columnLayout()
    cmds.separator(h=5, st="none")
    widgets["lockRBG"] = cmds.radioButtonGrp(nrb=2,
                                             l1="Unlock",
                                             l2="Lock",
                                             sl=2)
    widgets["hideRBG"] = cmds.radioButtonGrp(nrb=2, l1="Show", l2="Hide", sl=2)
    widgets["channelsBut"] = cmds.button(l="Lock/Hide Channels",
                                         w=250,
                                         h=30,
                                         bgc=(.5, .5, .5),
                                         rs=True,
                                         c=channelLockHide)
    cmds.separator(h=5, st="none")
    widgets["lockAttrTFBG"] = cmds.textFieldButtonGrp(l="Locked Attr",
                                                      bl="Create",
                                                      cal=[(1, "left"),
                                                           (2, "left"),
                                                           (3, "left")],
                                                      cw3=[60, 135, 50],
                                                      bc=lockedAttr)
    cmds.separator(h=5, st="none")
    widgets["channelsBut"] = cmds.button(l="Move Selected Attr Up",
                                         w=250,
                                         h=20,
                                         bgc=(.5, .7, .5),
                                         rs=True,
                                         c=partial(shiftAttr, 1))
    widgets["channelsBut"] = cmds.button(l="Move Selected Attr Down",
                                         w=250,
                                         h=20,
                                         bgc=(.7, .5, .5),
                                         rs=True,
                                         c=partial(shiftAttr, 0))
    cmds.separator(h=5, st="none")

    #back to columnLayout
    cmds.setParent(widgets["channelColLO"])
    widgets["colorFrLO"] = cmds.frameLayout(l="Object Color",
                                            cll=True,
                                            w=250,
                                            bgc=(.7, .6, .6))
    widgets["colorRCLO"] = cmds.rowColumnLayout(nr=4, bgc=(.8, .8, .8))

    #color controls (red, green, blue, yellow, other)
    cmds.canvas(w=50,
                h=20,
                rgb=(1, 0, 0),
                pc=partial(changeColor, colors["red"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(.5, .1, .1),
                pc=partial(changeColor, colors["darkRed"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(.659, .275, .449),
                pc=partial(changeColor, colors["lightRed"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(1, .8, .965),
                pc=partial(changeColor, colors["pink"]))

    cmds.canvas(w=50,
                h=20,
                rgb=(0, 1, 0),
                pc=partial(changeColor, colors["green"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(0, .35, 0),
                pc=partial(changeColor, colors["darkGreen"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(0, .55, .335),
                pc=partial(changeColor, colors["medGreen"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(.35, .635, .15),
                pc=partial(changeColor, colors["yellowGreen"]))

    cmds.canvas(w=50,
                h=20,
                rgb=(0, 0, 1),
                pc=partial(changeColor, colors["blue"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(0, 0, .35),
                pc=partial(changeColor, colors["darkBlue"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(0, .2, .6),
                pc=partial(changeColor, colors["medBlue"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(.65, .8, 1),
                pc=partial(changeColor, colors["lightBlue"]))

    cmds.canvas(w=50,
                h=20,
                rgb=(1, 1, 0),
                pc=partial(changeColor, colors["yellow"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(.225, .1, 0),
                pc=partial(changeColor, colors["darkBrown"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(.5, .275, 0),
                pc=partial(changeColor, colors["brown"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(.922, .707, .526),
                pc=partial(changeColor, colors["darkYellow"]))

    cmds.canvas(w=50,
                h=20,
                rgb=(.33, 0, .33),
                pc=partial(changeColor, colors["purple"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(.2, 0, .25),
                pc=partial(changeColor, colors["darkPurple"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(.0, 0, .0),
                pc=partial(changeColor, colors["black"]))
    cmds.canvas(w=50,
                h=20,
                rgb=(1, 1, 1),
                pc=partial(changeColor, colors["white"]))

    #TO-DO----------------figure out breaking connections(to delete or not?), call add attr win
    # cmds.setParent(widgets["channelColLO"])
    # widgets["channelFrLO"] = cmds.frameLayout(l="Channels", cll=True, w=250, bgc=(1,1,1))
    # widgets["channelRCLO"] = cmds.columnLayout(bgc=(.8,.8,.8))
    # widgets["breakAllBut"] = cmds.button(l="Break All Connections", w=150, h=30, bgc=(.5,.5,.5))
    # widgets["breakSelBut"] = cmds.button(l="Break Selected Connections", w=150, h=30, bgc=(.5,.5,.5))
    # cmds.separator(h=10, st="none")
    # widgets["addAttBut"] = cmds.button(l="Show 'Add Attribute' win", w=150, h=30, bgc=(.5,.5,.5))

    cmds.setParent(widgets["tabLO"])
    widgets["connectColLO"] = cmds.columnLayout("Connections",
                                                w=250,
                                                bgc=(.8, .8, .8))
    widgets["connectFrame"] = cmds.frameLayout(l="Make General Connections",
                                               cll=True,
                                               bgc=(.6, .8, .6))
    widgets["connectionColLO"] = cmds.columnLayout(bgc=(.8, .8, .8))

    #connection stuff
    cmds.text("Select a source object and a channel:")
    widgets["connector"] = cmds.textFieldButtonGrp(
        l="Connector",
        w=250,
        bl="<<<",
        cal=[(1, "left"), (2, "left"), (3, "left")],
        cw3=[60, 140, 30],
        bc=partial(getChannel, "connector"))
    cmds.separator(h=5, st="none")
    cmds.text("Select a target object and channel:")
    widgets["connectee"] = cmds.textFieldButtonGrp(
        l="Connectee",
        w=250,
        bl="<<<",
        cal=[(1, "left"), (2, "left"), (3, "left")],
        cw3=[60, 140, 30],
        bc=partial(getChannel, "connectee"))
    cmds.separator(h=10, st="none")
    widgets["connectBut"] = cmds.button(l="Connect Two Channels",
                                        w=240,
                                        h=30,
                                        bgc=(.5, .5, .5),
                                        c=connectChannels)
    cmds.separator(h=5, st="none")

    cmds.setParent(widgets["connectColLO"])
    widgets["shapeFrame"] = cmds.frameLayout(l="Connect to Shape Visibility",
                                             cll=True,
                                             bgc=(.6, .8, .6))
    widgets["shapeColLO"] = cmds.columnLayout(bgc=(.8, .8, .8))

    widgets["toShapeVis"] = cmds.textFieldButtonGrp(l="Vis Driver",
                                                    w=250,
                                                    bl="<<<",
                                                    cal=[(1, "left"),
                                                         (2, "left"),
                                                         (3, "left")],
                                                    cw3=[60, 140, 30],
                                                    bc=partial(
                                                        getChannel,
                                                        "toShapeVis"))
    cmds.separator(h=5, st="none")
    cmds.text("Now select the objs to drive:")
    widgets["shapeBut"] = cmds.button(l="Connect to Shapes' vis",
                                      w=240,
                                      h=30,
                                      bgc=(.5, .5, .5),
                                      c=connectShapeVis)
    cmds.separator(h=5, st="none")

    cmds.setParent(widgets["connectColLO"])
    widgets["inoutFrame"] = cmds.frameLayout(
        l="Select Connections (and print)", cll=True, bgc=(.6, .8, .6))
    widgets["inOutColLO"] = cmds.columnLayout(bgc=(.8, .8, .8))

    widgets["conversionCB"] = cmds.checkBox(l="Skip 'conversion' nodes?", v=1)
    cmds.text("Select an attribute in the channel box:")
    widgets["getInputBut"] = cmds.button(l="Select inConnection object",
                                         w=240,
                                         h=30,
                                         bgc=(.5, .5, .5),
                                         c=getInput)
    widgets["getOutputBut"] = cmds.button(l="Select outConnection objects",
                                          w=240,
                                          h=30,
                                          bgc=(.5, .5, .5),
                                          c=getOutput)

    #show window
    cmds.showWindow(widgets["win"])
    cmds.window(widgets["win"], e=True, w=250, h=370)
Exemple #26
0
def ZvDynamics():
	if __name__ == "__main__":
		prfx = ""
	else:
		prfx = __name__ + "."
	
	winName = "ZvDynamicsWin"
	if cmds.window(winName, exists=True):
		cmds.deleteUI(winName, window=True)
	
	cmds.window(winName, title="ZV Dynamics " + __version__)
	
	# verifica se c'e' nucleus e runge-kutta
	nPartEnabled = "nParticle" in cmds.ls(nt=True)
	try:
		if not cmds.pluginInfo(_rkNode, q=True, l=True):
			cmds.loadPlugin(_rkNode + ".py")
		rkEnabled = True
	except:
		rkEnabled = False
	
	tabs = cmds.tabLayout(innerMarginWidth=2, innerMarginHeight=2)
	
	# primo tab
	child1 = cmds.formLayout(nd=20)
	
	fl1 = cmds.frameLayout(l="Method", labelAlign="center", borderStyle="etchedOut", mw=10, mh=10, li=5)
	cmds.rowLayout(numberOfColumns=4, columnWidth4=(40, 80, 80, 100), adjustableColumn=4)
	cmds.canvas()
	cmds.radioCollection()
	if _lastSettings[0] == -1:
		if nPartEnabled:
			selMethod = _methodsRB[1]
		else:
			selMethod = _methodsRB[0]
	else:
		selMethod = _methodsRB[_lastSettings[0]]
	
	cmds.radioButton(_methodsRB[0], l="Particle", cc="%smethodChanged()" % prfx)
	cmds.radioButton(_methodsRB[1], l="nParticle", enable=nPartEnabled, cc="%smethodChanged()" % prfx)
	cmds.radioButton(_methodsRB[2], l="Runge-Kutta", enable=rkEnabled, cc="%smethodChanged()" % prfx)
	cmds.radioButton(selMethod, e=True, select=True)
	
	cmds.setParent("..")
	cmds.setParent("..")
	
	fs1 = cmds.floatSliderGrp("ZvVar1Slider", label="Weight:", field=True, minValue=0.0, maxValue=1.0, fmn=0.0, fmx=1.0, value=0.5, step=0.01, cw=[(1, 110), (2, 50)])
	fs2 = cmds.floatSliderGrp("ZvVar2Slider", label="Conserve:", field=True, minValue=0.0, maxValue=1.0, fmn=0.0, fmx=1.0, value=1.0, step=0.01, cw=[(1, 110), (2, 50)])
	methodChanged()
	
	cb = cmds.checkBox("ZvTransferShapes", l="Transfer Shapes", value=False, align="left")
	
	# pulsanti
	b1 = cmds.button(l="Make objects dynamic", height=28, c="%szvDynBtn()" % prfx)
	b2 = cmds.button(l="Close", height=28, c="%scloseWindow(\"%s\")" % (prfx, winName))
	
	cmds.formLayout(child1, e=True, attachForm=[(fl1, "left", 0), (fs1, "left", 0), (fs2, "left", 0), (cb, "left", 130), (fl1, "right", 0), (fl1, "top", 0), (fs1, "top", 65), (fs2, "top", 90), (cb, "top", 125), (b1, "left", 0), (b2, "right", 0), (b1, "bottom", 0), (b2, "bottom", 0)],\
					attachPosition=[(b2, "left", 0, 10), (b1, "right", 0, 10)])
	cmds.setParent(tabs)
	
	# secondo tab
	child2 = cmds.formLayout(nd=20)
	fl2 = cmds.frameLayout(l="Time Range", labelAlign="center", borderStyle="etchedOut", mw=10, mh=10, li=5)
	cmds.rowLayout(numberOfColumns=3, columnWidth3=(50, 100, 100), adjustableColumn=3)
	cmds.canvas()
	cmds.radioCollection()
	cmds.radioButton("ZvTimeSliderRB", l="Time Slider", select=False)
	cmds.radioButton(l="Start/End Animation", select=True)
	cmds.setParent(child2)
	b3 = cmds.button(l="Bake", height=28, c="%szvBakeBtn()" % prfx)
	b4 = cmds.button(l="Close", height=28, c="%scloseWindow(\"%s\")" % (prfx, winName))
	cmds.formLayout(child2, e=True, attachForm=[(fl2, "left", 0), (fl2, "right", 0), (fl2, "top", 0), (b3, "left", 0), (b4, "right", 0), (b3, "bottom", 0), (b4, "bottom", 0)],\
					attachPosition=[(b4, "left", 0, 10), (b3, "right", 0, 10)])
	cmds.setParent(tabs)
	
	# terzo tab
	child3 = cmds.formLayout(nd=30)
	b5 = cmds.button(l="Online Help", height=28, c="%shelpBtn()" % prfx)
	b6 = cmds.button(l="Close", height=28, c="%scloseWindow(\"%s\")" % (prfx, winName))
	cmds.formLayout(child3, e=True, attachForm=[(b6, "left", 0), (b6, "right", 0), (b6, "bottom", 0), (b5, "top", 50)],\
					attachPosition=[(b5, "left", 0, 8), (b5, "right", 0, 22)])
	
	cmds.tabLayout(tabs, edit=True, tabLabel=((child1, 'Dynamics'), (child2, 'Baking'), (child3, 'Help')), sti=1)
	
	cmds.showWindow(winName)
	cmds.window(winName, edit=True, widthHeight=(380, 248))
	
	sys.stdout.write("ZV Dynamics %s          http://www.paolodominici.com          [email protected]\n" % __version__)
Exemple #27
0
def create_lights():
    """populates the UI with a row for each light in the scene"""
    global lights
    lights = cmds.ls(type='light')

    global swatches
    swatches = []

    global main_layout
    cmds.setParent(main_layout)

    global light_layout
    light_layout = cmds.rowColumnLayout(nc=12,
                                        columnWidth=[(1, 60),
                                                     (2, 150), (3, 100),
                                                     (4, 100), (5, 60),
                                                     (6, 60), (7, 60), (8, 60),
                                                     (9, 60), (10, 100),
                                                     (11, 60), (12, 60)],
                                        cs=[(1, 10), (2, 10), (3, 10), (4, 10),
                                            (5, 10), (6, 10), (7, 10), (8, 10),
                                            (9, 10), (10, 10), (11, 10),
                                            (12, 10)],
                                        rs=(1, 10))

    # create rows of individual lights
    for i, light in enumerate(lights):
        # 1 - enabled
        enabled = cmds.getAttr(light + '.visibility')
        cmds.checkBox(label='',
                      v=enabled,
                      onc=partial(turn_on, light, 'visibility'),
                      ofc=partial(turn_off, light, 'visibility'),
                      al='center',
                      w=40)
        # 2 - name
        cmds.textField(light + 'name',
                       tx=cmds.listRelatives(light, type='transform',
                                             p=True)[0],
                       w=130,
                       cc=partial(rename, light),
                       ec=partial(rename, light))
        # 3 - type
        cmds.text(label=cmds.nodeType(light), w=130, al='left')
        # 4 - intensity
        cmds.floatField(light + 'intensity',
                        v=cmds.getAttr(light + '.intensity'),
                        cc=partial(update_float, light, 'intensity'),
                        ec=partial(update_float, light, 'intensity'),
                        w=60)
        # 5 - color
        swatch = cmds.canvas(rgbValue=cmds.getAttr(light + '.color')[0],
                             w=40,
                             h=20,
                             pressCommand=partial(color_picker, light, i))
        swatches.append(swatch)
        # 6 - cone angle
        if (cmds.nodeType(light) == 'spotLight'):
            cmds.floatField(light + 'coneAngle',
                            v=cmds.getAttr(light + '.coneAngle'),
                            cc=partial(update_float, light, 'coneAngle'),
                            ec=partial(update_float, light, 'coneAngle'),
                            w=60)
        else:
            cmds.floatField(v=0, w=60, en=0)

        # 7 - penumbra angle
        if (cmds.nodeType(light) == 'spotLight'):
            cmds.floatField(light + 'penumbraAngle',
                            v=cmds.getAttr(light + '.penumbraAngle'),
                            cc=partial(update_float, light, 'penumbraAngle'),
                            ec=partial(update_float, light, 'penumbraAngle'),
                            w=60)
        else:
            cmds.floatField(v=0, w=60, en=0)
        # 8 - diffuse
        if (cmds.nodeType(light) != 'ambientLight'):
            cmds.checkBox(label='',
                          v=cmds.getAttr(light + '.emitDiffuse'),
                          onc=partial(turn_on, light, 'emitDiffuse'),
                          ofc=partial(turn_off, light, 'emitDiffuse'),
                          al='center',
                          w=40)
        else:
            cmds.checkBox(label='', en=0)

        # 9 - spec
        if (cmds.nodeType(light) != 'ambientLight'):
            cmds.checkBox(label='',
                          v=cmds.getAttr(light + '.emitSpecular'),
                          onc=partial(turn_on, light, 'emitSpecular'),
                          ofc=partial(turn_off, light, 'emitSpecular'),
                          al='center',
                          w=40)
        else:
            cmds.checkBox(label='', en=0)
        # 10 - decay
        if (cmds.nodeType(light) == 'spotLight'
                or cmds.nodeType(light) == 'areaLight'):
            cmds.optionMenu('decay' + light,
                            w=100,
                            cc=partial(change_decay, light))
            cmds.menuItem(label='No Decay', parent='decay' + light)
            cmds.menuItem(label='Linear', parent='decay' + light)
            cmds.menuItem(label='Quadratic', parent='decay' + light)
            cmds.menuItem(label='Cubic', parent='decay' + light)
            change_decay(light, cmds.getAttr(light + '.decayRate'))
        else:
            cmds.optionMenu(en=0)

        # 11 - select
        cmds.button(label='Select',
                    command=partial(select, light),
                    al='center',
                    w=40)
        # 12 - point at
        if (cmds.nodeType(light) != 'ambientLight'
                and cmds.nodeType(light) != 'pointLight'):
            cmds.button(label='Point',
                        command=partial(aim, light),
                        al='center',
                        w=40)
        else:
            cmds.button(label='Point', en=0, w=40)

    cmds.setParent('..')
Exemple #28
0
    def build(self, window_):
        self.setWindow(width=230, sizable=0)
        form = cmds.formLayout(p=window_)

        colmain = cmds.columnLayout(p=form,
                                    columnAttach=('both', 10),
                                    rowSpacing=10,
                                    columnWidth=230)
        #cmds.button("setColor", l="Set Curve Color", h=30, ann="Set Curve Color", command=functions.applyColor)

        cmds.canvas('colorDisplay',
                    rgbValue=utility.sRGBtoLinear(self.colorPalette[0]),
                    width=210,
                    height=30,
                    pressCommand=self._editColor)

        palette = cmds.gridLayout(numberOfColumns=7, cellWidthHeight=(30, 30))
        for inx, colr in enumerate(self.colorPalette):
            colr = utility.sRGBtoLinear(colr)
            name = 'colorPalette' + str(inx)
            cmds.canvas(name,
                        width=30,
                        height=30,
                        rgbValue=colr,
                        pressCommand=partial(self._selectColor, name))

        shelf = cmds.shelfLayout(p=colmain,
                                 backgroundColor=(0.185, 0.185, 0.185),
                                 cellWidthHeight=(66, 66),
                                 spacing=3,
                                 w=210,
                                 h=210)

        def addCurveBtn():
            sl = utility.checkSelection([('nurbsCurve', 1, 1)])
            if sl:
                functions.saveCurve(sl[0])
                button_list = cmds.shelfLayout(shelf, q=1, childArray=1)[1:]
                #print(button_list)
                for btn in button_list:
                    cmds.deleteUI(btn)

                listAllCurve()

        def deleteCurveBtn(btnName, *args):
            curveName = btnName[4:]
            jsonFile = curveName + ".json"
            imageFile = curveName + ".png"
            os.remove(CURVE_PATH + jsonFile)
            os.remove(CURVE_PATH + imageFile)
            cmds.deleteUI(btnName)

        cmds.iconTextButton(
            'btnSaveCurve',
            image='add_new.svg',
            command=addCurveBtn,
        )

        def listAllCurve():
            curvesInfo = []
            curvesJson = utility.getFileList(CURVE_PATH,
                                             ext='json',
                                             sort='create')
            for file in curvesJson:
                with open(CURVE_PATH + file, 'r') as f:
                    data = json.load(f)
                    curvesInfo.append(data)

            for info in curvesInfo:
                cmds.iconTextButton(
                    'btn_' + info['name'],
                    st='iconAndTextVertical',
                    scaleIcon=1,
                    # backgroundColor=(0.32,0.52,0.65),
                    parent=shelf,
                    image=CURVE_PATH + info['icon'],
                    label=info['name'],
                    command=partial(self._createCurves, info['shape']),
                )
                p = cmds.popupMenu(b=3)
                cmds.menuItem(p=p,
                              l='import',
                              c=partial(self._createCurves, info['shape']))
                infoText = 'Do you want to delete "' + \
                    info['name']+'"? This action is not undoable.'
                command = partial(deleteCurveBtn, 'btn_' + info['name'])
                cmds.menuItem(p=p,
                              l='delete',
                              c=partial(makeSure, infoText, command))

        listAllCurve()

        cmds.formLayout(
            form,
            edit=True,
            attachForm=[
                (colmain, 'top', 10),
                (colmain, 'bottom', 10),
            ],
        )
Exemple #29
0
def create_lights():
    """populates the UI with a row for each light in the scene"""
    global lights
    lights = cmds.ls(type='light')
    
    global swatches
    swatches = []
    
    global main_layout
    cmds.setParent(main_layout)
    
    global light_layout
    light_layout = cmds.rowColumnLayout(nc=12,
                                        columnWidth=[(1, 60), (2, 150), (3, 100), (4, 100), (5, 60), (6, 60), (7, 60), (8, 60), (9, 60), (10, 100), (11, 60), (12, 60)],
                                        cs=[(1, 10), (2, 10), (3, 10), (4, 10), (5, 10), (6, 10), (7, 10), (8, 10), (9, 10), (10, 10), (11, 10), (12, 10)], rs=(1, 10))
    
    # create rows of individual lights
    for i, light in enumerate(lights):
        # 1 - enabled
        enabled = cmds.getAttr(light + '.visibility')
        cmds.checkBox(label='',
                      v=enabled,
                      onc=partial(turn_on, light, 'visibility'),
                      ofc=partial(turn_off, light, 'visibility'),
                      al='center', w=40)
        # 2 - name
        cmds.textField(light + 'name',
                       tx=cmds.listRelatives(light, type='transform', p=True)[0],
                       w=130,
                       cc=partial(rename, light),
                       ec=partial(rename, light))
        # 3 - type
        cmds.text(label=cmds.nodeType(light),
                  w=130,
                  al='left')
        # 4 - intensity
        cmds.floatField(light + 'intensity',
                        v=cmds.getAttr(light + '.intensity'),
                        cc=partial(update_float, light, 'intensity'),
                        ec=partial(update_float, light, 'intensity'),
                        w=60)
        # 5 - color
        swatch = cmds.canvas(rgbValue=cmds.getAttr(light + '.color')[0],
                             w=40,
                             h=20,
                             pressCommand=partial(color_picker, light, i))
        swatches.append(swatch)
        # 6 - cone angle
        if(cmds.nodeType(light) == 'spotLight'):
            cmds.floatField(light + 'coneAngle',
                            v=cmds.getAttr(light + '.coneAngle'),
                            cc=partial(update_float, light, 'coneAngle'),
                            ec=partial(update_float, light, 'coneAngle'),
                            w=60)
        else:
            cmds.floatField(v=0, w=60, en=0)
        
        # 7 - penumbra angle
        if(cmds.nodeType(light) == 'spotLight'):
            cmds.floatField(light + 'penumbraAngle',
                            v=cmds.getAttr(light + '.penumbraAngle'),
                            cc=partial(update_float, light, 'penumbraAngle'),
                            ec=partial(update_float, light, 'penumbraAngle'),
                            w=60)
        else:
            cmds.floatField(v=0, w=60, en=0)
        # 8 - diffuse
        if(cmds.nodeType(light) != 'ambientLight'):
            cmds.checkBox(label='',
                          v=cmds.getAttr(light + '.emitDiffuse'),
                          onc=partial(turn_on, light, 'emitDiffuse'),
                          ofc=partial(turn_off, light, 'emitDiffuse'),
                          al='center',
                          w=40)
        else:
            cmds.checkBox(label='', en=0)
        
        # 9 - spec
        if(cmds.nodeType(light) != 'ambientLight'):
            cmds.checkBox(label='',
                          v=cmds.getAttr(light + '.emitSpecular'),
                          onc=partial(turn_on, light, 'emitSpecular'),
                          ofc=partial(turn_off, light, 'emitSpecular'),
                          al='center',
                          w=40)
        else:
            cmds.checkBox(label='', en=0)
        # 10 - decay
        if(cmds.nodeType(light) == 'spotLight' or cmds.nodeType(light) == 'areaLight'):
            cmds.optionMenu('decay' + light, w=100, cc=partial(change_decay, light))
            cmds.menuItem(label='No Decay', parent='decay' + light)
            cmds.menuItem(label='Linear', parent='decay' + light)
            cmds.menuItem(label='Quadratic', parent='decay' + light)
            cmds.menuItem(label='Cubic', parent='decay' + light)
            change_decay(light, cmds.getAttr(light + '.decayRate'))
        else:
            cmds.optionMenu(en=0)
        
        # 11 - select
        cmds.button(label='Select', command=partial(select, light), al='center', w=40)
        # 12 - point at
        if(cmds.nodeType(light) != 'ambientLight' and cmds.nodeType(light) != 'pointLight'):
            cmds.button(label='Point', command=partial(aim, light), al='center', w=40)
        else:
            cmds.button(label='Point', en=0, w=40)
        
    cmds.setParent('..')
Exemple #30
0
    def savePreset(self, *args):

        # get presets' values
        # floatFieldGrpValue = [float, float, float]
        floatFieldGrpValue = cmds.floatFieldGrp(self.widgets["floatField"],
                                                q=1,
                                                v=True)
        # floatSliderGrpValue = float
        floatSliderGrpValue = cmds.floatSliderGrp(self.widgets["floatSlider"],
                                                  q=1,
                                                  v=True)
        # radioButtonGrpValue = int
        radioButtonGrpValue = cmds.radioButtonGrp(
            self.widgets["radioButtonGrp"], q=1, select=True)
        # inputTextField = string
        inputTextFieldValue = cmds.textField(self.widgets["inputTextField"],
                                             q=1,
                                             text=True)
        # outputTextFieldValue = string
        outputTextFieldValue = cmds.textField(self.widgets["outputTextField"],
                                              q=1,
                                              text=True)
        # swatchValue = [float, float, float]
        swatchValue = cmds.canvas(self.widgets["swatch"], q=1, rgbValue=True)
        # checkBox#Value = boolean & iconTextCheckBox#Value = boolean
        checkBox1Value = cmds.checkBox(self.widgets["checkBox1"],
                                       q=1,
                                       value=True)
        checkBox2Value = cmds.checkBox(self.widgets["checkBox2"],
                                       q=1,
                                       value=True)
        iconTextCheckBox1Value = cmds.iconTextCheckBox(
            self.widgets["iconTextCheckBox1"], q=1, value=True)
        iconTextCheckBox2Value = cmds.iconTextCheckBox(
            self.widgets["iconTextCheckBox2"], q=1, value=True)
        iconTextCheckBox3Value = cmds.iconTextCheckBox(
            self.widgets["iconTextCheckBox3"], q=1, value=True)
        iconTextCheckBox4Value = cmds.iconTextCheckBox(
            self.widgets["iconTextCheckBox4"], q=1, value=True)
        iconTextCheckBox5Value = cmds.iconTextCheckBox(
            self.widgets["iconTextCheckBox5"], q=1, value=True)
        '''
        print floatSliderGrpValue
        print iconTextCheckBox1Value

        print swatchValue[0]
        print swatchValue[1]
        print swatchValue[2]


        print floatFieldGrpValue[0]
        print floatFieldGrpValue[1]
        print floatFieldGrpValue[2]
        '''

        # open file and write the presets' values

        filePath = cmds.internalVar(upd=1) + 'preset.txt'
        file = open(filePath, 'w')

        # write(controlCommandName, controlName, valueTypeName, value)
        # write(floatFieldGrp, floatField, v, floatFieldGrpValue)
        file.write("floatFieldGrp;" + "floatField;" + "value;" +
                   str(floatFieldGrpValue) + "\n")

        file.write("floatSliderGrp;" + "floatSlider;" + "v;" +
                   str(floatSliderGrpValue) + "\n")
        file.write("radioButtonGrp;" + "radioButtonGrp;" + "select;" +
                   str(radioButtonGrpValue) + "\n")
        file.write("textField;" + "inputTextField;" + "text;" +
                   str(inputTextFieldValue) + "\n")
        file.write("textField;" + "outputTextField;" + "text;" +
                   str(outputTextFieldValue) + "\n")
        file.write("canvas;" + "swatch;" + "rgbValue;" + str(swatchValue) +
                   "\n")
        file.write("checkBox;" + "checkBox1;" + "value;" +
                   str(checkBox1Value) + "\n")
        file.write("checkBox;" + "checkBox2;" + "value;" +
                   str(checkBox2Value) + "\n")
        file.write("iconTextCheckBox;" + "iconTextCheckBox1;" + "value;" +
                   str(iconTextCheckBox1Value) + "\n")
        file.write("iconTextCheckBox;" + "iconTextCheckBox2;" + "value;" +
                   str(iconTextCheckBox2Value) + "\n")
        file.write("iconTextCheckBox;" + "iconTextCheckBox3;" + "value;" +
                   str(iconTextCheckBox3Value) + "\n")
        file.write("iconTextCheckBox;" + "iconTextCheckBox4;" + "value;" +
                   str(iconTextCheckBox4Value) + "\n")
        file.write("iconTextCheckBox;" + "iconTextCheckBox5;" + "value;" +
                   str(iconTextCheckBox5Value))

        file.close()
def attrUI(*args):
	"""UI for the script"""

	if cmds.window("attrWin", exists=True):
		cmds.deleteUI("attrWin")

	widgets["win"] = cmds.window("attrWin", t="zbw_attributes", h=370, w=250, s=True)
	widgets["tabLO"] = cmds.tabLayout()
	widgets["channelColLO"] = cmds.columnLayout("Object/Attr Controls", w=250, bgc=(.8,.8,.8))

	widgets["lockFrLO"] = cmds.frameLayout(l="Lock/Hide", cll=True, w=250, bgc=(.7,.6,.6))
	widgets["lockColLO"] = cmds.columnLayout(bgc=(.8,.8,.8))
	#lock and hide controls

	#switch to Row column layout to break up the channels
	widgets["attrRCLO"] = cmds.rowColumnLayout(nc=2, cw=([1, 100], [2,150]))
	widgets["transCB"] = cmds.checkBox(l="Translates", v=0, cc=partial(enableChannel, "transCB", "translateCBG"))
	widgets["translateCBG"] = cmds.checkBoxGrp(w=150, cw3=(50,50,50), ncb=3, l1="TX", l2="TY", l3="TZ", l4="Vis", va3=(0,0,0), bgc=(.5,.5,.5), en=False)
	widgets["rotCB"] = cmds.checkBox(l="Rotates", v=0, cc=partial(enableChannel, "rotCB","rotateCBG"))
	widgets["rotateCBG"] = cmds.checkBoxGrp(w=150, cw3=(50,50,50), ncb=3, l1="RX", l2="RY", l3="RZ", l4="Vis", va3=(0,0,0), bgc=(.5,.5,.5), en=False)
	widgets["scaleCB"] = cmds.checkBox(l="Scales", v=1, cc=partial(enableChannel, "scaleCB","scaleCBG"))
	widgets["scaleCBG"] = cmds.checkBoxGrp(w=150, cw3=(50,50,50), ncb=3, l1="SX", l2="SY", l3="SZ", l4="Vis", va3=(1,1,1), bgc=(.5,.5,.5), en=True)
	widgets["visCB"] = cmds.checkBox(l="Visibility", v=1)

	#back to frame layout
	cmds.setParent(widgets["lockFrLO"])
	widgets["topOneCLO"] = cmds.columnLayout()
	cmds.separator(h=5, st="none")	
	widgets["lockRBG"] = cmds.radioButtonGrp(nrb=2, l1="Unlock", l2="Lock", sl=2)
	widgets["hideRBG"] = cmds.radioButtonGrp(nrb=2, l1="Show", l2="Hide", sl=2)
	widgets["channelsBut"] = cmds.button(l="Lock/Hide Channels", w=250, h=30, bgc=(.5,.5,.5), rs=True, c=channelLockHide)
	cmds.separator(h=5, st="none")
	widgets["lockAttrTFBG"] = cmds.textFieldButtonGrp(l="Locked Attr", bl="Create", cal=[(1,"left"),(2,"left"),(3,"left")], cw3=[60,135,50], bc=lockedAttr)
	cmds.separator(h=5,st="none")
	widgets["channelsBut"] = cmds.button(l="Move Selected Attr Up", w=250, h=20, bgc=(.5,.7,.5), rs=True, c= partial(shiftAttr, 1))
	widgets["channelsBut"] = cmds.button(l="Move Selected Attr Down", w=250, h=20, bgc=(.7,.5,.5), rs=True, c=partial(shiftAttr, 0))
	cmds.separator(h=5,st="none")

	#back to columnLayout
	cmds.setParent(widgets["channelColLO"])
	widgets["colorFrLO"] = cmds.frameLayout(l="Object Color", cll=True, w=250, bgc=(.7,.6,.6))
	widgets["colorRCLO"] = cmds.rowColumnLayout(nr=4, bgc=(.8,.8,.8))

	#color controls (red, green, blue, yellow, other)
	cmds.canvas(w=50, h=20, rgb=(1,0,0), pc=partial(changeColor, colors["red"]))
	cmds.canvas(w=50, h=20, rgb=(.5,.1,.1), pc=partial(changeColor, colors["darkRed"]))
	cmds.canvas(w=50, h=20, rgb=(.659,.275,.449), pc=partial(changeColor, colors["lightRed"]))
	cmds.canvas(w=50, h=20, rgb=(1,.8,.965), pc=partial(changeColor, colors["pink"]))

	cmds.canvas(w=50, h=20, rgb=(0,1,0), pc=partial(changeColor, colors["green"]))
	cmds.canvas(w=50, h=20, rgb=(0,.35,0), pc=partial(changeColor, colors["darkGreen"]))
	cmds.canvas(w=50, h=20, rgb=(0,.55,.335), pc=partial(changeColor, colors["medGreen"]))
	cmds.canvas(w=50, h=20, rgb=(.35,.635,.15), pc=partial(changeColor, colors["yellowGreen"]))

	cmds.canvas(w=50, h=20, rgb=(0,0,1), pc=partial(changeColor, colors["blue"]))
	cmds.canvas(w=50, h=20, rgb=(0,0,.35), pc=partial(changeColor, colors["darkBlue"]))
	cmds.canvas(w=50, h=20, rgb=(0,.2,.6), pc=partial(changeColor, colors["medBlue"]))
	cmds.canvas(w=50, h=20, rgb=(.65,.8,1), pc=partial(changeColor, colors["lightBlue"]))

	cmds.canvas(w=50, h=20, rgb=(1,1,0), pc=partial(changeColor, colors["yellow"]))
	cmds.canvas(w=50, h=20, rgb=(.225,.1,0), pc=partial(changeColor, colors["darkBrown"]))
	cmds.canvas(w=50, h=20, rgb=(.5,.275,0), pc=partial(changeColor, colors["brown"]))
	cmds.canvas(w=50, h=20, rgb=(.922,.707,.526), pc=partial(changeColor, colors["darkYellow"]))

	cmds.canvas(w=50, h=20, rgb=(.33,0,.33), pc=partial(changeColor, colors["purple"]))
	cmds.canvas(w=50, h=20, rgb=(.2,0,.25), pc=partial(changeColor, colors["darkPurple"]))
	cmds.canvas(w=50, h=20, rgb=(.0,0,.0), pc=partial(changeColor, colors["black"]))
	cmds.canvas(w=50, h=20, rgb=(1,1,1), pc=partial(changeColor, colors["white"]))

#TO-DO----------------figure out breaking connections(to delete or not?), call add attr win
	# cmds.setParent(widgets["channelColLO"])
	# widgets["channelFrLO"] = cmds.frameLayout(l="Channels", cll=True, w=250, bgc=(1,1,1))
	# widgets["channelRCLO"] = cmds.columnLayout(bgc=(.8,.8,.8))
	# widgets["breakAllBut"] = cmds.button(l="Break All Connections", w=150, h=30, bgc=(.5,.5,.5))
	# widgets["breakSelBut"] = cmds.button(l="Break Selected Connections", w=150, h=30, bgc=(.5,.5,.5))
	# cmds.separator(h=10, st="none")
	# widgets["addAttBut"] = cmds.button(l="Show 'Add Attribute' win", w=150, h=30, bgc=(.5,.5,.5))

	cmds.setParent(widgets["tabLO"])
	widgets["connectColLO"] = cmds.columnLayout("Connections", w=250, bgc=(.8,.8,.8))
	widgets["connectFrame"] = cmds.frameLayout(l="Make General Connections", cll=True, bgc=(.6,.8,.6))
	widgets["connectionColLO"] = cmds.columnLayout(bgc=(.8,.8,.8))

	#connection stuff
	cmds.text("Select a source object and a channel:")
	widgets["connector"] = cmds.textFieldButtonGrp(l="Connector", w=250, bl="<<<", cal=[(1,"left"),(2,"left"),(3,"left")], cw3=[60,140,30], bc=partial(getChannel, "connector"))
	cmds.separator(h=5,st="none")
	cmds.text("Select a target object and channel:")
	widgets["connectee"] = cmds.textFieldButtonGrp(l="Connectee", w=250, bl="<<<", cal=[(1,"left"),(2,"left"),(3,"left")], cw3=[60,140,30], bc=partial(getChannel, "connectee"))
	cmds.separator(h=10,st="none")
	widgets["connectBut"] = cmds.button(l="Connect Two Channels", w=240, h=30, bgc=(.5,.5,.5), c=connectChannels)
	cmds.separator(h=5,st="none")

	cmds.setParent(widgets["connectColLO"])
	widgets["shapeFrame"] = cmds.frameLayout(l="Connect to Shape Visibility", cll=True, bgc=(.6,.8,.6))
	widgets["shapeColLO"] = cmds.columnLayout(bgc=(.8,.8,.8))

	widgets["toShapeVis"] = cmds.textFieldButtonGrp(l="Vis Driver", w=250, bl="<<<", cal=[(1,"left"),(2,"left"),(3,"left")], cw3=[60,140,30], bc=partial(getChannel, "toShapeVis"))
	cmds.separator(h=5,st="none")
	cmds.text("Now select the objs to drive:")
	widgets["shapeBut"] = cmds.button(l="Connect to Shapes' vis", w=240, h=30, bgc=(.5,.5,.5), c=connectShapeVis)
	cmds.separator(h=5,st="none")

	cmds.setParent(widgets["connectColLO"])
	widgets["inoutFrame"] = cmds.frameLayout(l="Select Connections (and print)", cll=True, bgc=(.6,.8,.6))
	widgets["inOutColLO"] = cmds.columnLayout(bgc=(.8,.8,.8))

	widgets["conversionCB"] = cmds.checkBox(l="Skip 'conversion' nodes?", v=1)
	cmds.text("Select an attribute in the channel box:")
	widgets["getInputBut"] = cmds.button(l="Select inConnection object", w=240, h=30, bgc=(.5,.5,.5), c=getInput)
	widgets["getOutputBut"] = cmds.button(l="Select outConnection objects", w=240, h=30, bgc=(.5,.5,.5), c=getOutput)

	#show window
	cmds.showWindow(widgets["win"])
	cmds.window(widgets["win"], e=True, w=250, h=370)
def _refrTimeForm(obj):
    '''Aggiorna il form della timeline window.'''

    timeForm = obj + _timeFormSfx
    min = cmds.playbackOptions(q=True, min=True)
    max = cmds.playbackOptions(q=True, max=True)
    rng = max - min + 1.0
    currentFrame = cmds.currentTime(q=True)

    # rimuovi gli elementi del time form
    children = cmds.formLayout(timeForm, q=True, ca=True)
    if children:
        cmds.deleteUI(children)

    # rintraccia il nodo di parent
    pcNode = cmds.ls(_getParentConstraint(obj))
    if pcNode:
        pcNode = pcNode[0]
    else:
        # aggiorna le label
        cmds.text(obj + _labelSfx[0], e=True, l='%d' % currentFrame, w=50)
        cmds.text(obj + _labelSfx[1], e=True, l='')
        return

    # il main form e' il parent
    cmds.setParent(timeForm)

    # parametri per l'edit del form
    attachPositions = []
    attachForms = []

    # lista dei target
    targets = cmds.parentConstraint(pcNode, q=True, tl=True)
    for tid in range(len(targets)):
        times = cmds.keyframe('%s.w%d' % (pcNode, tid), q=True, tc=True)
        values = cmds.keyframe('%s.w%d' % (pcNode, tid), q=True, vc=True)

        # nessuna chiave, lista nulla e passa al successivo
        if not times:
            continue

        # indici dei tempi delle chiavi di attach/detach
        idxList = []
        check = True
        for v in range(len(values)):
            if values[v] == check:
                idxList.append(v)
                check = not check

        # deve funzionare anche se l'ultima chiave e' attached (quindi numero chiavi dispari)
        times.append(cmds.playbackOptions(q=True, aet=True)+1.0)

        # ogni elemento di attach times e' relativo ad un particolare target ed e' una lista di questo tipo [[3,10], [12, 20]]
        timeRanges = [times[idxList[i]:idxList[i]+2] for i in range(0, len(idxList), 2)]

        hsvCol = _getColor(tid)

        # aggiungi i nuovi controlli
        for timeRange in timeRanges:
            # normalizza il timeRange
            normRange = [_timeFormDiv*(_crop(tr, min, max+1) - min)/rng for tr in timeRange]

            # se l'elemento e' stato croppato dal timerange passa al successivo
            if normRange[0] == normRange[1]:
                continue

            control = cmds.canvas(hsvValue=hsvCol, w=1, h=1, ann='%s [%d, %d]' % (targets[tid], timeRange[0], timeRange[1]-1.0))
            for button in [1, 3]:
                cmds.popupMenu(mm=True, b=button)
                cmds.menuItem(l='[%s]' % targets[tid], c='cmds.select(\'%s\')' % targets[tid], rp='N')
                cmds.menuItem(l='Select child', c='cmds.select(\'%s\')' % obj, rp='S')
                cmds.menuItem(l='Fix snaps', c='cmds.select(\'%s\')\n%s.fixSnap(True)' % (obj, __name__), rp='E')

            attachForms.extend([(control, 'top', 0), (control, 'bottom', 0)])
            attachPositions.extend([(control, 'left', 0, normRange[0]), (control, 'right', 0, normRange[1])])

    # current frame
    if currentFrame >= min and currentFrame <= max:
        frameSize = _timeFormDiv/rng
        normCf = frameSize*(currentFrame - min)
        currentTarget = _getActiveAttachTarget(pcNode)
        if not currentTarget:
            hsvCol = (0.0, 0.0, 0.85)
        else:
            hsvCol = _getColor(targets.index(currentTarget), 0.15)
        cf = cmds.canvas(hsvValue=hsvCol, w=1, h=1)

        attachForms.extend([(cf, 'top', 0), (cf, 'bottom', 0)])
        attachPositions.extend([(cf, 'left', 0, normCf), (cf, 'right', 0, normCf+frameSize)])

    # setta i parametri del form
    cmds.formLayout(timeForm, e=True, attachForm=attachForms, attachPosition=attachPositions)

    # aggiorna le label
    cmds.text(obj + _labelSfx[0], e=True, l='%d' % currentFrame, w=50)
    cmds.text(obj + _labelSfx[1], e=True, l='[%s]' % _getActiveAttachTarget(pcNode))
Exemple #33
0
 def planeEmitUI(self,state):
     '''
     Creates the UI containing options to emit particles from a plane
     
     Initialises the following variables
     self.startFrame     : Frame to start emission
     self.endFrame       : Frame to finish emission
     self.maxDistance    : Maximum distance particles will be emitted from the plane
     self.minDistance    : Minimum distance particles will be emitted from the plane
     self.maxAngle       : Maximum angle from the plane normal the particles con be emitted at
     self.emitTime       : Number of frames particles will be affected by the emission force
     self.lifeTime       : Average lifetime of a particle
     self.lifeTimeVar    : Variation from average lifetime as a percentage
     self.fadeOut        : Number of frames to scale down particles at the end of their lifetime
     self.driftX         : Distance a particle will drift in the X direction in 10 frames
     self.driftY         : Distance a particle will drift in the Y direction in 10 frames
     self.driftZ         : Distance a particle will drift in the Z direction in 10 frames
     self.turbulenceAmp  : Amplitude of the turbulence animation graph
     self.turbulencePer  : Period of the turbulence animation graph
     self.sourcePlane    : Name of the plane particles will emit from
     self.flakeNumber    : Number of snowflake particles to generate
     self.flakeRadius    : Average radius of snowflake particles
     self.flakeRadiusVar : Variation from average radius as a percentage
     self.shardNumber    : Number of shard particles to generate
     self.shardRadius    : Average radius of shard particles
     self.shardRadiusVar : Variation from average radius as a percentage
     self.colour1        : Canvas showing one end of the particle colour range
     self.colour2        : Canvas showing the other end of the particle colour range
     self.transparency   : Alpha value for the particle material
     self.glow           : Glow value for the particle material
     '''
     if state == 1:
         self.tmpFrame2 = cmds.rowColumnLayout(numberOfColumns=1,parent=self.snowFXOptionsFrame)
         cmds.frameLayout(label='Animation',cll=1)
         cmds.rowColumnLayout(numberOfColumns=2,cs=[(1,5),(2,5)],cw=[(1,350),(2,118)],cal=[(1,'right'),(2,'left')])
         
         cmds.text(label='Start Emission')
         self.startFrame = cmds.intField(minValue=0,width=60)
         cmds.text(label='End Emission')
         self.endFrame = cmds.intField(minValue=0,width=60,v=3)
         cmds.text(label='Maximum Distance')
         self.maxDistance = cmds.floatField(minValue=0,width=60,pre=3,v=8)
         cmds.text(label='Minimum Distance')
         self.minDistance = cmds.floatField(width=60,pre=3,v=-1)
         cmds.text(label='Maximum Angle')
         self.maxAngle = cmds.floatField(minValue=0,width=60,pre=3,v=15)
         cmds.text(label='Force Duration')
         self.forceTime = cmds.intField(minValue=0,width=60,v=10)
         cmds.text(label='Particle Lifetime')
         self.lifeTime = cmds.intField(minValue=0,width=60,v=40)
         cmds.text(label='Particle Lifetime Variation (%)')
         self.lifeTimeVar = cmds.intField(minValue=0,maxValue=100,width=60,v=20)
         cmds.text(label='Particle Fadeout')
         self.fadeOut = cmds.intField(minValue=0,width=60,v=3)
         cmds.text(label = 'Drift:')
         cmds.rowLayout(numberOfColumns = 6)
         cmds.text(label = 'X')
         self.driftX = cmds.floatField(width=30,pre=2,v=0.05)
         cmds.text(label = 'Y')
         self.driftY = cmds.floatField(width=30,pre=2,v=0.1)
         cmds.text(label = 'Z')
         self.driftZ = cmds.floatField(width=30,pre=2,v=0.05)
         cmds.setParent('..')
         cmds.text(label='Turbulence Amplitude')
         self.turbulenceAmp = cmds.floatField(minValue=0,width=60,pre=3,v=1)
         cmds.text(label='Turbulence Period')
         self.turbulencePer = cmds.intField(minValue=0,width=60,v=12)
         cmds.text(label='Source Plane Name')
         self.sourcePlane = cmds.textField(width=60)
         cmds.text(label='')
         cmds.button(label='Set Selected', c=self.updateSourcePlane)
         cmds.setParent('..')
         cmds.setParent('..')
         
         
         cmds.frameLayout(label='Particles',cll=1)
         cmds.rowColumnLayout(numberOfColumns=2,cs=[(1,5),(2,5)],cw=[(1,350),(2,118)],cal=[(1,'right'),(2,'left')])
         
         cmds.text(label='Number of Snowflakes')
         self.flakeNumber = cmds.intField(minValue=0,width=60,v=10)
         cmds.text(label='Snowflake Radius')
         self.flakeRadius = cmds.floatField(minValue=0,width=60,pre=3,v=0.2)
         cmds.text(label='Snowflake Radius Variation (%)')
         self.flakeRadiusVar = cmds.intField(minValue=0,maxValue=100,width=60,v=20)
         cmds.text(label='Number of Shards')
         self.shardNumber = cmds.intField(minValue=0,width=60,v=50)
         cmds.text(label='Shard Size')
         self.shardSize = cmds.floatField(minValue=0,width=60,pre=3,v=0.07)
         cmds.text(label='Shard Size Variation (%)')
         self.shardSizeVar = cmds.intField(minValue=0,width=60,v=20)
         cmds.text(label='Colour Range 1')
         self.colour1 = cmds.canvas( rgb=(0.82,0.87,0.94),width = 60,height=20,pc=self.updateColour1)
         cmds.text(label='Colour Range 2')
         self.colour2 = cmds.canvas( rgb=(0.83,0.82,0.92),width = 60,height=20,pc=self.updateColour2)
         cmds.text(label='Transparency')
         self.transparency = cmds.floatField(minValue=0,maxValue=1,width=60,pre=3,v=0.6)
         cmds.text(label='Glow Intensity')
         self.glow = cmds.floatField(minValue=0,maxValue=1,width=60,pre=3,v=0.15)
         cmds.setParent('..')
         cmds.setParent('..')
         
         
         cmds.button(label='Generate',width=100,c=self.runPlaneEmit)
         cmds.setParent('..')
     else:
         cmds.deleteUI(self.tmpFrame2)
     return
Exemple #34
0
    def populate_window(self):
        """
        This function creates the fields, sliders, etc contained in the window
        """

        tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5)
        '''
        ----------------------    Tab for Terrain Creation and its options ------------------------------------
        '''
        terrain_tab = cmds.columnLayout()

        # Main column layout inside the frame layout
        cmds.columnLayout(rowSpacing=2)

        self.make_separator(10)

        # Create the elements that will keep the general attributes for the terrain
        cmds.textFieldGrp(
            self.terrainName,
            label="Terrain Name",
            placeholderText="myTerrain",
            changeCommand=lambda new_val: self.update_value(
                new_val if new_val else "myTerrain", self.terrainName),
            ann="The desired name for the terrain that is being created.")
        cmds.intSliderGrp(
            self.dimensionSlider,
            label="Terrain Dimension",
            field=True,
            min=1,
            max=150,
            value=self.valueDictionary[self.dimensionSlider],
            changeCommand=lambda new_val: self.update_value(
                new_val, self.dimensionSlider),
            ann=
            "Width and height sized for the terrain. This tool creates square terrains."
        )
        cmds.intSliderGrp(
            self.subdivisionSlider,
            label="Terrain Subdivisions",
            field=True,
            min=1,
            max=150,
            value=self.valueDictionary[self.subdivisionSlider],
            changeCommand=lambda new_val: self.update_value(
                new_val, self.subdivisionSlider),
            ann=
            "Amount of subdivisions of the new terrain. Uniform for width and height."
        )

        self.make_separator(10)

        # Column layout to center the optionMenu
        cmds.columnLayout(columnAttach=('both', self.windowWidth / 8),
                          columnWidth=self.windowWidth)

        # Options for the user to choose terrain generation method
        cmds.optionMenu(
            self.methodField,
            label="Deformation Method",
            changeCommand=lambda new_val: self.update_value(
                new_val, self.methodField),
            ann="The method or algorithm used to deform the terrain.")
        cmds.menuItem(
            label="Random Soft Select",
            annotation=
            "Chooses random vertices with soft selection enabled and modifies their location"
        )
        cmds.menuItem(
            label="Value Noise",
            annotation=
            "Calculates value noise using the coordinates of each vertex")

        cmds.setParent('..')  # Exit Menu column Layout

        # Texture section
        self.make_separator(10)
        cmds.textFieldGrp(
            self.terrainShaderName,
            label="Terrain material Name",
            placeholderText="terrain_mat",
            changeCommand=lambda new_val: self.update_value(
                new_val if new_val else "terrain_mat", self.terrainShaderName),
            ann="The desired name for the material applied to the terrain.")

        cmds.columnLayout(columnAttach=('both', self.windowWidth / 8),
                          columnWidth=self.windowWidth)
        cmds.rowColumnLayout(numberOfColumns=3,
                             rowSpacing=(1, 5),
                             columnWidth=[(1, self.windowWidth / 4),
                                          (2, self.windowWidth / 4),
                                          (3, self.windowWidth / 4)],
                             columnAttach=[
                                 (1, 'both', self.windowWidth / 8 - 50),
                                 (2, 'both', self.windowWidth / 8 - 50),
                                 (3, 'both', self.windowWidth / 8 - 50)
                             ])
        cmds.text(label="Color Map")
        cmds.text(label="Normal Map")
        cmds.text(label="Specular Map")
        cmds.iconTextButton(
            self.terrainColorIcon,
            style='textOnly',
            w=100,
            h=100,
            bgc=(.2, .2, .2),
            command=lambda: self.update_icon(self.terrainColorIcon),
            ann="Texture used as Color Map in the material")
        cmds.iconTextButton(
            self.terrainNormalIcon,
            style='textOnly',
            w=100,
            h=100,
            bgc=(.2, .2, .2),
            command=lambda: self.update_icon(self.terrainNormalIcon),
            ann="Texture used as Normal Map in the material")
        cmds.iconTextButton(
            self.terrainSpecularIcon,
            style='textOnly',
            w=100,
            h=100,
            bgc=(.2, .2, .2),
            command=lambda: self.update_icon(self.terrainSpecularIcon),
            ann="Texture used as Specular Map in the material")
        cmds.setParent('..')  # Exit Row Layout
        cmds.setParent('..')  # Exit Centered column layout

        # Execute Creation buttons
        self.make_separator(10)
        cmds.columnLayout(columnAttach=('both', self.windowWidth / 8),
                          columnWidth=self.windowWidth)
        cmds.rowLayout(
            numberOfColumns=2,
            columnWidth2=[self.windowWidth / 2, self.windowWidth / 2])
        cmds.button(
            label="Create new terrain",
            width=self.windowWidth / 4,
            command=self.create_and_deform,
            ann="Creates a new terrain using the selected deformation method.")
        cmds.button(
            label="Add deformation",
            width=self.windowWidth / 4,
            command=self.just_deform,
            ann=
            "Adds another layer of deformation to the PREVIOUSLY created terrain with the selected method."
        )
        cmds.setParent('..')  # Exit Row Layout
        cmds.setParent('..')  # Exit Centered column layout

        cmds.setParent('..')  # Exit MAIN column layout
        cmds.setParent('..')  # Exit Frame Layout
        '''
        ----------------------------    Tab for Rock Creation and its options  --------------------------------
        '''
        rocks_tab = cmds.columnLayout()

        # Main column layout for rocks
        cmds.columnLayout(rowSpacing=2)
        self.make_separator(10)

        cmds.textFieldGrp(
            self.rocksName,
            label="Rocks Name",
            placeholderText="myRocks",
            changeCommand=lambda new_val: self.update_value(
                new_val if new_val else "myRocks", self.rocksName),
            ann=
            "Common name shared within all the rocks created. This tool groups the rocks inside a "
            "group with the same name with _grp suffix")
        cmds.intSliderGrp(self.rockSlider,
                          label="Rocks Amount",
                          field=True,
                          min=1,
                          max=100,
                          value=self.valueDictionary[self.rockSlider],
                          changeCommand=lambda new_val: self.update_value(
                              new_val, self.rockSlider),
                          ann="The amount of rocks generated")

        # Texture section
        self.make_separator(10)
        cmds.textFieldGrp(
            self.rocksShaderName,
            label="Rocks material Name",
            placeholderText="rocks_mat",
            changeCommand=lambda new_val: self.update_value(
                new_val if new_val else "rocks_mat", self.rocksShaderName),
            ann="The desired name for the material applied to the terrain.")
        cmds.columnLayout(columnAttach=('both', self.windowWidth / 8),
                          columnWidth=self.windowWidth)
        cmds.rowColumnLayout(numberOfColumns=2,
                             rowSpacing=(1, 5),
                             columnWidth=[(1, 3 * self.windowWidth / 8),
                                          (2, 3 * self.windowWidth / 8)],
                             columnAttach=[
                                 (1, 'both', 3 * self.windowWidth / 16 - 50),
                                 (2, 'both', 3 * self.windowWidth / 16 - 50)
                             ])
        cmds.text(label="Color Map")
        cmds.text(label="Normal Map")
        cmds.iconTextButton(
            self.rocksColorIcon,
            style='textOnly',
            w=100,
            h=100,
            bgc=(.2, .2, .2),
            command=lambda: self.update_icon(self.rocksColorIcon),
            ann="Texture used as Color Map in the material")
        cmds.iconTextButton(
            self.rocksNormalIcon,
            style='textOnly',
            w=100,
            h=100,
            bgc=(.2, .2, .2),
            command=lambda: self.update_icon(self.rocksNormalIcon),
            ann="Texture used as Normal Map in the material")
        cmds.setParent('..')  # Exit Row Layout

        self.make_separator(10)

        # Section for Ambient Color
        cmds.text(label="Ambient Color")
        cmds.separator(height=10, style="none")

        cmds.intSliderGrp(
            self.colorSlider,
            value=120,
            min=0,
            max=359,
            dc=lambda new_val: self.update_color(new_val, self.colorSlider))
        cmds.canvas("colorDisplay", backgroundColor=(0, 1, 0), w=50, h=50)

        cmds.separator(height=10, style="none")
        cmds.rowColumnLayout(numberOfColumns=2,
                             rowSpacing=(1, 5),
                             columnWidth=[(1, 3 * self.windowWidth / 8),
                                          (2, 3 * self.windowWidth / 8)],
                             columnAttach=[
                                 (1, 'both', 3 * self.windowWidth / 16 - 50),
                                 (2, 'both', 3 * self.windowWidth / 16 - 50)
                             ])
        cmds.text(label="Min Saturation:")
        cmds.text(label="Max Saturation:")
        cmds.floatField(
            self.minSaturation,
            max=1.0,
            min=0.0,
            changeCommand=lambda new_val: self.update_value(
                new_val, self.minSaturation),
            ann="Minimum saturation used by the ambient color attribute."
            "Make both values ZERO to use grayscale")
        cmds.floatField(
            self.maxSaturation,
            value=1,
            max=1.0,
            min=0.0,
            changeCommand=lambda new_val: self.update_value(
                new_val, self.maxSaturation),
            ann="Maximum saturation used by the ambient color attribute"
            "Make both values ZERO to use grayscal")
        cmds.setParent('..')  # Exit Row Layout

        cmds.separator(height=10, style="none")
        cmds.rowColumnLayout(numberOfColumns=2,
                             rowSpacing=(1, 5),
                             columnWidth=[(1, 3 * self.windowWidth / 8),
                                          (2, 3 * self.windowWidth / 8)],
                             columnAttach=[
                                 (1, 'both', 3 * self.windowWidth / 16 - 50),
                                 (2, 'both', 3 * self.windowWidth / 16 - 50)
                             ])
        cmds.text(label="Min Brightness:")
        cmds.text(label="Max Brightness:")
        cmds.floatField(
            self.minBrightness,
            max=1.0,
            min=0.0,
            changeCommand=lambda new_val: self.update_value(
                new_val, self.minBrightness),
            ann="Minimum brightness used by the ambient color attribute")
        cmds.floatField(
            self.maxBrightness,
            value=1,
            max=1.0,
            min=0.0,
            changeCommand=lambda new_val: self.update_value(
                new_val, self.maxBrightness),
            ann="Maximum brightness used by the ambient color attribute")
        cmds.setParent('..')  # Exit Row Layout

        cmds.setParent('..')  # Exit Centered column layout

        # Execution
        self.make_separator(10)
        # Button column layout
        cmds.columnLayout(columnAttach=('both', self.windowWidth / 8),
                          columnWidth=self.windowWidth)
        cmds.button(
            label="Create Rocks",
            align='right',
            width=self.windowWidth / 4,
            command=self.create_rocks,
            ann="Spawns the selected amount of rocks on the terrain's surface."
        )
        cmds.setParent('..')  # Exit Button Column Layout

        self.make_separator(10)

        cmds.setParent('..')  # Exit Main column Layout
        cmds.setParent('..')  # Exit Frame Layout
        '''
        ----------------------------------------------------------------------------------------------------------------
        '''
        cmds.tabLayout(tabs,
                       edit=True,
                       tabLabel=((terrain_tab, 'Terrain'), (rocks_tab,
                                                            'Rocks')))
        '''
        ------------------------------------ Development Tools ---------------------------------------------------------
        '''
        if logger.level == logging.DEBUG:
            cmds.frameLayout(label="Development Tools", bgc=(.5, 0, 0))
            cmds.gridLayout(nc=3, cellWidthHeight=(self.windowWidth / 3, 20))
            cmds.button(label="Delete Unused Nodes",
                        w=self.windowWidth / 3,
                        command=lambda x: mel.eval('MLdeleteUnused;'))
            cmds.button(label="Delete All Objects",
                        w=self.windowWidth / 3,
                        command=lambda x: cmds.delete(cmds.ls(dag=True)))
Exemple #35
0
def rigToolsUI(*args):
    if cmds.window("rigToolWin", exists=True):
        cmds.deleteUI("rigToolWin")

    widgets["win"] = cmds.window("rigToolWin", t="zbw_rigTools", w=280, rtf=True, s=True)
    widgets["mainCLO"] = cmds.columnLayout(w=280)
    widgets["mainFLO"] = cmds.formLayout(w=280, bgc = (0.1,0.1,0.1))

#controls layout
    widgets["ctrlFLO"] = cmds.formLayout(w=113, h=380, bgc = (0.3,0.3,0.3))
    widgets["ctrlFrLO"] = cmds.frameLayout(l="CONTROLS", w=113, h=380, bv=True, bgc = (0.3,0.3,0.3))
    widgets["ctrlCLO"] = cmds.columnLayout(bgc = (0.3,0.3,0.3))

    widgets["circleBut"] = cmds.button(l="circle", w=113, h=20, bgc=(.7, .7, .5), c = partial(control, "circle"))
    widgets["sphereBut"] = cmds.button(l="sphere", w=113, h=20, bgc=(.7, .7, .5), c = partial(control, "sphere"))
    widgets["squareBut"] = cmds.button(l="square", w=113, h=20, bgc=(.7, .7, .5), c = partial(control, "square"))
    widgets["boxBut"] = cmds.button(l="box", w=113, h=20, bgc=(.7, .7, .5), c = partial(control, "box"))
    widgets["lolBut"] = cmds.button(l="lollipop", w=113, h=20, bgc=(.7, .7, .5), c = partial(control, "lollipop"))
    widgets["barbellBut"] = cmds.button(l="barbell", w=113, h=20, bgc=(.7, .7, .5), c = partial(control, "barbell"))
    widgets["crossBut"] = cmds.button(l="cross", w=113, h=20, bgc=(.7, .7, .5), c = partial(control, "cross"))
    widgets["bentXBut"] = cmds.button(l="bent cross", h=20, w=113, bgc=(.7, .7, .5), c = partial(control, "bentCross"))
    widgets["arrowBut"] = cmds.button(l="arrow", w=113, h=20, bgc=(.7, .7, .5), c = partial(control, "arrow"))
    widgets["bentArrowBut"] = cmds.button(l="bent arrow", h=20, w=113, bgc=(.7, .7, .5), c = partial(control, "bentArrow"))
    widgets["splitOBut"] = cmds.button(l="split circle", h=20, w=113, bgc=(.7, .7, .5), c = partial(control, "splitCircle"))
    widgets["cylinderBut"] = cmds.button(l="cylinder", h=20, w=113, bgc=(.7, .7, .5), c = partial(control, "cylinder"))
    widgets["starBut"] = cmds.button(l="star", w=113, h=20, bgc=(.7, .7, .5), c = partial(control, "star"))
    widgets["octagonBut"] = cmds.button(l="octagon", h=20, w=113, bgc=(.7, .7, .5), c = partial(control, "octagon"))
    widgets["halfCircBut"] = cmds.button(l="half circle", h=20, w=113, bgc=(.7, .7, .5), c = partial(control, "halfCircle"))
    widgets["crossArrow"] = cmds.button(l="arrow cross", h=20, w=113, bgc=(.7, .7, .5), c = partial(control, "arrowCross"))	
    cmds.separator(h=10, style="none")
    widgets["ctrlAxisRBG"] = cmds.radioButtonGrp(nrb=3, la3=("x", "y", "z"), cw=([1, 33], [2, 33], [3, 33]), cal=([1, "left"], [2, "left"], [3, "left"]), sl=1)

#action layout
    cmds.setParent(widgets["mainFLO"])
    widgets["actionFLO"] = cmds.formLayout(w=150, h=380, bgc = (0.3,0.3,0.3))
    widgets["actionFrLO"] = cmds.frameLayout(l="ACTIONS", w=150, h=380, bv=True, bgc = (0.3,0.3,0.3))
    widgets["actionCLO"] = cmds.columnLayout(bgc = (0.3,0.3,0.3))
    widgets["grpFrzBut"] = cmds.button(l="group freeze selected", w=150, bgc=(.5, .7, .5), c = groupFreeze)
    widgets["grpAbvBut"] = cmds.button(l="insert group above ('Grp')", w=150, bgc=(.5, .7, .5), c = insertGroupAbove)
    widgets["grpCnctBut"] = cmds.button(l="group freeze connect", w=150, bgc=(.5, .7, .5), c = freezeAndConnect)
    widgets["slctHiBut"] = cmds.button(l="select hierarchy", w=150, bgc=(.5, .7, .5), c = selectHi)	
    widgets["prntChnBut"] = cmds.button(l="parent chain selected", w=150, bgc=(.5, .7, .5), c = parentChain)
    widgets["hideShp"] = cmds.button(l="selection toggle shape vis", w=150, bgc=(.5, .7, .5), c=hideShape)	
    widgets["slctCmptBut"] = cmds.button(l="select components", w=150, bgc=(.5, .7, .5), c = selectComponents)
    widgets["bBox"] = cmds.button(l="bounding box control", w=150, bgc=(.5, .7, .5), c=bBox)	
    widgets["cpSkinWtsBut"] = cmds.button(l="copy skin & weights", w=150, bgc=(.5, .7, .5), c = copySkinning)	
    widgets["remNSBut"] = cmds.button(l="remove all namespaces", w=150, bgc=(.5, .7, .5), c = remNS)	
    widgets["cntrLoc"] = cmds.button(l="selection center locator", w=150, bgc=(.5, .7, .5), c = center_locator)
    widgets["addToLat"] = cmds.button(l="add to lattice", w=150, bgc=(.5, .7, .5), c = addLattice)

#zScript Layout
    cmds.setParent(widgets["mainFLO"])
    widgets["zScrptFLO"] = cmds.formLayout(w=280, bgc = (0.3,0.3,0.3))
    widgets["zScrptFrLO"] = cmds.frameLayout(l="Z_SCRIPTS", w=280, bv=True, bgc = (0.3,0.3,0.3))
    cmds.setParent(widgets["zScrptFLO"])	
    widgets["attrBut"] = cmds.button(l="zbw_attrs", w=135, bgc = (.7, .5, .5), c=partial(zAction, "attr"))
    widgets["shpSclBut"] = cmds.button(l="zbw_shapeScale", w=135, bgc = (.7, .5, .5), c=partial(zAction, "shpScl"))
    widgets["selBufBut"] = cmds.button(l="zbw_selectionBuffer", w=135, bgc = (.7, .5, .5), c=partial(zAction, "selBuf"))
    widgets["snapBut"] = cmds.button(l="zbw_snap", w=135, bgc = (.7, .5, .5), c=partial(zAction, "snap"))
    widgets["smIKBut"] = cmds.button(l="zbw_smallIKStretch", w=135, bgc = (.7, .5, .5), c=partial(zAction, "smIK"))
    widgets["sftDefBut"] = cmds.button(l="zbw_softDeformers", w=135, bgc = (.7, .5, .5), c=partial(zAction, "soft"))
    widgets["follBut"] = cmds.button(l="zbw_makeFollicle", w=135, bgc = (.7, .5, .5), c=partial(zAction, "foll"))
    widgets["ribbonBut"] = cmds.button(l="zbw_ribbon", w=135, bgc = (.7, .5, .5), c=partial(zAction, "ribbon"))
    widgets["jntRadBut"] = cmds.button(l="zbw_jointRadius", w=135, bgc = (.7, .5, .5), c=partial(zAction, "jntRadius"))
    widgets["randSelect"] = cmds.button(l="zbw_randomSelection", w=135, bgc = (.7, .5, .5), c=partial(zAction, "randSelect"))
    widgets["trnBuffer"] = cmds.button(l="zbw_transformBuffer", w=135, bgc = (.7, .5, .5), c=partial(zAction, "trfmBuffer"))	
    widgets["crvTools"] = cmds.button(l="zbw_randomAttrs", w=135, bgc = (.7, .5, .5), c=partial(zAction, "rndAttr"))
    widgets["rndAttr"] = cmds.button(l="zbw_curveTools", w=135, bgc = (.7, .5, .5), c=partial(zAction, "crvTools"))	
    widgets["extrRig"] = cmds.button(l="curveExtrudeRig", w=135, bgc = (.7, .5, .5), c=partial(zAction, "extrRig"))	

#color layout
    cmds.setParent(widgets["mainFLO"])
    widgets["colorFLO"] = cmds.formLayout(w=280, h=66, bgc = (0.3,0.3,0.3))
    widgets["colorFrLO"] = cmds.frameLayout(l="COLORS", w=280, h=66, bv=True, bgc = (0.3,0.3,0.3))
    widgets["colorRCLO"] = cmds.rowColumnLayout(nc=6)
    #cmds.setParent(widgets["colorFLO"])
    widgets["redCNV"] = cmds.canvas(w=48, h=20, rgb=(1,0,0), pc=partial(changeColor, colors["red"]))
    widgets["blueCNV"] = cmds.canvas(w=48, h=20, rgb=(0,0,1), pc=partial(changeColor, colors["blue"]))
    widgets["greenCNV"] = cmds.canvas(w=48, h=20, rgb=(0,1,0), pc=partial(changeColor, colors["green"]))
    widgets["yellowCNV"] = cmds.canvas(w=48, h=20, rgb=(1,1,0), pc=partial(changeColor, colors["yellow"]))
    widgets["pinkCNV"] = cmds.canvas(w=48, h=20, rgb=(1,.8,.965), pc=partial(changeColor, colors["pink"]))
    widgets["ltBlueCNV"] = cmds.canvas(w=48, h=20, rgb=(.65,.8,1), pc=partial(changeColor, colors["ltBlue"]))
    widgets["brownCNV"] = cmds.canvas(w=48, h=20, rgb=(.5,.275,0), pc=partial(changeColor, colors["brown"]))
    widgets["purpleCNV"] = cmds.canvas(w=48, h=20, rgb=(.33,0,.33), pc=partial(changeColor, colors["purple"]))
    widgets["dkGreenCNV"] = cmds.canvas(w=48, h=20, rgb=(0,.35,0), pc=partial(changeColor, colors["dkGreen"]))
#---------------- add three more colors    

#formlayout stuff
    cmds.formLayout(widgets["mainFLO"], e=True, af=[
        (widgets["ctrlFLO"], "left", 0),
        (widgets["ctrlFLO"], "top", 0), 
        (widgets["actionFLO"], "left", 125),
        (widgets["actionFLO"], "top", 0),
        (widgets["zScrptFLO"], "left", 0),
        (widgets["zScrptFLO"], "top", 457),
        (widgets["colorFLO"], "left", 0),
        (widgets["colorFLO"], "top", 385),				
        ])

    cmds.formLayout(widgets["zScrptFLO"], e=True, af = [
        (widgets["attrBut"], "left", 0),
        (widgets["attrBut"], "top", 25),
        (widgets["selBufBut"], "left", 140),
        (widgets["selBufBut"], "top", 25),
        (widgets["shpSclBut"], "left", 0),
        (widgets["shpSclBut"], "top", 50),
        (widgets["snapBut"], "left", 140),
        (widgets["snapBut"], "top", 50),
        (widgets["smIKBut"], "left", 0),
        (widgets["smIKBut"], "top", 75),
        (widgets["sftDefBut"], "left", 140),
        (widgets["sftDefBut"], "top", 75),
        (widgets["follBut"], "left", 0),
        (widgets["follBut"], "top", 100),
        (widgets["ribbonBut"], "left", 140),
        (widgets["ribbonBut"], "top", 100),	
        (widgets["jntRadBut"], "left", 0),
        (widgets["jntRadBut"], "top", 125),
        (widgets["randSelect"], "left", 140),
        (widgets["randSelect"], "top", 125),
        (widgets["trnBuffer"], "left", 0),
        (widgets["trnBuffer"], "top", 150),						
        (widgets["rndAttr"], "left", 140),
        (widgets["rndAttr"], "top", 150),			
        (widgets["crvTools"], "left", 0),
        (widgets["crvTools"], "top", 175),	
        (widgets["extrRig"], "left", 140),
        (widgets["extrRig"], "top", 175),			
        ])	
    
    cmds.window(widgets["win"], e=True, rtf=True, w=5, h=5)
    cmds.showWindow(widgets["win"])
Exemple #36
0
 def _selectColor(self, name, *args):
     rgbV = cmds.canvas(name, q=1, rgbValue=1)
     cmds.canvas('colorDisplay', e=1, rgbValue=rgbV)
     functions.applyCurvesColor(utility.LineartosRGB(rgbV))
Exemple #37
0
def _refrTimeForm(obj):
    '''Aggiorna il form della timeline window.'''

    timeForm = obj + _timeFormSfx
    min = cmds.playbackOptions(q=True, min=True)
    max = cmds.playbackOptions(q=True, max=True)
    rng = max - min + 1.0
    currentFrame = cmds.currentTime(q=True)

    # rimuovi gli elementi del time form
    children = cmds.formLayout(timeForm, q=True, ca=True)
    if children:
        cmds.deleteUI(children)

    # rintraccia il nodo di parent
    pcNode = cmds.ls(_getParentConstraint(obj))
    if pcNode:
        pcNode = pcNode[0]
    else:
        # aggiorna le label
        cmds.text(obj + _labelSfx[0], e=True, l='%d' % currentFrame, w=50)
        cmds.text(obj + _labelSfx[1], e=True, l='')
        return

    # il main form e' il parent
    cmds.setParent(timeForm)

    # parametri per l'edit del form
    attachPositions = []
    attachForms = []

    # lista dei target
    targets = cmds.parentConstraint(pcNode, q=True, tl=True)
    for tid in range(len(targets)):
        times = cmds.keyframe('%s.w%d' % (pcNode, tid), q=True, tc=True)
        values = cmds.keyframe('%s.w%d' % (pcNode, tid), q=True, vc=True)

        # nessuna chiave, lista nulla e passa al successivo
        if not times:
            continue

        # indici dei tempi delle chiavi di attach/detach
        idxList = []
        check = True
        for v in range(len(values)):
            if values[v] == check:
                idxList.append(v)
                check = not check

        # deve funzionare anche se l'ultima chiave e' attached (quindi numero chiavi dispari)
        times.append(cmds.playbackOptions(q=True, aet=True) + 1.0)

        # ogni elemento di attach times e' relativo ad un particolare target ed e' una lista di questo tipo [[3,10], [12, 20]]
        timeRanges = [
            times[idxList[i]:idxList[i] + 2]
            for i in range(0, len(idxList), 2)
        ]

        hsvCol = _getColor(tid)

        # aggiungi i nuovi controlli
        for timeRange in timeRanges:
            # normalizza il timeRange
            normRange = [
                _timeFormDiv * (_crop(tr, min, max + 1) - min) / rng
                for tr in timeRange
            ]

            # se l'elemento e' stato croppato dal timerange passa al successivo
            if normRange[0] == normRange[1]:
                continue

            control = cmds.canvas(
                hsvValue=hsvCol,
                w=1,
                h=1,
                ann='%s [%d, %d]' %
                (targets[tid], timeRange[0], timeRange[1] - 1.0))
            for button in [1, 3]:
                cmds.popupMenu(mm=True, b=button)
                cmds.menuItem(l='[%s]' % targets[tid],
                              c='cmds.select(\'%s\')' % targets[tid],
                              rp='N')
                cmds.menuItem(l='Select child',
                              c='cmds.select(\'%s\')' % obj,
                              rp='S')
                cmds.menuItem(l='Fix snaps',
                              c='cmds.select(\'%s\')\n%s.fixSnap(True)' %
                              (obj, __name__),
                              rp='E')

            attachForms.extend([(control, 'top', 0), (control, 'bottom', 0)])
            attachPositions.extend([(control, 'left', 0, normRange[0]),
                                    (control, 'right', 0, normRange[1])])

    # current frame
    if currentFrame >= min and currentFrame <= max:
        frameSize = _timeFormDiv / rng
        normCf = frameSize * (currentFrame - min)
        currentTarget = _getActiveAttachTarget(pcNode)
        if not currentTarget:
            hsvCol = (0.0, 0.0, 0.85)
        else:
            hsvCol = _getColor(targets.index(currentTarget), 0.15)
        cf = cmds.canvas(hsvValue=hsvCol, w=1, h=1)

        attachForms.extend([(cf, 'top', 0), (cf, 'bottom', 0)])
        attachPositions.extend([(cf, 'left', 0, normCf),
                                (cf, 'right', 0, normCf + frameSize)])

    # setta i parametri del form
    cmds.formLayout(timeForm,
                    e=True,
                    attachForm=attachForms,
                    attachPosition=attachPositions)

    # aggiorna le label
    cmds.text(obj + _labelSfx[0], e=True, l='%d' % currentFrame, w=50)
    cmds.text(obj + _labelSfx[1],
              e=True,
              l='[%s]' % _getActiveAttachTarget(pcNode))
Exemple #38
0
 def _createCurves(self, shapes, *args):
     color = utility.LineartosRGB(
         cmds.canvas('colorDisplay', q=1, rgbValue=1))
     functions.createCurves(shapes, color)
Exemple #39
0
def createGUI(): 
    '''
    Creates a user interface for the city generator script.
    
    On exit: A window with the user interface has been created.
    '''    
    GUIwindow = cmds.window( title = "City Generator")
    layout0 = cmds.columnLayout()
    imageNum = random.randint(1,19)
    cmds.image("cityImage", image="cityImages/dayImage" + str(imageNum) + ".jpg", width = 800, height = 288 )
    layout1 = cmds.rowLayout(nc = 2, parent = layout0)
    layout2 = cmds.columnLayout(parent = layout1, rs = 3)
    cmds.rowLayout(nc = 2, parent = layout2, cw2 = [140,250])
    cmds.text(label = "City name")
    cmds.textField("cityName", width = 240)
    cmds.intSliderGrp("cityWidth", field=True, label="City width", minValue=50, maxValue=200, fieldMinValue=50, fieldMaxValue=200, value=100, cal = [1,"left"],parent = layout2)
    cmds.intSliderGrp("cityDepth", field=True, label="City depth", minValue=50, maxValue=200, fieldMinValue=50, fieldMaxValue=200, value=100, cal = [1,"left"],parent = layout2)
    cmds.intSliderGrp("minHeight", field=True, label="Minimum house height", minValue=4, maxValue=40, fieldMinValue=4, fieldMaxValue=40, value=4, cal = [1,"left"],parent = layout2, dc = changeMaxHeight)
    cmds.intSliderGrp("maxHeight", field=True, label="Maximum house height", minValue=4, maxValue=40, fieldMinValue=4, fieldMaxValue=40, value=30, cal = [1,"left"],parent = layout2, dc = changeMinHeight)
    cmds.intSliderGrp("minWidth", field=True, label="Minimum house width", minValue=2, maxValue=20, fieldMinValue=2, fieldMaxValue=20, value=5, cal = [1,"left"],parent = layout2, dc = changeMaxWidth)
    cmds.intSliderGrp("maxWidth", field=True, label="Maximum house width", minValue=12, maxValue=30, fieldMinValue=12, fieldMaxValue=30, value=20, cal = [1,"left"],parent = layout2, dc = changeMinWidth)
    cmds.checkBoxGrp("features", numberOfCheckBoxes=3, label1="Windows", label2 = "Booleans", label3="Deformers", v1=True, v2 = False, v3 = True, cc1 =  windows, cc2 = booleans, cal = [1,"left"],parent = layout2,cw = [1,140])
    cmds.checkBoxGrp("time", numberOfCheckBoxes=3, label1="Daytime", label2="Nighttime", label3 = "All windows glow", v1=True, v2 = False, v3 = False, enable3 = False, cal = [1,"left"], parent = layout2,cw = [1,140], cc1 = daytime, cc2 = nighttime )
    cmds.colorSliderGrp("environment", label="Environment colour", hsv=(204, 0.451, 1), parent = layout2, cal = [1,"left"] )
    layout3 = cmds.columnLayout(parent = layout1)
    cmds.text("Set the colour range for the houses by selecting the ranges separately for hue,\nsaturation and value.", align  = "left")
    cmds.text("\nStart of range:", align = "left")
    cmds.rowLayout( numberOfColumns=2, parent = layout3, cw2 = [70,200])
    cmds.canvas("hueCanvas1", hsvValue=(0, 1, 1), width=70, height=15)
    cmds.intSliderGrp("hue1", field=True, label="Hue", minValue=0, maxValue=360, fieldMinValue=0, fieldMaxValue=360, value=0,cw3 = [70,70,170], dc = hueChange1 )
    cmds.rowLayout( numberOfColumns=2, parent = layout3, cw2 = [70,200])
    cmds.canvas("saturationCanvas1", hsvValue=(0, 1, 1), width=70, height=15)
    cmds.floatSliderGrp("saturation1", field=True, label="Saturation", minValue=0, maxValue=1, fieldMinValue=0, fieldMaxValue=1, value=1,cw3 = [70,70,170], dc = saturationChange1, step = 0.01)
    cmds.rowLayout( numberOfColumns=2, parent = layout3, cw2 = [70,200])
    cmds.canvas("valueCanvas1", hsvValue=(0, 1, 1), width=70, height=15)
    cmds.floatSliderGrp("value1", field=True, label="Value", minValue=0, maxValue=1, fieldMinValue=0, fieldMaxValue=1, value=1,cw3 = [70,70,170], dc = valueChange1, step = 0.01)
    cmds.text("End of range:", align =  "left", parent = layout3)
    cmds.rowLayout( numberOfColumns=2, parent = layout3, cw2 = [70,200])
    cmds.canvas("hueCanvas2", hsvValue=(0, 1, 1), width=70, height=15)
    cmds.intSliderGrp("hue2", field=True, label="Hue", minValue=0, maxValue=360, fieldMinValue=0, fieldMaxValue=360, value=0,cw3 = [70,70,170], dc = hueChange2 )
    cmds.rowLayout( numberOfColumns=2, parent = layout3, cw2 = [70,200])
    cmds.canvas("saturationCanvas2", hsvValue=(0, 1, 1), width=70, height=15)
    cmds.floatSliderGrp("saturation2", field=True, label="Saturation", minValue=0, maxValue=1, fieldMinValue=0, fieldMaxValue=1, value=1,cw3 = [70,70,170], dc = saturationChange2, step = 0.01)
    cmds.rowLayout( numberOfColumns=2, parent = layout3, cw2 = [70,200])
    cmds.canvas("valueCanvas2", hsvValue=(0, 1, 1), width=70, height=15)
    cmds.floatSliderGrp("value2", field=True, label="Value", minValue=0, maxValue=1, fieldMinValue=0, fieldMaxValue=1, value=1,cw3 = [70,70,170], dc = valueChange2, step = 0.01)
    cmds.button(label = "Randomize", command = randomize, parent = layout3)
    layout4 = cmds.rowLayout(numberOfColumns=2, parent = layout0, cw2 = [690,110])
    cmds.button(label="Generate City", command = defaultButtonPush, parent = layout4, w = 685, h = 50)
    cmds.button(label="Clear Scene", command = clearScene, parent = layout4, w = 110, h = 50)
    cmds.showWindow()
Exemple #40
0
    def createMaterialsLayout(self):

        print("ML Log: createMaterialsLayout")
        # Create the tab and form layouts.
        self.materialsTab = cmds.tabLayout(borderStyle="full")
        self.materialsForm = cmds.formLayout(numberOfDivisions=100)

        # Add the icon size slider.
        iconSizeRow = cmds.rowLayout("RPRIconSize",
                                     numberOfColumns=2,
                                     columnWidth=(1, 22))
        cmds.image(image='material_browser/thumbnails.png')
        self.iconSizeSlider = cmds.intSlider(
            width=120,
            step=1,
            minValue=1,
            maxValue=4,
            value=self.getDefaultMaterialIconSize(),
            dragCommand=self.updateMaterialIconSize)
        cmds.setParent('..')

        # Add the search field.
        searchRow = cmds.rowLayout(numberOfColumns=2)
        cmds.image(image='material_browser/search.png')
        self.searchField = cmds.textField(
            placeholderText="Search...",
            width=250,
            height=22,
            textChangedCommand=self.searchMaterials)
        cmds.setParent('..')

        # Add help text.
        helpText = cmds.text(
            label=
            "To import a material, double click it, or select it and click the Import button."
        )

        # Add the background canvas.
        bg = cmds.canvas(rgbValue=self.backgroundColor)

        # Add the scroll layout that will contain the material icons.
        self.materialsContainer = cmds.scrollLayout(
            backgroundColor=self.backgroundColor,
            childResizable=True,
            resizeCommand=self.updateMaterialsLayout)
        cmds.setParent('..')

        # Assign the form to the tab.
        cmds.tabLayout(self.materialsTab,
                       edit=True,
                       tabLabel=((self.materialsForm, 'Materials')))

        # Lay out components within the form.
        cmds.formLayout(self.materialsForm,
                        edit=True,
                        attachForm=[(searchRow, 'top', 5),
                                    (searchRow, 'right', 5),
                                    (iconSizeRow, 'top', 10),
                                    (iconSizeRow, 'left', 6),
                                    (self.materialsContainer, 'left', 10),
                                    (self.materialsContainer, 'bottom', 10),
                                    (self.materialsContainer, 'right', 5),
                                    (bg, 'left', 5), (bg, 'bottom', 5),
                                    (bg, 'right', 5), (helpText, 'left', 10),
                                    (helpText, 'bottom', 8)],
                        attachNone=[(searchRow, 'bottom'), (searchRow, 'left'),
                                    (iconSizeRow, 'bottom'),
                                    (iconSizeRow, 'right'),
                                    (helpText, 'right'), (helpText, 'top')],
                        attachControl=[
                            (self.materialsContainer, 'top', 10, searchRow),
                            (self.materialsContainer, 'bottom', 10, helpText),
                            (bg, 'top', 5, searchRow),
                            (bg, 'bottom', 5, helpText)
                        ])

        cmds.setParent('..')
        cmds.setParent('..')

        # Initialize the currently selected category index.
        self.selectedCategoryIndex = 0
Exemple #41
0
def randomize(args):
    '''
    Randomizes the hue, saturation and value for both the start
    and the end of the colour range.
    
    args: Dummy argument needed to satisfy the command interface.
    On exit: Random values for hue, saturation and value have been
    picked for both the start and the end of the colour range. The 
    canvases and the sliders have been updated accordingly.
    '''
    rhue1 = random.randint(0,360)
    rsaturation1 = random.uniform(0,1)
    rvalue1 = random.uniform(0,1)
    rhue2 = random.randint(0,360)
    rsaturation2 = random.uniform(0,1)
    rvalue2 = random.uniform(0,1)
    cmds.intSliderGrp("hue1", edit = True, value = rhue1)
    cmds.floatSliderGrp("saturation1", edit = True, value = rsaturation1)
    cmds.floatSliderGrp("value1", edit = True, value = rvalue1)
    cmds.canvas("hueCanvas1", edit = True, hsvValue = (rhue1,1,1))
    cmds.canvas("saturationCanvas1", edit = True, hsvValue = (rhue1, rsaturation1,1))    
    cmds.canvas("valueCanvas1", edit = True, hsvValue = (rhue1, rsaturation1,rvalue1)) 
    cmds.intSliderGrp("hue2", edit = True, value = rhue2)
    cmds.floatSliderGrp("saturation2", edit = True, value = rsaturation2)
    cmds.floatSliderGrp("value2", edit = True, value = rvalue2)
    cmds.canvas("hueCanvas2", edit = True, hsvValue = (rhue2,1,1))
    cmds.canvas("saturationCanvas2", edit = True, hsvValue = (rhue2, rsaturation2,1))    
    cmds.canvas("valueCanvas2", edit = True, hsvValue = (rhue2, rsaturation2,rvalue2)) 
Exemple #42
-1
def color_picker(light, index, *args):
    """brings up the color picker UI to select a color for a light"""
    sel_light = cmds.listRelatives(cmds.textField(light + 'name', q=True, tx=True), s=True)[0]
    curr_color = cmds.getAttr(sel_light + '.color')
    cmds.colorEditor(rgbValue=curr_color[0])
    if cmds.colorEditor(query=True, result=True):
        values = cmds.colorEditor(query=True, rgb=True)
        cmds.setAttr(sel_light + '.color', *values)
        cmds.canvas(swatches[index], e=True, rgbValue=cmds.getAttr(sel_light + '.color')[0])
Exemple #43
-1
 def updateColour2(self):
     '''
     Opens a colour picker to allow the user to select a colour for the 1nd canvas
     '''
     cmds.colorEditor(rgb=cmds.canvas(self.colour2,q=1,rgb=1))
     if cmds.colorEditor(q=1,r=1):
         rgb=cmds.colorEditor(q=1,rgb=1)
         cmds.canvas(self.colour2,e=1,rgb=rgb)
     else:
         return