def createUI(self, parent): from ngSkinTools.ui.mainwindow import MainWindow mainActions = MainWindow.getInstance().actions self.setTitle('Mirror') # base layout self.cmdLayout = self.createCommandLayout( [('Mirror Weights', mainActions.mirrorWeights, '')], SkinToolsDocs.UI_TAB_MIRROR) self.mirroringOptions = VertexMirroringOptions() self.mirroringOptions.createUI(self.cmdLayout.innerLayout) #configurationGroup = self.createUIGroup(self.cmdLayout.innerLayout, 'Configuration',defaultCollapsed=True) self.vertexMappingConfiguration = VertexMappingConfiguration() self.vertexMappingConfiguration.createUI( parent=self.cmdLayout.innerLayout) self.influenceMappingConfiguration = InfluencesMappingConfiguration() self.influenceMappingConfiguration.createUI( parent=self.cmdLayout.innerLayout) def update(): cmds.layout(self.cmdLayout.outerLayout.layout, e=True, enable=selectionState.getLayersAvailable()) selectionState.selectionInfo.changed.addHandler(update, parent) update() return self.cmdLayout.outerLayout.layout
def createInfluenceListRMBMenu(self): from ngSkinTools.ui.mainwindow import MainWindow actions = MainWindow.getInstance().actions self.controls.inflListMenu = cmds.popupMenu( parent=self.controls.influenceDisplay.control ) actions.copyWeights.newMenuItem('Copy Influence Weights') actions.cutWeights.newMenuItem('Cut Influence Weights') actions.pasteWeightsAdd.newMenuItem('Paste Weights (Add)') actions.pasteWeightsReplace.newMenuItem('Paste Weights (Replace)') cmds.menuItem( divider=True) cmds.radioMenuItemCollection() self.controls.menuAllInfluences = cmds.menuItem(label='List All Influences', enable=True, radioButton=True,command=self.influenceMenuChangeCommand ) self.controls.menuActiveInfluences = cmds.menuItem(label='List Only Active Influences', enable=True, radioButton=False,command=self.influenceMenuChangeCommand ) cmds.menuItem( divider=True) actions.convertMaskToTransparency.newMenuItem('Convert Mask to Transparency') actions.convertTransparencyToMask.newMenuItem('Convert Transparency to Mask') cmds.menuItem( divider=True) actions.influenceFilter.newMenuItem('Show/Hide Influence Filter')
def execute(self): ''' button handler for "Mirror Skin Weights" ''' from ngSkinTools.ui.mainwindow import MainWindow mirrorTab = MainWindow.getInstance().tabMirror mirrorTab.executeMirror()
def createInfluenceListRMBMenu(self): from ngSkinTools.ui.mainwindow import MainWindow actions = MainWindow.getInstance().actions self.controls.inflListMenu = cmds.popupMenu( parent=self.controls.influenceDisplay.control) actions.copyWeights.newMenuItem('Copy Influence Weights') actions.cutWeights.newMenuItem('Cut Influence Weights') actions.pasteWeightsAdd.newMenuItem('Paste Weights (Add)') actions.pasteWeightsReplace.newMenuItem('Paste Weights (Replace)') cmds.menuItem(divider=True) cmds.radioMenuItemCollection() self.controls.menuAllInfluences = cmds.menuItem( label='List All Influences', enable=True, radioButton=True, command=self.influenceMenuChangeCommand) self.controls.menuActiveInfluences = cmds.menuItem( label='List Only Active Influences', enable=True, radioButton=False, command=self.influenceMenuChangeCommand) cmds.menuItem(divider=True) actions.convertMaskToTransparency.newMenuItem( 'Convert Mask to Transparency') actions.convertTransparencyToMask.newMenuItem( 'Convert Transparency to Mask') cmds.menuItem(divider=True) actions.influenceFilter.newMenuItem('Show/Hide Influence Filter')
def execute(self): ''' button handler for "Mirror Skin Weights" ''' from ngSkinTools.ui.mainwindow import MainWindow from ngSkinTools.ui.tabMirror import TabMirror # any problems? maybe cache is not initialized/outdated? layerData = LayerDataModel.getInstance() layerData.updateMirrorCacheStatus() if not layerData.mirrorCache.isValid: Utils.displayError(layerData.mirrorCache.message) return False try: mirrorTab = MainWindow.getInstance().tabMirror mirrorDirection = MirrorDirection.DIRECTION_POSITIVETONEGATIVE if mirrorTab.controls.mirrorDirection.getValue() == 0: # guess mirrorDirection = MirrorDirection.DIRECTION_GUESS if mirrorTab.controls.mirrorDirection.getValue( ) == 2: # negative to positive mirrorDirection = MirrorDirection.DIRECTION_NEGATIVETOPOSITIVE if mirrorTab.controls.mirrorDirection.getSelectedText( ) == TabMirror.MIRROR_FLIP: mirrorDirection = MirrorDirection.DIRECTION_FLIP with LayerDataModel.getInstance().mll.batchUpdateContext(): for layerId in LayerDataModel.getInstance( ).layerListsUI.getSelectedLayers(): LayerDataModel.getInstance().mll.mirrorLayerWeights( layerId, mirrorWidth=mirrorTab.controls.mirrorWidth.getValue(), mirrorLayerWeights=mirrorTab.controls.mirrorWeights. getValue(), mirrorLayerMask=mirrorTab.controls.mirrorMask.getValue( ), mirrorDualQuaternion=mirrorTab.controls.mirrorDq. getValue(), mirrorDirection=mirrorDirection) # if layer list is filtered, might be handy to refresh influence list now - not that it costs much LayerEvents.influenceListChanged.emit() return True except: import traceback traceback.print_exc() Utils.displayError("unknown error") # we're not sure what's wrong in this case, just re-raise raise
def createLayersListRMBMenu(self): from ngSkinTools.ui.mainwindow import MainWindow self.controls.layerListMenu = cmds.popupMenu( parent=self.controls.layerDisplay.control ) actions = MainWindow.getInstance().actions actions.newLayer.newMenuItem("New Layer...") actions.duplicateLayer.newMenuItem("Duplicate Selected Layer(s)") actions.deleteLayer.newMenuItem("Delete Selected Layer(s)") cmds.menuItem( divider=True) actions.moveLayerUp.newMenuItem("Move Current Layer Up") actions.moveLayerDown.newMenuItem("Move Current Layer Down") actions.enableDisableLayer.newMenuItem("Toggle Layer On/Off") cmds.menuItem( divider=True) actions.layerProperties.newMenuItem("Properties...")
def createLayersListRMBMenu(self): from ngSkinTools.ui.mainwindow import MainWindow self.controls.layerListMenu = cmds.popupMenu( parent=self.controls.layerDisplay.control) actions = MainWindow.getInstance().actions actions.newLayer.newMenuItem("New Layer...") actions.duplicateLayer.newMenuItem("Duplicate Selected Layer(s)") actions.deleteLayer.newMenuItem("Delete Selected Layer(s)") cmds.menuItem(divider=True) actions.moveLayerUp.newMenuItem("Move Current Layer Up") actions.moveLayerDown.newMenuItem("Move Current Layer Down") actions.enableDisableLayer.newMenuItem("Toggle Layer On/Off") cmds.menuItem(divider=True) actions.layerProperties.newMenuItem("Properties...")
def execute(self): ''' button handler for "Mirror Skin Weights" ''' from ngSkinTools.ui.mainwindow import MainWindow from ngSkinTools.ui.tabMirror import TabMirror # any problems? maybe cache is not initialized/outdated? layerData = LayerDataModel.getInstance() layerData.updateMirrorCacheStatus() if not layerData.mirrorCache.isValid: Utils.displayError(layerData.mirrorCache.message) return False try: mirrorTab = MainWindow.getInstance().tabMirror mirrorDirection = MirrorDirection.DIRECTION_POSITIVETONEGATIVE if mirrorTab.controls.mirrorDirection.getValue()==0: # guess mirrorDirection = MirrorDirection.DIRECTION_GUESS; if mirrorTab.controls.mirrorDirection.getValue()==2: # negative to positive mirrorDirection = MirrorDirection.DIRECTION_NEGATIVETOPOSITIVE; if mirrorTab.controls.mirrorDirection.getSelectedText()==TabMirror.MIRROR_FLIP: mirrorDirection = MirrorDirection.DIRECTION_FLIP; with LayerDataModel.getInstance().mll.batchUpdateContext(): for layerId in LayerDataModel.getInstance().layerListsUI.getSelectedLayers(): LayerDataModel.getInstance().mll.mirrorLayerWeights(layerId, mirrorWidth=mirrorTab.controls.mirrorWidth.getValue(), mirrorLayerWeights=mirrorTab.controls.mirrorWeights.getValue(), mirrorLayerMask=mirrorTab.controls.mirrorMask.getValue(), mirrorDualQuaternion=mirrorTab.controls.mirrorDq.getValue(), mirrorDirection=mirrorDirection ) # if layer list is filtered, might be handy to refresh influence list now - not that it costs much LayerEvents.influenceListChanged.emit() return True except: import traceback;traceback.print_exc(); Utils.displayError("unknown error") # we're not sure what's wrong in this case, just re-raise raise
def commandButtons(): yield ('Mirror',MainWindow.getInstance().actions.mirrorWeights,'') yield ('Paint',self.execPaint,'')
def execute(self): from ngSkinTools.ui.mainwindow import MainWindow MainWindow.getInstance().targetUI.layersUI.filterUi.toggle() self.onExecuted.emit(True)
def execute(self): from ngSkinTools.ui.mainwindow import MainWindow MainWindow.getInstance().targetUI.layersUI.filterUi.toggle() self.onExecuted.emit(True)
def commandButtons(): yield ('Mirror',MainWindow.getInstance().actions.mirrorWeights,'') yield ('Paint',self.execPaint,'')
def copySkinLayers(self, *args): ''' ''' uv = None #======================================================================= # get layers that we want to copy #======================================================================= # print 'selLayers: ', self.controls.selLayers.getValue() if self.controls.selLayers.getValue(): # if set to "Selected layers in lister" layerLister = MainWindow.getInstance().targetUI.layersUI.getSelectedLayers() # print 'LayerLister: ', layerLister else: # use all layers layerLister = [] #=================================================================== # surface association #=================================================================== if self.controls.radioClosestPoint.getValue(): surfaceAssociation = 'closestPoint' elif self.controls.radioRaycast.getValue(): surfaceAssociation = 'rayCast' elif self.controls.radioClosestComponent.getValue(): surfaceAssociation = 'closestComponent' elif self.controls.radioUVSpace.getValue(): surfaceAssociation = 'closestPoint' uvSets = mc.polyUVSet(q=True, currentUVSet=True) if len(uvSets) > 0: srcSet = uvSets[0] destSet = uvSets[-1] uv = srcSet, destSet else: mc.warning('Unknown surface association') sampleSpace = self.controls.sampleSpace.getValue() #======================================================================= # influence association #======================================================================= associationNameMap = {'None': None, 'Closest joint': 'closestJoint', 'Closest bone': 'closestBone', 'One to one': 'oneToOne', 'Label': 'label', 'Name': 'name'} influenceAssociation = [] for index in range(3): association = self.controls.__dict__['influenceAssoc%d' % (index+1)].getSelectedText() influenceAssociation.append(associationNameMap[association]) normalize = 1 - self.controls.normalization.getValue() ''' print surfaceAssociation print sampleSpace print influenceAssociation print layerLister print normalize ''' sel = mc.ls(os=True) if len(sel) == 2: srcMeshName, destMeshName = sel[:2] else: mc.error('Select source mesh, then shift-select destination mesh.') args = [srcMeshName, destMeshName, layerLister, influenceAssociation, surfaceAssociation, sampleSpace, normalize] if uv: args.append(uv) copySkinLayers(*args) mc.select(destMeshName)