def paint_mode(self, *args): """ replaces the set value MEL script in the paint script tool """ paint_mode = cmds.radioCollection(self.mode_collection, q=True, select=True) cmds.rowLayout(self.volume_row, e=True, enable=False) cmds.button(self.floodButton, e=True, enable=True) if paint_mode == "conceal_radio": cmds.artUserPaintCtx("ngSkinToolsLayerPaintCtx", e=True, setValueCommand="ngSkinAlexUtilconceal") if paint_mode == "spread_radio": cmds.artUserPaintCtx("ngSkinToolsLayerPaintCtx", e=True, setValueCommand="ngSkinAlexUtilSpread") if paint_mode == "contrast_radio": cmds.artUserPaintCtx("ngSkinToolsLayerPaintCtx", e=True, setValueCommand="ngSkinAlexUtilContrast") if paint_mode == "gain_radio": cmds.artUserPaintCtx("ngSkinToolsLayerPaintCtx", e=True, setValueCommand="ngSkinAlexUtilGain") if paint_mode == "volume_radio": cmds.artUserPaintCtx("ngSkinToolsLayerPaintCtx", e=True, setValueCommand="ngSkinAlexUtilVolEq") cmds.rowLayout(self.volume_row, e=True, enable=True) cmds.button(self.floodButton, e=True, enable=False)
def exit(self, *args): """ exits tool and resets it to the ngSkinTools settings """ init_mel = Utils.createMelProcedure(ngLayerPaintCtxInitialize, [('string', 'mesh')], returnType='string') cmds.artUserPaintCtx("ngSkinToolsLayerPaintCtx", e=True, setValueCommand="ngLayerPaintCtxSetValue", initializeCmd=init_mel, finalizeCmd="ngLayerPaintCtxFinalize", value=self.defaultVal) cmds.rowColumnLayout(self.ng_radio_layout[0], e=True, enable=True) cmds.checkBox(self.ng_checkboxes[0], e=True, enable=True) cmds.checkBox(self.ng_checkboxes[1], e=True, enable=True) cmds.rowLayout(self.ng_slider_rows[0], e=True, enable=True) cmds.formLayout(self.radio_form, e=True, enable=False) cmds.button(self.floodButton, e=True, enable=False) cmds.rowLayout(self.intensity_row, e=True, enable=False) cmds.rowLayout(self.volume_row, e=True, enable=False) ng_paint_mode = [(self.ng_radio_buttons.index(i) + 1) for i in self.ng_radio_buttons if cmds.radioButton(i, q=True, select=True) is True] ng_intensity_value = cmds.floatSlider(self.ng_intensity[0], q=True, value=True) cmds.ngSkinLayer(paintOperation=ng_paint_mode[0], paintIntensity=ng_intensity_value)
def doStartPaint(self): if not cmds.artUserPaintCtx(self.TOOL_PAINT,exists=True): cmds.artUserPaintCtx(self.TOOL_PAINT); cmds.artUserPaintCtx(self.TOOL_PAINT,e=True, tsc=Utils.createMelProcedure(self.paintCtxSetupProcedure, [('string','toolContext')]), toolCleanupCmd=Utils.createMelProcedure(self.paintCtxCleanupProcedure, [('string','toolContext')]), initializeCmd="ngLayerPaintCtxInitialize", finalizeCmd="ngLayerPaintCtxFinalize", setValueCommand="ngLayerPaintCtxSetValue", getValueCommand="ngLayerPaintCtxGetValue", whichTool="userPaint", fullpaths = True ) self.configurePaintValues() cmds.setToolTo(self.TOOL_PAINT);
def configurePaintValues(self): ''' sets paint tool values from UI ''' oper,pvalue = self.getPaintModeValues() cmds.ngSkinLayer(paintOperation=oper,paintIntensity=pvalue.get()) if cmds.artUserPaintCtx(self.TOOL_PAINT,exists=True): # internally, use maya's "replace" brush with intensity of 1.0 cmds.artUserPaintCtx(self.TOOL_PAINT,e=True, selectedattroper='absolute', value=1.0, opacity=1.0, brushfeedback=False, accopacity=False, stampProfile=self.getSelectedBrushShape()) self.updateToTool()
def paint_tool_setup(self, *args): """ changes the initial settings for the paint script tool """ cmds.rowColumnLayout(self.ng_radio_layout[0], e=True, enable=False) cmds.checkBox(self.ng_checkboxes[0], e=True, enable=False) cmds.checkBox(self.ng_checkboxes[1], e=True, enable=False) cmds.rowLayout(self.ng_slider_rows[0], e=True, enable=False) cmds.formLayout(self.radio_form, e=True, enable=True) cmds.button(self.floodButton, e=True, enable=True) cmds.rowLayout(self.intensity_row, e=True, enable=True) cmds.artUserPaintCtx( "ngSkinToolsLayerPaintCtx", e=True, initializeCmd="ngSkinAlexUtilInitialize", finalizeCmd="ngSkinAlexUtilFinalize", ) self.intensity() self.match_volume() self.paint_mode()
def paint(): """ Initialize the smooth weight context, make sure to have a mesh selected with a skin cluster attached to it. Once this command is run the context will be set as the active tool. """ if not cmds.artUserPaintCtx(CONTEXT, query=True, exists=True): cmds.artUserPaintCtx(CONTEXT) cmds.artUserPaintCtx(CONTEXT, edit=True, ic=CONTEXT_INITIALIZE, svc=CONTEXT_UPDATE, whichTool="userPaint", fullpaths=True, outwhilepaint=True, brushfeedback=False, selectedattroper="additive") cmds.setToolTo(CONTEXT)
def configurePaintValues(self): ''' sets paint tool values from UI ''' oper, pvalue = self.getPaintModeValues() cmds.ngSkinLayer(paintOperation=oper, paintIntensity=pvalue.get(), paintMirror=self.controls.mirroredMode.isChecked()) from ngSkinTools import selectionState if self.controls.mirroredMode.isChecked( ) and selectionState.getLayersAvailable(): self.parentWindow.tabMirror.influenceMappingConfiguration.updateSelectionsInfluenceMapping( ) MllInterface().setPaintOptionRedistributeWeight( self.controls.redistributeWeightSetting.isChecked()) if cmds.artUserPaintCtx(self.TOOL_PAINT, exists=True): # internally, use maya's "replace" brush with intensity of 1.0 cmds.artUserPaintCtx( self.TOOL_PAINT, e=True, selectedattroper='absolute', value=1.0, opacity=1.0, brushfeedback=False, accopacity=False, usepressure=self.controls.stylusPressureOnOff.isChecked(), stampProfile=self.getSelectedBrushShape()) if self.controls.stylusPressureOnOff.isChecked(): try: cmds.artUserPaintCtx(self.TOOL_PAINT, e=True, mappressure=self.controls. stylusPressureMode.getSelectedText()) except: pass self.updateToTool()
def artUserPaintCtx(*args, **kwargs): if len(args): doPassSelf = kwargs.pop('passSelf', False) else: doPassSelf = False for key in ['cc', 'chunkCommand', 'gac', 'getArrayAttrCommand', 'getSurfaceCommand', 'getValueCommand', 'gsc', 'gvc', 'sac', 'setArrayValueCommand', 'setValueCommand', 'svc']: try: cb = kwargs[key] if callable(cb): kwargs[key] = _factories.makeUICallback(cb, args, doPassSelf) except KeyError: pass res = cmds.artUserPaintCtx(*args, **kwargs) return res
def updateToTool(self): ''' update controls to current tool ''' isPainting = self.isPainting() cmds.control(self.cmdLayout.innerLayout,e=True,enable=isPainting) cmds.button(self.cmdLayout.buttons[1],e=True,label="Flood" if isPainting else "Paint") if (isPainting): self.controls.brushRadiusSlider.setValue(cmds.artUserPaintCtx(self.TOOL_PAINT,q=True,radius=True)) self.controls.brushRadiusSlider.setEnabled(isPainting) layersAvailable = LayerDataModel.getInstance().layerDataAvailable cmds.layout(self.cmdLayout.buttonForm,e=True,enable=layersAvailable)
def changeBrushRadius(self): if cmds.artUserPaintCtx(self.TOOL_PAINT,exists=True): cmds.artUserPaintCtx(self.TOOL_PAINT,e=True, radius=self.controls.brushRadiusSlider.getValue())
def intensity(self, *args): """ sets the value slider of the paint script tool to this amount """ intensity = cmds.floatSlider(self.extra_slider, q=True, value=True) cmds.artUserPaintCtx("ngSkinToolsLayerPaintCtx", e=True, value=intensity)
def match_volume(self, *args): radius = cmds.artUserPaintCtx("ngSkinToolsLayerPaintCtx", q=True, radius=True) cmds.floatField(self.volume_field, e=True, value=radius) cmds.floatSlider(self.volume_slider, e=True, value=radius)
brushValue = linearInterpolation(oldWeight, 0, averagedWeight, 1, val) cmds.setAttr('{}.weightList[{}].weights[{}]'.format(skc, index, ji), brushValue) # set the init mel script mel.eval(''' global proc string smoothSkinWeightsCtx(string $context){ python ("smoothSkinWeightsSetup()"); return $context; } global proc string smoothSkinWeightsInit(string $name) { return ("-dt worldV -n local"); } global proc smoothSkinWeightsFinish( int $slot ){ } global proc smoothSkinWeights(int $slot, int $index, float $val, float $Dx, float $Dy, float $Dz, float $Nx, float $Ny, float $Nz) { python ("smoothVertexWeight(\"+$index+\", \"+ $val +\")\"); }''') if skc: cmds.ScriptPaintTool() cmds.artUserPaintCtx( cmds.currentCtx(), e=True, tsc='smoothSkinWeightsCtx', ic='smoothSkinWeightsInit', fc='smoothSkinWeightsFinish', svc='smoothSkinWeights', )