Пример #1
0
 def createRamp( self, attr ):
     #Create the control fields
     pm.columnLayout( )
     
     cmds.rowLayout(nc=2, cw2=(142,220))
     pm.text("Shutter Curve");
     pm.text(" ");
     pm.cmds.setParent('..')
     
     cmds.rowLayout("ShutterCurveRowLayout",nc=2, cw2=(142,220))
     
     pm.columnLayout("ShutterCurveColumLayout")
     cmds.rowLayout("ShutterCurveValueLayout", nc=2, cw2=(60,45))
     pm.text("Value");
     valueField = pm.floatField("ShutterCurveValueField");
     pm.cmds.setParent('..')
     
     pm.rowLayout("ShutterCurvePositionLayout", nc=2, cw2=(60,45))
     pm.text("Position");
     
     positionField = cmds.floatField("ShutterCurvePositionField");
     pm.cmds.setParent('..')
     
     '''pm.rowLayout(nc=2, cw2=(60,65))
     pm.text("Interpol.");
     pm.optionMenu(changeCommand=self.updateRamp )
     pm.menuItem( label='None' )
     pm.menuItem( label='Linear' )
     pm.menuItem( label='Smooth' )
     pm.menuItem( label='Spline' )
     pm.cmds.setParent('..')'''
     pm.cmds.setParent('..')
     
     gradient = pm.gradientControlNoAttr("ShutterCurveGradientControl", w=200, h=100 )
     pm.gradientControlNoAttr( gradient, edit=True, changeCommand=pm.Callback(self.syncAttribute,attr,gradient, valueField, positionField) )
     
     #Initialize the curve with the values in the attribute
     curveString = ""
     attr = self.nodeAttr('aiShutterCurve')
     size = cmds.getAttr(attr, size=True)
     startX = 0
     startY = 1
     if size > 0:
         x = cmds.getAttr(attr+'[0].aiShutterCurveX')
         y = cmds.getAttr(attr+'[0].aiShutterCurveY')
         startX = x
         startY = y
         curveString += str(y) +"," + str(x) +",1"
     else:
         curveString += "1,0,1"
     for i in range(1,size):
         x = cmds.getAttr(attr+'['+str(i)+'].aiShutterCurveX')
         y = cmds.getAttr(attr+'['+str(i)+'].aiShutterCurveY')
         curveString += ","+str(y) +"," + str(x) +",1"
         
     cmds.gradientControlNoAttr( gradient, edit=True, asString=curveString) 
     
     pm.floatField(valueField, edit=True, value=startY, changeCommand=pm.Callback(self.updateValue, attr, gradient, valueField, positionField))
     pm.floatField(positionField, edit=True, value=startX, changeCommand=pm.Callback(self.updatePosition, attr, gradient, valueField, positionField))
Пример #2
0
 def callback(cmd, _):
     if not (cmd.count('softSelect ') and pm.window('softselectskin', exists=True)): return
     current_radius = pm.softSelect(q=True, softSelectDistance=True)
     current_curve = pm.softSelect(q=True, softSelectCurve=True)
     try:
         pm.floatSliderGrp(slider, e=True, value=current_radius)
         pm.gradientControlNoAttr(curve, e=True, asString=current_curve)
     except NameError:
         pass
Пример #3
0
 def updatePosition(self, attr, control, valueField, positionField):
     value = pm.floatField(positionField, query=True, value=True)
     
     values = cmds.gradientControlNoAttr( control, query=True, asString=True) 
     valuesSplit = values.split(',')
         
     current = cmds.gradientControlNoAttr( control, query=True, currentKey=True) 
     
     valuesSplit[current*3+1] = str(value)
     values = ",".join(valuesSplit)
     
     pm.gradientControlNoAttr( control, edit=True, asString=values)
     self.syncAttribute(attr, control, valueField, positionField)
    def updatePosition(self, attr, control, valueField, positionField):
        value = pm.floatField(positionField, query=True, value=True)

        values = cmds.gradientControlNoAttr(control, query=True, asString=True)
        valuesSplit = values.split(',')

        current = cmds.gradientControlNoAttr(control,
                                             query=True,
                                             currentKey=True)

        valuesSplit[current * 3 + 1] = str(value)
        values = ",".join(valuesSplit)

        pm.gradientControlNoAttr(control, edit=True, asString=values)
        self.syncAttribute(attr, control, valueField, positionField)
Пример #5
0
def function(function, inputVal):
    if function == "Linear":
        return inputVal
    if function == "Quadratic":
        return inputVal * inputVal
    if function == "Ramp":
        return pm.gradientControlNoAttr('falloffCurve', q=True, vap=inputVal)
        raise Exception('Not implemented')
    else:
        raise Exception('Not a valid function')
Пример #6
0
    def create_layout(self):
        self.win = pm.window(title="Cluster Weight Interpolation")
        layout = pm.rowColumnLayout(numberOfColumns=2,
                                    columnAttach=(1, 'right', 0),
                                    columnWidth=[(1, 150), (2, 250)],
                                    rowOffset=(6, "bottom", 15),
                                    rowSpacing=(1, 10),
                                    columnSpacing=(2, 15))
        #chkBox = pm.checkBox(label = "My Checkbox", value=True, parent=layout)

        #Set up weight inputs
        pm.text(label="Min Weight")
        self.minWeight = pm.textField()
        pm.text(label="Max Weight")
        self.maxWeight = pm.textField()

        #Set up cluster Menu
        pm.text(label='Cluster')
        self.clusterMenu = pm.optionMenu()
        clusterList = hybridClusterList(self.vertList)
        for c in clusterList:
            pm.menuItem(label=str(c))

        #Set up Equation Menu
        pm.text(label='Equation')
        self.functionMenu = pm.optionMenu()
        pm.menuItem(label='Ramp')
        pm.menuItem(label='Linear')
        pm.menuItem(label='Quadratic')

        #Set up Ramp
        #TODO is there a way that we can hide or disable this thing if the user should select to use the Linear or Quadratic options?
        pm.text(label='Ramp Value')
        pm.optionVar(stringValueAppend=['falloffCurveOptionVar', '0,1,2'])
        pm.optionVar(stringValueAppend=['falloffCurveOptionVar', '1,0,2'])
        pm.gradientControlNoAttr('falloffCurve', h=90)
        self.ramp = pm.gradientControlNoAttr('falloffCurve',
                                             e=True,
                                             optionVar='falloffCurveOptionVar')

        pm.text(label='Invert')
        self.invert = pm.optionMenu()
        pm.menuItem(label='Yes')
        pm.menuItem(label='No')

        #Set up Axis Menu
        pm.text(label='Axies for Dist Measurement')
        self.interpolationAxis = pm.optionMenu()
        pm.menuItem(label='xyz')
        pm.menuItem(label='x')
        pm.menuItem(label='y')
        pm.menuItem(label='z')
        pm.menuItem(label='xy')
        pm.menuItem(label='xz')
        pm.menuItem(label='yz')
        pm.menuItem(label='Point Number')

        #Set up Buttons
        closeBtn = pm.button(label="Close", parent=layout)
        interpolateBtn = pm.button(label="Interpolate", parent=layout)

        interpolateBtn.setCommand(lambda *args: self.interpolate())
        closeBtn.setCommand(lambda *args: self.close_dialog())
Пример #7
0
def show():

    pm.loadPlugin('%s/sss-plug-ins.py' % os.path.dirname(__file__), quiet=True)

    if pm.window('softselectskin', exists=True):
        pm.deleteUI('softselectskin')
    with pm.window('softselectskin', **main_window_flags) as win:
        with pm.formLayout('main_form') as main_layout:
            with pm.frameLayout('softselect_frame', **softselect_frame_flags) as softselect_framelayout:
                with pm.formLayout('softselect_form') as lyt:
                    current_radius = pm.softSelect(q=True, softSelectDistance=True)
                    current_curve = pm.softSelect(q=True, softSelectCurve=True)
                    slider = pm.floatSliderGrp('fsg_radius', value=current_radius, **falloff_radius_slider_flags)
                    with pm.formLayout('curve_formlayout') as curve_formlayout:
                        curve_display = pm.text('curve_display', **falloff_curve_display_flags)
                        curve = pm.gradientControlNoAttr('gc_curve', asString=current_curve, **falloff_curve_flags)

                        attach = {
                            'e': True,
                            'attachForm': [
                                (curve_display, 'top', 0),
                                (curve_display, 'bottom', 0),
                                (curve_display, 'left', 0),
                                (curve, 'top', 0),
                                (curve, 'bottom', 0),
                                (curve, 'right', 0),
                            ],
                            'attachControl': [
                                (curve, 'left', 0, curve_display),
                            ]
                        }

                        pm.formLayout(curve_formlayout, **attach)

                    callback = softselect_changed_callback_generator(slider, curve)
                    callback_id = om.MCommandMessage.addCommandCallback(callback)

                    attach = {
                        'e': True,
                        'attachForm': [
                            (slider, 'top', 5),
                            (slider, 'left', 5),
                            (slider, 'right', 5),
                            (curve_formlayout, 'left', 5),
                            (curve_formlayout, 'right', 5),
                        ],
                        'attachControl': [
                            (curve_formlayout, 'top', 5, slider),
                        ]
                    }

                    pm.formLayout(lyt, **attach)

            with pm.frameLayout('skeleton_frame', **skeleton_frame_flags) as skeleton_framelayout:
                with pm.formLayout('skeleton_formlayout') as skeleton_formlayout:
                    tsl = pm.textScrollList('skeleton_list', **skeleton_list_flags)
                    callback = selection_changed_callback_generator(tsl)
                    pm.scriptJob(event=['SelectionChanged', callback], parent=win)

                    attach = {
                        'e': True,
                        'attachForm': [
                            (tsl, 'top', 5),
                            (tsl, 'left', 5),
                            (tsl, 'right', 5),
                        ],
                    }

                    pm.formLayout(skeleton_formlayout, **attach)

            attach = {
                'e': True,
                'attachForm': [
                    (softselect_framelayout, 'top', 5),
                    (softselect_framelayout, 'left', 5),
                    (softselect_framelayout, 'right', 5),
                    (skeleton_framelayout, 'left', 5),
                    (skeleton_framelayout, 'right', 5),
                ],
                'attachControl': [
                    (skeleton_framelayout, 'top', 5, softselect_framelayout),
                ]
            }

            pm.formLayout(main_layout, **attach)

    omui.MUiMessage.addUiDeletedCallback(win, lambda *_: om.MMessage.removeCallback(callback_id))
    def createRamp(self, attr):
        #Create the control fields
        pm.columnLayout()

        cmds.rowLayout(nc=2, cw2=(142, 220))
        pm.text("Shutter Curve")
        pm.text(" ")
        pm.cmds.setParent('..')

        cmds.rowLayout("ShutterCurveRowLayout", nc=2, cw2=(142, 220))

        pm.columnLayout("ShutterCurveColumLayout")
        cmds.rowLayout("ShutterCurveValueLayout", nc=2, cw2=(60, 45))
        pm.text("Value")
        valueField = pm.floatField("ShutterCurveValueField")
        pm.cmds.setParent('..')

        pm.rowLayout("ShutterCurvePositionLayout", nc=2, cw2=(60, 45))
        pm.text("Position")

        positionField = cmds.floatField("ShutterCurvePositionField")
        pm.cmds.setParent('..')
        '''pm.rowLayout(nc=2, cw2=(60,65))
        pm.text("Interpol.");
        pm.optionMenu(changeCommand=self.updateRamp )
        pm.menuItem( label='None' )
        pm.menuItem( label='Linear' )
        pm.menuItem( label='Smooth' )
        pm.menuItem( label='Spline' )
        pm.cmds.setParent('..')'''
        pm.cmds.setParent('..')

        gradient = pm.gradientControlNoAttr("ShutterCurveGradientControl",
                                            w=200,
                                            h=100)
        pm.gradientControlNoAttr(gradient,
                                 edit=True,
                                 changeCommand=pm.Callback(
                                     self.syncAttribute, attr, gradient,
                                     valueField, positionField))

        #Initialize the curve with the values in the attribute
        curveString = ""
        attr = self.nodeAttr('aiShutterCurve')
        size = cmds.getAttr(attr, size=True)
        startX = 0
        startY = 1
        if size > 0:
            x = cmds.getAttr(attr + '[0].aiShutterCurveX')
            y = cmds.getAttr(attr + '[0].aiShutterCurveY')
            startX = x
            startY = y
            curveString += str(y) + "," + str(x) + ",1"
        else:
            curveString += "1,0,1"
        for i in range(1, size):
            x = cmds.getAttr(attr + '[' + str(i) + '].aiShutterCurveX')
            y = cmds.getAttr(attr + '[' + str(i) + '].aiShutterCurveY')
            curveString += "," + str(y) + "," + str(x) + ",1"

        cmds.gradientControlNoAttr(gradient, edit=True, asString=curveString)

        pm.floatField(valueField,
                      edit=True,
                      value=startY,
                      changeCommand=pm.Callback(self.updateValue, attr,
                                                gradient, valueField,
                                                positionField))
        pm.floatField(positionField,
                      edit=True,
                      value=startX,
                      changeCommand=pm.Callback(self.updatePosition, attr,
                                                gradient, valueField,
                                                positionField))