Exemplo n.º 1
0
 def refreshSettingsFromSelection(self):
     layersAvailable = LayerDataModel.getInstance().getLayersAvailable()
     currentLimit = 0 if not layersAvailable else LayerDataModel.getInstance().mll.getInfluenceLimitPerVertex()
     
     self.controls.numMaxInfluences.setValue(max(1,currentLimit))
     self.controls.useInfluenceLimit.setValue(currentLimit!=0)
     self.updateUIEnabled()
Exemplo n.º 2
0
    def executeMirror(self):
        self.influenceMappingConfiguration.updateSelectionsInfluenceMapping()

        mirrorDirection = MirrorDirection.DIRECTION_POSITIVETONEGATIVE
        if self.mirroringOptions.mirrorDirection.getValue() == 0:  # guess
            mirrorDirection = MirrorDirection.DIRECTION_GUESS
        if self.mirroringOptions.mirrorDirection.getValue(
        ) == 2:  # negative to positive
            mirrorDirection = MirrorDirection.DIRECTION_NEGATIVETOPOSITIVE
        if self.mirroringOptions.mirrorDirection.getSelectedText(
        ) == VertexMirroringOptions.MIRROR_FLIP:
            mirrorDirection = MirrorDirection.DIRECTION_FLIP

        with LayerDataModel.getInstance().mll.batchUpdateContext():
            for layerId in LayerDataModel.getInstance(
            ).layerListsUI.getSelectedLayers():
                LayerDataModel.getInstance().mll.mirrorLayerWeights(
                    layerId,
                    mirrorWidth=self.mirroringOptions.mirrorWidth.getValue(),
                    mirrorLayerWeights=self.mirroringOptions.mirrorWeights.
                    getValue(),
                    mirrorLayerMask=self.mirroringOptions.mirrorMask.getValue(
                    ),
                    mirrorDualQuaternion=self.mirroringOptions.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
Exemplo n.º 3
0
    def execute(self):
        targetMll = MllInterface(mesh=self.targetMesh)

        self.ensureTargetMeshLayers()

        previousLayerIds = [layerId for layerId, _ in targetMll.listLayers()]

        sourceMesh = self.sourceMesh
        if self.sourceModel is not None:
            self.sourceModel.saveTo(MllInterface.TARGET_REFERENCE_MESH)
            sourceMesh = MllInterface.TARGET_REFERENCE_MESH

        vertexTransferMode = self.vertexTransferModes[
            self.parent.controls.transferMode.getSelectedText()]

        sourceMll = MllInterface(mesh=sourceMesh)
        sourceMll.transferWeights(self.targetMesh,
                                  influencesMapping=self.mapper.mapping,
                                  vertexTransferMode=vertexTransferMode)

        if self.parent.controls.keepExistingLayers.getValue() != 1:
            for layerId in previousLayerIds:
                targetMll.deleteLayer(layerId)

        LayerDataModel.getInstance().updateLayerAvailability()
        LayerEvents.layerListModified.emit()
Exemplo n.º 4
0
    def applyCurrentSkinSettings(self):
        limit = 0 if not self.controls.useInfluenceLimit.isChecked() else self.controls.numMaxInfluences.getModelValue()
        LayerDataModel.getInstance().mll.setInfluenceLimitPerVertex(limit)

        pruneFilter = 0.00 if not self.controls.usePruneFilter.isChecked() else self.controls.pruneFilterValue.getModelValue()
        LayerDataModel.getInstance().mll.setPruneWeightsFilter(threshold=pruneFilter)
        
        self.updateUIEnabled()
    def refreshSettingsFromSelection(self):
        layersAvailable = LayerDataModel.getInstance().getLayersAvailable()
        currentLimit = 0 if not layersAvailable else LayerDataModel.getInstance(
        ).mll.getInfluenceLimitPerVertex()

        self.controls.numMaxInfluences.setValue(max(1, currentLimit))
        self.controls.useInfluenceLimit.setValue(currentLimit != 0)
        self.updateUIEnabled()
Exemplo n.º 6
0
 def execute(self):
     influencesMapping = MllInterface.influencesMapToList(self.mapper.mapping)
     mirrorAxis = TransferWeightsTab.axisValues[self.mapper.distanceMatchRule.mirrorAxis]
     
     cmds.ngSkinLayer(initMirrorData=True, influencesMapping=influencesMapping, mirrorAxis=mirrorAxis)
     
     LayerDataModel.getInstance().mll.setManualMirrorInfluences(self.mapper.manualOverrides)
     
     LayerDataModel.getInstance().updateMirrorCacheStatus()
Exemplo n.º 7
0
    def initialize(self):
        log.debug("creating headless data host")

        LayerDataModel.reset()
        restartEvents()

        Utils.loadPlugin()

        MayaEvents.registerScriptJobs()

        LayerDataModel.getInstance()
Exemplo n.º 8
0
 def internalEditLabelCommand(self, item, newName):
     '''
     implements layer in-place rename
     '''
     # do not allow empty layer names
     if newName.strip()=='':
         return ''
     
     LayerDataModel.getInstance().setLayerName(int(item),newName)
     cmds.treeView(self.control,e=True,displayLabel=(item,newName))
     return item
Exemplo n.º 9
0
    def initialize(self):
        log.debug("creating headless data host")
        
        LayerDataModel.reset()
        restartEvents()

        Utils.loadPlugin()

        MayaEvents.registerScriptJobs()
        
        LayerDataModel.getInstance()
Exemplo n.º 10
0
    def applyCurrentSkinSettings(self):
        limit = 0 if not self.controls.useInfluenceLimit.isChecked(
        ) else self.controls.numMaxInfluences.getModelValue()
        LayerDataModel.getInstance().mll.setInfluenceLimitPerVertex(limit)

        pruneFilter = 0.00 if not self.controls.usePruneFilter.isChecked(
        ) else self.controls.pruneFilterValue.getModelValue()
        LayerDataModel.getInstance().mll.setPruneWeightsFilter(
            threshold=pruneFilter)

        self.updateUIEnabled()
Exemplo n.º 11
0
    def initialize(self):
        log.debug("creating headless data host")

        Utils.loadPlugin()

        MayaEvents.registerScriptJobs()
        LayerDataModel.bindAll()
        selectionState.bindAll()
        LayerDataModel.getInstance().updateLayerAvailability()
        selectionState.selectionInfo.dropCache()
        selectionState.mirrorInfo.dropCache()
Exemplo n.º 12
0
    def internalEditLabelCommand(self, layerId, newName):
        '''
        implements layer in-place rename
        '''
        # do not allow empty layer names
        if newName.strip() == '':
            return False

        LayerDataModel.getInstance().setLayerName(layerId, newName)
        #cmds.treeView(self.control,e=True,displayLabel=(item,newName))
        return True
Exemplo n.º 13
0
 def updatePreferedValues(self):
     if self.mirrorMode:
         preferedMirrorAxis = LayerDataModel.getInstance().mirrorCache.mirrorAxis
         if preferedMirrorAxis is None:
             preferedMirrorAxis = 'X'
         self.controls.mirrorAxis.setValue(TransferWeightsTab.axisValues.index(preferedMirrorAxis.upper()))
     
     if self.mirrorMode and LayerDataModel.getInstance().layerDataAvailable:
         self.manualOverrides = LayerDataModel.getInstance().mll.getManualMirrorInfluences()
     else:
         self.manualOverrides = {}
Exemplo n.º 14
0
 def buildInfluenceMappingEngine(self,controls):
     '''
     builds influence transfer mapping, using parameters from UI
     '''
     mapping = TransferDataModel.buildInfluenceMappingEngine(self,controls)
     mapping.sourceInfluences = LayerDataModel.getInstance().mll.listInfluenceInfo();
         
     mapping.mirrorMode = True
     
     mapping.manualOverrides = LayerDataModel.getInstance().mll.getManualMirrorInfluences()
     
     return mapping
Exemplo n.º 15
0
    def execute(self):
        defaultLayerName = "New Layer"
        dlg = LayerPropertiesDialog(newLayerMode=True)
        dlg.layerNameValue.set("")
        if dlg.execute() != dlg.BUTTON_OK:
            return

        newLayerName = dlg.layerNameValue.get()
        if newLayerName.strip() == "":
            newLayerName = defaultLayerName
        LayerDataModel.getInstance().addLayer(newLayerName)
        self.onExecuted.emit()
Exemplo n.º 16
0
    def refreshSettingsFromSelection(self):
        layersAvailable = LayerDataModel.getInstance().getLayersAvailable()

        currentLimit = 0 if not layersAvailable else LayerDataModel.getInstance().mll.getInfluenceLimitPerVertex()
        self.controls.numMaxInfluences.setValue(max(3,currentLimit))
        self.controls.useInfluenceLimit.setValue(currentLimit!=0)
        
        pruneFilterValue = 0 if not layersAvailable else LayerDataModel.getInstance().mll.getPruneWeightsFilter()
        self.controls.pruneFilterValue.setValue(max(0.01,min(1,pruneFilterValue)))
        self.controls.usePruneFilter.setValue(pruneFilterValue!=0)
        
        self.updateUIEnabled()
Exemplo n.º 17
0
 def execute(self):
     defaultLayerName = "New Layer"
     dlg = LayerPropertiesDialog(newLayerMode=True)
     dlg.layerNameValue.set("")
     if dlg.execute()!=dlg.BUTTON_OK:
         return
     
     newLayerName = dlg.layerNameValue.get()
     if newLayerName.strip()=="":
         newLayerName = defaultLayerName
     LayerDataModel.getInstance().addLayer(newLayerName)
     self.onExecuted.emit()
Exemplo n.º 18
0
    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
Exemplo n.º 19
0
    def execInfluenceSelected(self,*args):
        '''
        selection change handler for .influenceDisplay
        '''
        targetId = self.controls.influenceDisplay.getSelectedID();
        
        if targetId is None:
            return
        
        LayerDataModel.getInstance().mll.setCurrentPaintTarget(targetId)

        LayerEvents.currentInfluenceChanged.emit()
        
        log.info("selected logical influence {0}".format(targetId))
Exemplo n.º 20
0
    def execute(self):
        influencesMapping = MllInterface.influencesMapToList(
            self.mapper.mapping)
        mirrorAxis = TransferWeightsTab.axisValues[
            self.mapper.distanceMatchRule.mirrorAxis]

        cmds.ngSkinLayer(initMirrorData=True,
                         influencesMapping=influencesMapping,
                         mirrorAxis=mirrorAxis)

        LayerDataModel.getInstance().mll.setManualMirrorInfluences(
            self.mapper.manualOverrides)

        LayerDataModel.getInstance().updateMirrorCacheStatus()
Exemplo n.º 21
0
    def buildInfluenceMappingEngine(self, controls):
        '''
        builds influence transfer mapping, using parameters from UI
        '''
        mapping = TransferDataModel.buildInfluenceMappingEngine(self, controls)
        mapping.sourceInfluences = LayerDataModel.getInstance(
        ).mll.listInfluenceInfo()

        mapping.mirrorMode = True

        mapping.manualOverrides = LayerDataModel.getInstance(
        ).mll.getManualMirrorInfluences()

        return mapping
Exemplo n.º 22
0
 def execCleanNodes(self,*args):
     if not LayerUtils.hasCustomNodes():
         Utils.confirmDialog(icon='information', title='Info', message='Scene does not contain any custom ngSkinTools nodes.', button=['Ok']);
         return
     
     message = 'This command deletes all custom nodes from ngSkinTools plugin. Skin weights will be preserved, but all layer data will be lost. Do you want to continue?'
     if Utils.confirmDialog(
             icon='warning',
             title='Warning', 
             message=message, 
             button=['Yes','No'], defaultButton='No')!='Yes':
         return
     
     LayerDataModel.getInstance().cleanCustomNodes()
Exemplo n.º 23
0
    def execInfluenceSelected(self, *args):
        '''
        selection change handler for .influenceDisplay
        '''
        targetId = self.controls.influenceDisplay.getSelectedID()

        if targetId is None:
            return

        LayerDataModel.getInstance().mll.setCurrentPaintTarget(targetId)

        LayerEvents.currentInfluenceChanged.emit()

        log.info("selected logical influence {0}".format(targetId))
Exemplo n.º 24
0
    def updatePreferedValues(self):
        if self.mirrorMode:
            preferedMirrorAxis = LayerDataModel.getInstance(
            ).mirrorCache.mirrorAxis
            if preferedMirrorAxis is None:
                preferedMirrorAxis = 'X'
            self.controls.mirrorAxis.setValue(
                TransferWeightsTab.axisValues.index(
                    preferedMirrorAxis.upper()))

        if self.mirrorMode and LayerDataModel.getInstance().layerDataAvailable:
            self.manualOverrides = LayerDataModel.getInstance(
            ).mll.getManualMirrorInfluences()
        else:
            self.manualOverrides = {}
Exemplo n.º 25
0
    def initialize(self):
        log.debug("creating headless data host")
        self.scriptJobs = []

        LayerDataModel.reset()
        restartEvents()

        Utils.loadPlugin()

        self.registerScriptJob("SelectionChanged", MayaEvents.nodeSelectionChanged.emit)
        self.registerScriptJob("Undo", MayaEvents.undoRedoExecuted.emit)
        self.registerScriptJob("Redo", MayaEvents.undoRedoExecuted.emit)
        self.registerScriptJob("ToolChanged", MayaEvents.toolChanged.emit)

        LayerDataModel.getInstance()
Exemplo n.º 26
0
    def refreshSettingsFromSelection(self):
        layersAvailable = LayerDataModel.getInstance().getLayersAvailable()

        currentLimit = 0 if not layersAvailable else LayerDataModel.getInstance(
        ).mll.getInfluenceLimitPerVertex()
        self.controls.numMaxInfluences.setValue(max(3, currentLimit))
        self.controls.useInfluenceLimit.setValue(currentLimit != 0)

        pruneFilterValue = 0 if not layersAvailable else LayerDataModel.getInstance(
        ).mll.getPruneWeightsFilter()
        self.controls.pruneFilterValue.setValue(
            max(0.01, min(1, pruneFilterValue)))
        self.controls.usePruneFilter.setValue(pruneFilterValue != 0)

        self.updateUIEnabled()
Exemplo n.º 27
0
def removeAllNodes():
    if not LayerUtils.hasCustomNodes():
        utils.confirmDialog(icon='information', title='Info',
                            message='Scene does not contain any custom ngSkinTools nodes.', button=['Ok']);
        return

    message = 'This command deletes all custom ngSkinTools nodes. Skin weights will be preserved, but all layer data will be lost. Do you want to continue?'
    if utils.confirmDialog(
            icon='warning',
            title='Warning',
            message=message,
            button=['Yes', 'No'], defaultButton='No') != 'Yes':
        return

    LayerDataModel.getInstance().cleanCustomNodes()
    def initialize(self):
        log.debug("creating headless data host")
        self.scriptJobs = []
        
        LayerDataModel.reset()
        restartEvents()

        Utils.loadPlugin()

        self.registerScriptJob('SelectionChanged',MayaEvents.nodeSelectionChanged.emit)
        self.registerScriptJob('Undo',MayaEvents.undoRedoExecuted.emit)
        self.registerScriptJob('Redo',MayaEvents.undoRedoExecuted.emit)
        self.registerScriptJob('ToolChanged',MayaEvents.toolChanged.emit)        
        
        LayerDataModel.getInstance()
Exemplo n.º 29
0
 def onOpacitySliderChange(self):
     '''
     emits when opacity slider in the dialog changes value
     '''
     currLayer = LayerDataModel.getInstance().getCurrentLayer()
     if currLayer is not None:
         cmds.ngSkinLayer(e=True,id=currLayer,opacity=self.dlg.layerOpacityValue.get())
Exemplo n.º 30
0
 def execPruneWeights(self):
     ldm = LayerDataModel.getInstance()
     for layerId in ldm.layerListsUI.getSelectedLayers():
         if self.controls.pruneWeights.getValue():
             ldm.mll.pruneWeights(layerId=layerId,threshold=self.controls.pruneWeightsThreshold.getValue())
         if self.controls.pruneMask.getValue():
             ldm.mll.pruneMask(layerId=layerId,threshold=self.controls.pruneMaskThreshold.getValue())
Exemplo n.º 31
0
    def execute(self):
        layerData = LayerDataModel.getInstance()
        layerId = layerData.getCurrentLayer()
        influences = layerData.getSelectedInfluenceIds()

        zeroWeights = [0] * layerData.mll.getVertCount()
        prevWeights = {}

        if None in influences:
            raise Exception("fail")

        with layerData.mll.batchUpdateContext():
            for paintTarget in influences:
                prevWeights[paintTarget] = layerData.mll.getInfluenceWeights(
                    layerId, paintTarget)
                if (prevWeights[paintTarget]):
                    layerData.mll.setInfluenceWeights(layerId, paintTarget,
                                                      zeroWeights)

            for paintTarget in influences:
                if not prevWeights[paintTarget]:
                    continue
                weights = [1 - i for i in prevWeights[paintTarget]]
                layerData.mll.setInfluenceWeights(layerId, paintTarget,
                                                  weights)
Exemplo n.º 32
0
 def isEnabled(self):
     model = LayerDataModel.getInstance()
     if model is None:
         return False
     if not model.mirrorCache.isValid:
         return False
     return BaseLayerAction.isEnabled(self)
Exemplo n.º 33
0
    def execute(self):
        data = LayerDataModel.getInstance()

        currLayer = data.getCurrentLayer()
        if currLayer is None or currLayer==0:
            return;

        
        self.dlg = LayerPropertiesDialog(newLayerMode=False)
        
        self.dlg.layerNameValue.set("Layer Properties")
        self.dlg.layerNameValue.set(data.getLayerName(currLayer))

        initialOpacity = data.getLayerOpacity(currLayer)
        self.dlg.layerOpacityValue.set(initialOpacity)
        self.dlg.onOpacityChange.addHandler(self.onOpacitySliderChange)
        
        
        if self.dlg.execute()!=BaseDialog.BUTTON_OK:
            # dialog canceled: rollback changes and exit
            cmds.ngSkinLayer(e=True,id=currLayer,opacity=initialOpacity)
            return
        
        # dialog confirmed - apply changes
        data.setLayerName(currLayer,self.dlg.layerNameValue.get())
        self.onExecuted.emit()
Exemplo n.º 34
0
 def execPruneWeights(self):
     ldm = LayerDataModel.getInstance()
     for layerId in ldm.layerListsUI.getSelectedLayers():
         if self.controls.pruneWeights.getValue():
             ldm.mll.pruneWeights(layerId=layerId,threshold=self.controls.pruneWeightsThreshold.getValue())
         if self.controls.pruneMask.getValue():
             ldm.mll.pruneMask(layerId=layerId,threshold=self.controls.pruneMaskThreshold.getValue())
Exemplo n.º 35
0
    def createUI(self, parent):
        self.data = LayerDataModel.getInstance()
        self.data.setLayerListsUI(self)

        baseForm = FormLayout(cmds.formLayout("LayerListsUI", parent=parent))
        self.baseLayout = baseForm
        self.controls.layerListsUI = self.createLayerListsUI(baseForm)

        self.filterUi = InfluenceFilterUi(self)
        self.filterUi.filterChanged.addHandler(self.updateInfluenceList)
        filterLayout = self.filterUi.createUI(baseForm)
        baseForm.attachForm(self.controls.layerListsUI, 0, 0, None, 0)
        baseForm.attachForm(filterLayout, None, 0, 0, 0)
        baseForm.attachControl(self.controls.layerListsUI, filterLayout, None,
                               None, Constants.MARGIN_SPACING_VERTICAL, None)

        LayerEvents.nameChanged.addHandler(self.updateLayerList, parent)
        LayerEvents.layerAvailabilityChanged.addHandler(self.update, parent)
        LayerEvents.layerListModified.addHandler(self.update, parent)
        LayerEvents.influenceListChanged.addHandler(self.updateInfluenceList,
                                                    parent)
        MayaEvents.undoRedoExecuted.addHandler(self.update, parent)
        LayerEvents.currentLayerChanged.addHandler(
            self.currentLayerChangedHandler, parent)
        MayaEvents.nodeSelectionChanged.addHandler(self.update, parent)

        self.update()
Exemplo n.º 36
0
 def layerDropped(self,layers,newParent,itemBefore,itemAfter):
     '''
     final handler of drag-drop action in layers list
     '''
     
     mll = LayerDataModel.getInstance().mll
     
     with mll.batchUpdateContext():
         # first, order layers by index, and start the "drop" with lowest index
         layers = sorted(layers,key=lambda layer:mll.getLayerIndex(layer),reverse=True)
         
         if newParent:
             itemAfter = None
             itemBefore = newParent
 
         for layer in layers:
             # as layers are shifted, indexes change for target layers
             currentIndex = mll.getLayerIndex(layer)
             
             targetIndex = 0
             if itemAfter:
                 targetIndex = mll.getLayerIndex(itemAfter)+1
             elif itemBefore:
                 targetIndex = mll.getLayerIndex(itemBefore)
 
             # fix index when moving up            
             if targetIndex>currentIndex:
                 targetIndex -= 1
                 
             mll.setLayerIndex(layer,targetIndex)
             
             # for subsequent layers, drop after this layer
             itemBefore = layer
             itemAfter = None
Exemplo n.º 37
0
 def updateLayoutEnabled(self):
     '''
     updates UI enabled/disabled flag based on layer data availability
     '''
     enabled = LayerDataModel.getInstance().layerDataAvailable == True
     cmds.layout(self.cmdLayout.innerLayout, e=True, enable=enabled)
     cmds.layout(self.cmdLayout.buttonForm, e=True, enable=enabled)
Exemplo n.º 38
0
 def updateCacheInfo(self):
     '''
     updates UI according to new mirror cache status
     '''
     
     self.controls.labelCacheInfo.setLabel(LayerDataModel.getInstance().mirrorCache.message)
     self.updateInfluenceList()
Exemplo n.º 39
0
    def __init__(self):
        class Controls:
            pass

        self.controls = Controls()
        self.data = LayerDataModel.getInstance()
        self.data.setLayerListsUI(self)
Exemplo n.º 40
0
 def isEnabled(self):
     model = LayerDataModel.getInstance()
     if model is None:
         return False
     if not model.mirrorCache.isValid:
         return False
     return BaseLayerAction.isEnabled(self)
    def __init__(self):
        self.data = LayerDataModel.getInstance()

        class Controls:
            pass

        self.controls = Controls()
Exemplo n.º 42
0
 def updateLayoutEnabled(self):
     '''
     updates UI enabled/disabled flag based on layer data availability
     '''
     enabled = LayerDataModel.getInstance().layerDataAvailable==True
     cmds.layout(self.cmdLayout.innerLayout,e=True,enable=enabled)
     cmds.layout(self.cmdLayout.buttonForm,e=True,enable=enabled)
Exemplo n.º 43
0
    def updateCacheInfo(self):
        '''
        updates UI according to new mirror cache status
        '''

        self.controls.labelCacheInfo.setLabel(
            LayerDataModel.getInstance().mirrorCache.message)
        self.updateInfluenceList()
Exemplo n.º 44
0
    def execInitMirrorData(self):
        kargs = {};
        kargs["initMirrorData"] = True;
        kargs["influenceAssociationDistance"] = self.controls.influenceDistanceError.getValue()
        kargs["mirrorAxis"] = self.controls.mirrorAxis.getSelectedText()


        # create a comma-delimited prefix string, stripping away any spaces 
        # that might be specified in the user input        
        prefixes = self.controls.influencePrefixes.getValue()
        kargs["influenceAssociationPrefix"] = ",".join([prefix.strip() for prefix in prefixes.split(",")])
        
        cmds.ngSkinLayer(**kargs)
        
        LayerDataModel.getInstance().updateMirrorCacheStatus()

        self.updateInfluenceList()
Exemplo n.º 45
0
 def updateUIEnabled(self):
     layersAvailable = LayerDataModel.getInstance().getLayersAvailable()
     
     Layout.setEnabled(self.controls.selectedSkinSettingsGroup,layersAvailable)
     if not layersAvailable:
         return
     
     self.controls.influenceLimitRow.setEnabled(self.controls.useInfluenceLimit.getModelValue())
Exemplo n.º 46
0
    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        
Exemplo n.º 47
0
    def updateHighlight(self,includeInfluence=True):
        '''
        updates highlight - if painting, adds  current influence to highlight
        '''
        if cmds.currentCtx()!=self.TOOL_PAINT:
            return

        if not LayerDataModel.getInstance().layerDataAvailable:
            return

        newHighlightItems = []
        if includeInfluence:
            currentInfluencePath = LayerDataModel.getInstance().mll.getPaintTargetPath();
            if currentInfluencePath:
                newHighlightItems.append(currentInfluencePath)
                
            
        SelectHelper.replaceHighlight(newHighlightItems)
Exemplo n.º 48
0
 def getMirrorSideTexts(self):
     dataModel = LayerDataModel.getInstance();
     if dataModel.layerDataAvailable:
         mirrorAxis = dataModel.mirrorCache.mirrorAxis
         
         if self.MIRROR_TEXTS.has_key(mirrorAxis):
             return self.MIRROR_TEXTS[mirrorAxis]
     
     return self.MIRROR_TEXTS['x']
Exemplo n.º 49
0
 def onOpacitySliderChange(self):
     '''
     emits when opacity slider in the dialog changes value
     '''
     currLayer = LayerDataModel.getInstance().getCurrentLayer()
     if currLayer is not None:
         cmds.ngSkinLayer(e=True,
                          id=currLayer,
                          opacity=self.dlg.layerOpacityValue.get())
Exemplo n.º 50
0
    def updateHighlight(self, includeInfluence=True):
        '''
        updates highlight - if painting, adds  current influence to highlight
        '''
        if cmds.currentCtx() != self.TOOL_PAINT:
            return

        if not LayerDataModel.getInstance().layerDataAvailable:
            return

        newHighlightItems = []
        if includeInfluence:
            currentInfluencePath = LayerDataModel.getInstance(
            ).mll.getPaintTargetPath()
            if currentInfluencePath:
                newHighlightItems.append(currentInfluencePath)

        SelectHelper.replaceHighlight(newHighlightItems)
Exemplo n.º 51
0
    def getMirrorSideTexts(self):
        dataModel = LayerDataModel.getInstance()
        if dataModel.layerDataAvailable:
            mirrorAxis = dataModel.mirrorCache.mirrorAxis

            if self.MIRROR_TEXTS.has_key(mirrorAxis):
                return self.MIRROR_TEXTS[mirrorAxis]

        return self.MIRROR_TEXTS['x']
    def execute(self):
        layerListsUi = LayerDataModel.getInstance().layerListsUI

        setup = DuplicateLayers()
        setup.setMllInterface(LayerDataModel.getInstance().mll)

        layers = layerListsUi.getSelectedLayers()
        if len(layers) == 0:
            raise MessageException('No layers selected')

        for layer in reversed(layers):
            setup.addLayer(layer)
        setup.execute()

        LayerDataModel.getInstance().mll.setCurrentLayer(
            setup.duplicateIds[-1])

        LayerEvents.layerListModified.emit()
Exemplo n.º 53
0
    def execInitMirrorData(self):
        kargs = {}
        kargs["initMirrorData"] = True
        kargs[
            "influenceAssociationDistance"] = self.controls.influenceDistanceError.getValue(
            )
        kargs["mirrorAxis"] = self.controls.mirrorAxis.getSelectedText()

        # create a comma-delimited prefix string, stripping away any spaces
        # that might be specified in the user input
        prefixes = self.controls.influencePrefixes.getValue()
        kargs["influenceAssociationPrefix"] = ",".join(
            [prefix.strip() for prefix in prefixes.split(",")])

        cmds.ngSkinLayer(**kargs)

        LayerDataModel.getInstance().updateMirrorCacheStatus()

        self.updateInfluenceList()
    def updateUIEnabled(self):
        layersAvailable = LayerDataModel.getInstance().getLayersAvailable()

        Layout.setEnabled(self.controls.selectedSkinSettingsGroup,
                          layersAvailable)
        if not layersAvailable:
            return

        self.controls.influenceLimitRow.setEnabled(
            self.controls.useInfluenceLimit.getModelValue())
Exemplo n.º 55
0
 def execute(self):
     layerListsUi = LayerDataModel.getInstance().layerListsUI
     
     setup = DuplicateLayers()
     setup.setMllInterface(LayerDataModel.getInstance().mll)
     
     layers = layerListsUi.getSelectedLayers()
     if len(layers)==0:
         raise MessageException('No layers selected')
     
     for layer in reversed(layers):
         setup.addLayer(layer)
     setup.execute()
     
     LayerDataModel.getInstance().mll.setCurrentLayer(setup.duplicateIds[-1])
     
     LayerEvents.layerListModified.emit()
     
     
     
     
Exemplo n.º 56
0
    def execute(self):
        targetMll = MllInterface(mesh=self.targetMesh)

        self.ensureTargetMeshLayers()
        
        previousLayerIds = [layerId for layerId, _  in targetMll.listLayers()]

        sourceMesh = self.sourceMesh        
        if self.sourceModel is not None:
            self.sourceModel.saveTo(MllInterface.TARGET_REFERENCE_MESH)
            sourceMesh = MllInterface.TARGET_REFERENCE_MESH
        
        vertexTransferMode = self.vertexTransferModes[self.parent.controls.transferMode.getSelectedText()]

        sourceMll = MllInterface(mesh=sourceMesh)
        sourceMll.transferWeights(self.targetMesh,influencesMapping=self.mapper.mapping,vertexTransferMode=vertexTransferMode)

        if self.parent.controls.keepExistingLayers.getValue()!=1:
            for layerId in previousLayerIds:
                targetMll.deleteLayer(layerId)

        LayerDataModel.getInstance().updateLayerAvailability()
        LayerEvents.layerListModified.emit()
Exemplo n.º 57
0
    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)
Exemplo n.º 58
0
 def execute(self):
     ldm = LayerDataModel.getInstance()
     for layerId in ldm.layerListsUI.getSelectedLayers():
         if ldm.mll.getLayerIndex(layerId)==0:
             Utils.displayError("Cannot merge lowest layer")
             return
         
         ldm.mll.layerMergeDown(layerId)
         
         
     
         
     LayerEvents.layerListModified.emit()
     self.onExecuted.emit()
Exemplo n.º 59
0
    def updateHighlight(self,includeInfluence=True):
        '''
        updates highlight - if painting, adds  current influence to highlight
        '''
        if cmds.currentCtx()!=self.TOOL_PAINT:
            return

        if not LayerDataModel.getInstance().layerDataAvailable:
            return

        newHighlightItems = []
        if includeInfluence:
            currentInfluence = cmds.ngSkinLayer(q=True,ci=True)
            # returns influence path, if current paint target has any
            if (len(currentInfluence)>1):
                newHighlightItems.append(currentInfluence[1])
                
            
        SelectHelper.replaceHighlight(newHighlightItems)
Exemplo n.º 60
0
    def execute(self):
        if not LayerDataModel.getInstance().getLayersAvailable():
            raise Exception("layers data not available")
        
        fileName = self.selectFile(forSave=True)
        if fileName is None:
            return

        import ngSkinTools.importExport as ie 
        model = ie.LayerData()
        
        model.loadFrom(self.getTargetMesh())
        
        exporter = self.ioFormat.exporterClass()
        
        f = open(fileName,'w')
        try:
            f.write(exporter.process(model))
        finally:
            f.close();