コード例 #1
0
    def getTextureDimensions(self, *args, **kwargs):
        '''
            returns the dimensions of the currently displayed texture in the UV Editor
            If there is no texture loaded returns a default [1,1]

        '''
        textureDimensions = [1, 1]

        numImages = pm.textureWindow(self.uvTextureView[0], q=True, ni=True)
        if numImages > 0:

            if int(pm.about(version=True)) < 2014:
                currentTextureImage = pm.textureWindow(self.uvTextureView[0],
                                                       q=True,
                                                       imageNumber=True)
                imageList = pm.textureWindow(self.uvTextureView[0],
                                             q=True,
                                             imageNames=True)
                currentTextureString = imageList[currentTextureImage].split(
                    '|')
                currentTextureNode = currentTextureString[
                    len(currentTextureString) - 1].strip()
                if pm.nodeType(currentTextureNode) == 'file':
                    textureDimensions = pm.getAttr(currentTextureNode +
                                                   '.outSize')
            else:
                textureDimensions = pm.textureWindow(self.uvTextureView[0],
                                                     q=True,
                                                     imageSize=True)

        return textureDimensions
コード例 #2
0
ファイル: pbUV.py プロジェクト: aaronfang/pbUV
    def __init__(self, par, editor):
        self.editor = editor
        ToolsUI.__init__(self, par)

        with pm.gridLayout(p=par, nc=2, cwh=[26, 26]) as self.layout:
            griddisp = pm.iconTextCheckBox(image1='gridDisplay.png',
                                           value=pm.textureWindow(self.editor, q=True, toggle=True),
                                           onc=lambda *args: pm.textureWindow(self.editor, e=True, toggle=True),
                                           ofc=lambda *args: pm.textureWindow(self.editor, e=True, toggle=False),
                                           ann=pm.mel.uiRes('m_textureWindowCreateToolBar.kViewGridAnnot'))
            pm.popupMenu(button=3, p=griddisp, pmc=lambda *args: pm.mel.performTextureViewGridOptions(1))

            pxsnap = pm.iconTextCheckBox(image1='pixelSnap.png',
                                         value=pm.snapMode(q=True, pixelSnap=True),
                                         onc=lambda *args: pm.snapMode(pixelSnap=True),
                                         ofc=lambda *args: pm.snapMode(pixelSnap=False),
                                         ann=pm.mel.uiRes('m_textureWindowCreateToolBar.kPixelSnapAnnot'))
            pm.popupMenu(button=3, p=pxsnap, pmc=lambda *args: pm.mel.performPixelSnapOptions(1))

            pm.iconTextButton(image1='textureEditorDisplayColor.png',
                              c=lambda *args: pm.textureWindow(self.editor, e=True, displayStyle='color'),
                              ann='m_textureWindowCreateToolBar.kDisplayRGBChannelsAnnot')

            pm.iconTextButton(image1='textureEditorDisplayAlpha.png',
                              c=lambda *args: pm.textureWindow(self.editor, e=True, displayStyle='mask'),
                              ann='m_textureWindowCreateToolBar.kDisplayAlphaChannelsAnnot')
コード例 #3
0
ファイル: pbUV.py プロジェクト: aaronfang/pbUV
    def __init__(self, par, editor):
        ToolsUI.__init__(self, par)
        self.editor = editor
        with pm.gridLayout(p=par, nc=2, cwh=[26, 26]) as self.layout:
            swapbg = pm.iconTextCheckBox(image1='swapBG.png',
                                         value=pm.optionVar['displayEditorImage'],
                                         ann=pm.mel.uiRes('m_textureWindowCreateToolBar.kUVTextureEditorBakingAnnot'),
                                         cc=lambda *args: pm.mel.textureWindowToggleEditorImage(self.editor))
            pm.popupMenu(button=3, p=swapbg, pmc=lambda *arg: pm.mel.performTextureViewBakeTextureOptions(1))

            pm.iconTextButton(image1='updatePsdTextureEditor.png',
                              ann=pm.mel.uiRes('m_textureWindowCreateToolBar.kUpdatePSDNetworksAnnot'),
                              c=lambda *args: pm.mel.psdUpdateTextures(),
                              commandRepeatable=True)

            pm.iconTextButton(image1='bakeEditor.png',
                              ann=pm.mel.uiRes('m_textureWindowCreateToolBar.kForceEditorTextureRebakeAnnot'),
                              c=lambda *args: pm.mel.textureWindowBakeEditorImage(),
                              commandRepeatable=True)

            pm.iconTextCheckBox(image1='imageRatio.png',
                                ann=pm.mel.uiRes('m_textureWindowCreateToolBar.kUseImageRatioAnnot'),
                                value=pm.textureWindow(self.editor, q=True, imageRatio=True),
                                onc=lambda *args: pm.textureWindow(self.editor, e=True, imageRatio=True),
                                ofc=lambda *args: pm.textureWindow(self.editor, e=True, imageRatio=False))
コード例 #4
0
ファイル: pbUV.py プロジェクト: aaronfang/pbUV
 def dim_image_cmd(self, value):
     if value:
         pm.textureWindow(self.editor, e=True, imageBaseColor=[0.5, 0.5, 0.5])
         self.dimImage.setValue(0.5)
     else:
         pm.textureWindow(self.editor, e=True, imageBaseColor=[1.0, 1.0, 1.0])
         self.dimImage.setValue(1.0)
コード例 #5
0
ファイル: pbUV.py プロジェクト: aaronfang/pbUV
 def toggle_image_display(self, *args):
     if pm.textureWindow(self.editor, q=True, id=True):
         pm.textureWindow(self.editor, e=True, id=False)
         self.imageDisplay.setValue(False)
     else:
         pm.textureWindow(self.editor, e=True, id=True)
         self.imageDisplay.setValue(True)
コード例 #6
0
ファイル: pbUV.py プロジェクト: aaronfang/pbUV
 def set_isolate(self, val):
     if val:
         pm.textureWindow(self.editor, e=True, useFaceGroup=True)
         pm.optionVar['textureWindowShaderFacesMode'] = 2
     else:
         pm.textureWindow(self.editor, e=True, useFaceGroup=False)
         pm.optionVar['textureWindowShaderFacesMode'] = 0
コード例 #7
0
ファイル: pbUV.py プロジェクト: aaronfang/pbUV
    def dim_image_attr(self, *args):
        val = self.dimImage.getValue()
        pm.textureWindow(self.editor, e=True, imageBaseColor=[val, val, val])

        if val < 0.99:
            self.dimImageBtn.setValue(True)
        else:
            self.dimImageBtn.setValue(False)
コード例 #8
0
ファイル: uvHandler.py プロジェクト: z199416/MayaScript
def switch2BaseMap():
    """
    切换 Base Map
    """
    for texWinName in pm.getPanel(sty='polyTexturePlacementPanel'):
        for i, _map in enumerate(
                pm.textureWindow(texWinName, q=1, textureNames=1)):
            if 'BaseMap' in _map:
                pm.textureWindow(texWinName, e=1, textureNumber=i)
コード例 #9
0
ファイル: lcTexture.py プロジェクト: kotchin/mayaSettings
 def setTextureTiling(self, resizeMatrix, *args, **kwargs):
   '''
     input and return format is [U min, V min, U max, V max]
     Resizes the range the texture image is tiled in the UV Editor
   
   '''
   currentSize = pm.textureWindow(self.uvTextureView[0],q=True,imageTileRange=True)
   newSize = [currentSize[0]+resizeMatrix[0],currentSize[1]+resizeMatrix[1],currentSize[2]+resizeMatrix[2],currentSize[3]+resizeMatrix[3]] #add the matrices together
   pm.textureWindow(self.uvTextureView[0],e=True,imageTileRange=list(newSize))
   return newSize
コード例 #10
0
ファイル: lcTexture.py プロジェクト: kotchin/mayaSettings
 def getTextureDimensions(self, *args, **kwargs):
   '''
     returns the dimensions of the currently displayed texture in the UV Editor
     If there is no texture loaded returns a default [1,1]
   
   '''
   textureDimensions = [1,1]
   numImages = pm.textureWindow(self.uvTextureView[0],q=True, ni=True)
   if numImages>0:
     currentTextureImage = pm.textureWindow(self.uvTextureView[0],q=True, imageNumber=True)
     imageList = pm.textureWindow(self.uvTextureView[0],q=True, imageNames=True)
     currentTextureString = imageList[currentTextureImage].split('|')
     currentTextureNode = currentTextureString[len(currentTextureString)-1].strip()
     if pm.nodeType(currentTextureNode)=='file':
       textureDimensions = pm.getAttr(currentTextureNode+'.outSize')        
   return textureDimensions
コード例 #11
0
ファイル: lcTexture.py プロジェクト: kotchin/mayaSettings
 def getTextureTiling(self, *args, **kwargs):     
   '''
     return format is [U min, V min, U max, V max]
     return the sizing matrix for the UV Editor's image tiling
     
   '''
   currentSize = pm.textureWindow(self.uvTextureView[0],q=True,imageTileRange=True)
   return currentSize
コード例 #12
0
    def setTextureTiling(self, resizeMatrix, *args, **kwargs):
        '''
            input and return format is [U min, V min, U max, V max]
            Resizes the range the texture image is tiled in the UV Editor

        '''
        currentSize = pm.textureWindow(self.uvTextureView[0],
                                       q=True,
                                       imageTileRange=True)
        newSize = [
            currentSize[0] + resizeMatrix[0], currentSize[1] + resizeMatrix[1],
            currentSize[2] + resizeMatrix[2], currentSize[3] + resizeMatrix[3]
        ]  # add the matrices together
        pm.textureWindow(self.uvTextureView[0],
                         e=True,
                         imageTileRange=list(newSize))
        return newSize
コード例 #13
0
    def getTextureTiling(self, *args, **kwargs):
        '''
            return format is [U min, V min, U max, V max]
            return the sizing matrix for the UV Editor's image tiling

        '''
        currentSize = pm.textureWindow(self.uvTextureView[0],
                                       q=True,
                                       imageTileRange=True)
        return currentSize
コード例 #14
0
ファイル: lcTexture.py プロジェクト: kotchin/mayaSettings
  def getTextureList(self, *args, **kwargs):
    '''
      returns a list of file texture nodes currently loaded in the UV Editor
      list items are formatted: [texture number, texture node]
      texture number is the index associated with the texture in the UV Editor
      texture node is the name of the maya file texture node
      SHADING GROUPS ARE EXCLUDED FROM THIS LIST
      
    '''
    texList = []
    numImages = pm.textureWindow(self.uvTextureView[0],q=True, ni=True)
    if numImages>0:
      imageList = pm.textureWindow(self.uvTextureView[0],q=True, imageNames=True)

      for i in range(0,numImages):
        shadString = imageList[i].split('|')
        shadNode   = shadString[len(shadString)-1].strip()
        if pm.nodeType(shadNode)=='file':
          texList.append([i,shadNode])
      
    return texList
コード例 #15
0
ファイル: pbUV.py プロジェクト: aaronfang/pbUV
    def __init__(self, par, editor):
        self.editor = editor
        ToolsUI.__init__(self, par)
        with pm.columnLayout(p=par) as self.layout:
            with pm.rowLayout(nc=4):
                self.imageDisplay = pm.iconTextCheckBox('imageDisplayButton', image1='imageDisplay.png',
                                                        v=pm.textureWindow(self.editor, q=True, id=True),
                                                        cc=self.toggle_image_display,
                                                        ann=pm.mel.uiRes(
                                                            'm_textureWindowCreateToolBar.kDisplayImageAnnot'))
                pm.popupMenu(button=3, p=self.imageDisplay,
                             pmc=lambda *args: pm.mel.performTextureViewImageRangeOptions(1))

                pm.iconTextCheckBox(image1='textureEditorShadeUVs.png',
                                    value=pm.textureWindow(self.editor, q=True, displaySolidMap=True),
                                    onc=lambda *args: pm.textureWindow(self.editor, e=True, displaySolidMap=True),
                                    ofc=lambda *args: pm.textureWindow(self.editor, e=True, displaySolidMap=False),
                                    ann=pm.mel.uiRes('m_textureWindowCreateToolBar.kOverlapAnnot'))

                self.edgeColorBtn = pm.iconTextButton(image1='pbUV/opts01EdgeColor.png', c=self.edge_col_cmd)
                self.edgeColSld = pm.intSlider(min=1, max=31,
                                               value=pm.displayColor('polymesh', q=True, active=True) + 1,
                                               dc=self.edge_col_attr)

            with pm.rowLayout(nc=4):
                pm.iconTextCheckBox(image1='filteredMode.png', v=pm.textureWindow(self.editor, q=True, iuf=True),
                                    onc=lambda *args: pm.textureWindow(self.editor, e=True, iuf=True),
                                    ofc=lambda *args: pm.textureWindow(self.editor, e=True, iuf=False),
                                    ann=pm.mel.uiRes('m_textureWindowCreateToolBar.kToggleFilteredImageAnnot'))

                polyOpts = pm.iconTextButton(image1='textureBorder.png', c=self.toggle_tx_border,
                                             ann=pm.mel.uiRes(
                                                 'm_textureWindowCreateToolBar.kToggleTextureBordersAnnot'))
                pm.popupMenu(button=3, p=polyOpts, pmc=lambda *args: pm.mel.CustomPolygonDisplayOptions())

                self.dimImageBtn = pm.iconTextCheckBox('dimmerButton', image1='dimTexture.png',
                                                       ann=pm.mel.uiRes('m_textureWindowCreateToolBar.kDimImageAnnot'),
                                                       onc=lambda *args: self.dim_image_cmd(True),
                                                       ofc=lambda *args: self.dim_image_cmd(False),
                                                       value=pm.textureWindow(self.editor, q=True,
                                                                              imageBaseColor=True) < 0.9)

                self.dimImage = pm.floatSlider(minValue=0.0, maxValue=1.0,
                                               value=pm.textureWindow(self.editor, q=True, imageBaseColor=True)[0],
                                               cc=self.dim_image_attr, dc=self.dim_image_attr)
コード例 #16
0
    def getTextureList(self, *args, **kwargs):
        '''
            returns a list of file texture nodes currently loaded in the UV Editor
            list items are formatted: [texture number, texture node]
            texture number is the index associated with the texture in the UV Editor
            texture node is the name of the maya file texture node
            SHADING GROUPS ARE EXCLUDED FROM THIS LIST

        '''
        texList = []
        numImages = pm.textureWindow(self.uvTextureView[0], q=True, ni=True)
        if numImages > 0:
            imageList = pm.textureWindow(self.uvTextureView[0],
                                         q=True,
                                         imageNames=True)

            for i in range(0, numImages):
                shadString = imageList[i].split('|')
                shadNode = shadString[len(shadString) - 1].strip()
                if pm.nodeType(shadNode) == 'file':
                    texList.append([i, shadNode])

        return texList