Example #1
0
def rtb_highres_list_populate(highresListDropdown, *args, **kwargs):
    ''' '''
    global defaultString
    global lct_cfg

    highresListDropdown.clear()
    highresListDropdown.addItems([defaultString])

    sel = [
        obj for obj in pm.ls(dag=True, transforms=True)
        if obj.getShape() and obj.getShape().nodeType() == 'mesh'
    ]
    highres = lcUtility.Utility.filterByToken(sel, 'high')

    for mesh in highres:
        highresListDropdown.addItems([mesh])

    rtb_glow(highresListDropdown)

    pm.picture(prefix + '_picture_layer_mesh', edit=True, enable=False)
    pm.floatSlider(prefix + '_floatSlider_layer_mesh', edit=True, enable=False)

    if highresListDropdown.getNumberOfItems() < lct_cfg.get(
            'lcRetopoBasicListItem'):
        lct_cfg.set('lcRetopoBasicListItem',
                    highresListDropdown.getNumberOfItems())
Example #2
0
def rtb_choose_active(highresListDropdown, *args, **kwargs):
    ''' '''
    global prefix
    global defaultString
    global lct_cfg

    lct_cfg.set('lcRetopoBasicListItem', highresListDropdown.getSelect())
    high = highresListDropdown.getValue()
    if high != defaultString:
        rtb_scale_layer_mesh(highresListDropdown)
        pm.picture(prefix + '_picture_layer_mesh', edit=True, enable=True)
        pm.floatSlider(prefix + '_floatSlider_layer_mesh',
                       edit=True,
                       enable=True)

        live = pm.PyNode(high.replace('_high', '_live'))
        liveShape = live.getShape()
        pm.makeLive(live)
    else:
        pm.makeLive(none=True)
        rtb_scale_layer_mesh(highresListDropdown)
        pm.picture(prefix + '_picture_layer_mesh', edit=True, enable=False)
        pm.floatSlider(prefix + '_floatSlider_layer_mesh',
                       edit=True,
                       enable=False)

    rtb_glow(highresListDropdown)
Example #3
0
def rtb_setup_live_mesh(highresListDropdown, *args, **kwargs):
    ''' '''
    global lct_cfg

    sel = pm.ls(sl=True)
    lcGeometry.Geometry.fixNamespaceNames()
    if sel:
        for item in sel:
            pm.undoInfo(chunkName='lc_undo_makelive', openChunk=True)
            try:
                pm.parent(item, world=True)
                lcGeometry.Geometry.unlock_translate_rotate_scale(item)
                root = pm.group(empty=True, name=item + '_RETOPO')
                live = pm.duplicate(item, name=item + '_live')[0]
                high = item.rename(item + '_high')

                pm.makeIdentity([high, live], apply=True, t=1, r=1, s=1, n=0)
                lcUtility.Utility.centerPvt([high, live])

                highShape = high.getShape()
                liveShape = live.getShape()

                highShape.overrideEnabled.set(1)  # enable display overrides
                highShape.overrideDisplayType.set(2)  # set to referenced

                liveShape.overrideEnabled.set(1)  # enable display overrides
                liveShape.overrideDisplayType.set(1)  # set to template
                liveShape.overrideVisibility.set(0)  # set visibility to 0

                pm.makeLive(live)

                highresListDropdown.addItems([high])
                numItems = highresListDropdown.getNumberOfItems()
                highresListDropdown.setSelect(numItems)

                pm.parent(high, root)
                pm.parent(live, root)

                pm.connectAttr('persp.translate', high.scalePivot)

                rtb_scale_layer_mesh(highresListDropdown)

                rtb_glow(highresListDropdown)

                lct_cfg.set('lcRetopoBasicListItem',
                            highresListDropdown.getSelect())

                pm.picture(prefix + '_picture_layer_mesh',
                           edit=True,
                           enable=True)
                pm.floatSlider(prefix + '_floatSlider_layer_mesh',
                               edit=True,
                               enable=True)
                pm.undoInfo(chunkName='lc_undo_makelive', closeChunk=True)
                pm.select(clear=True)
            except:
                pm.undoInfo(chunkName='lc_undo_makelive', closeChunk=True)
                pm.undo()
                lcUtility.Utility.lc_print(
                    'Could not make {0} live'.format(item))
    def createAssetPrompt(self):
        code = ''

        proj = database.getProjectDict()
        if self.type == 'asset':
            code = "%04d" % proj['nextAsset']
        elif self.type == 'shot':
            code = "%04d" % proj['nextShot']

        form = pm.setParent(q=True)
        f = pm.formLayout(form, e=True, width=150)
        row = pm.rowLayout(nc=2, adj=2)
        pm.picture(image='sphere.png', w=50, h=50)
        col = pm.columnLayout(adjustableColumn=True)
        nameField = pm.textFieldGrp('CrAsset_nameField',
                                    label='Name',
                                    cw=(1, 70),
                                    text='',
                                    adj=2,
                                    cat=[(1, 'left', 5), (2, 'left', 5)],
                                    editable=True)
        codeField = pm.textFieldGrp('CrAsset_codeField',
                                    label='Code',
                                    cw=(1, 70),
                                    text=code,
                                    adj=2,
                                    cat=[(1, 'left', 5), (2, 'left', 5)],
                                    editable=True)
        workflow = pm.optionMenuGrp('CrAsset_workflowOpt',
                                    label='Workflow',
                                    cw=(1, 70),
                                    cat=[(1, 'left', 5), (2, 'left', 5)])
        proj = database.getProjectDict()

        for key in proj['workflow']:
            context = set([
                proj['workflow'][key][x]['type'] for x in proj['workflow'][key]
            ])
            if self.type in context:
                pm.menuItem(label=key)

        b1 = pm.button(p=f, l='Cancel', c=self.abortCreateCallback)
        b2 = pm.button(p=f, l='OK', c=self.createAssetCallBack)

        spacer = 5
        top = 5
        edge = 5
        pm.formLayout(form,
                      edit=True,
                      attachForm=[(row, 'right', edge), (row, 'top', top),
                                  (row, 'left', edge), (row, 'right', edge),
                                  (b1, 'right', edge), (b1, 'bottom', edge),
                                  (b2, 'left', edge), (b2, 'bottom', edge)],
                      attachNone=[],
                      attachControl=[],
                      attachPosition=[(b1, 'right', spacer, 90),
                                      (b2, 'left', spacer, 10)])
Example #5
0
    def lcToolbox_child_popout(cls, mainColumn, windowName, height, commandString, iconPath, lct_cfg, *args, **kwargs):
        '''
        pop out the tool from the lcToolbox
        '''
        import lct.src.lcToolbox.lcToolbox as lcToolbox

        lcToolboxPath = os.path.join(os.path.abspath(os.path.dirname(__file__)), os.pardir, 'lcToolbox',
                                     "lcToolbox.conf")
        conf = lcConfiguration.Conf.load_conf_file(lcToolboxPath)

        srcPath = lcPath.Path.getSrcPath()
        if pm.columnLayout(mainColumn, ex=True) and pm.window(windowName, ex=False) and pm.window('lcToolbox', ex=True):
            pm.deleteUI(mainColumn)
            toolboxHeight = pm.window('lcToolbox', query=True, h=True) - height + conf['height']
            pm.picture(image=os.path.join(srcPath, 'lcToolbox', 'icons', 'none.png'), parent='fl_form_tool')
            pm.symbolButton('lcTb_{}'.format(windowName), edit=True, enable=True,
                            image=os.path.join(iconPath, '{}_Return.png'.format(windowName)),
                            command=functools.partial(lcToolbox.lcTb_open_tool, 'lcToolbox', height, commandString))
            lct_cfg.set(windowName + 'Pop', True)
            lct_cfg.set('lcToolboxHeight', conf['height'])
            lct_cfg.set('lcToolboxCurrentTool', '')
            pm.window('lcToolbox', edit=True, h=toolboxHeight)
Example #6
0
def lcTb_open_tool(windowName,
                   heightAdjust,
                   commandString='',
                   *args,
                   **kwargs):
    ''' '''
    prefix = conf['prefix']

    if lcUtility.Utility.maya_version_check():

        if pm.columnLayout(prefix + '_columLayout_holder', exists=True):
            pm.deleteUI(prefix + '_columLayout_holder')
        if pm.formLayout('fl_form', exists=True):
            pm.deleteUI('fl_form')
        if pm.columnLayout('fl_form_shelf', exists=True):
            pm.deleteUI('fl_form_shelf')
        if pm.columnLayout('fl_form_tool', exists=True):
            pm.deleteUI('fl_form_tool')

        pm.setParent(prefix + '_columnLayout_main')

        pm.columnLayout(prefix + '_columLayout_holder', rowSpacing=0)

        pm.formLayout('fl_form', numberOfDivisions=100)
        pm.picture('fl_form_header',
                   image=os.path.join(
                       iconPath, 'header_{}.png'.format(lct_conf['release'])))
        if lct_conf['release'] == 'dev':
            pm.symbolButton('fl_form_reload',
                            image=os.path.join(iconPath, 'reload.png'),
                            command=functools.partial(
                                lcTb_open_tool_new_window, shelfCommand))

        pm.columnLayout('fl_form_shelf')
        shelfHeight = 32
        fl_flow_layout = pm.flowLayout(width=204,
                                       height=shelfHeight + 4,
                                       wrap=True,
                                       columnSpacing=0)

        # list published tools except lcToolbox
        toolList = lcUtility.Utility.buildPublishList(inline=False)
        toolCount = 0
        for item in toolList:
            if item[0] != 'lcToolbox':
                toolCount = toolCount + 1
                toolName = item[0]
                toolPrefix = item[1]
                toolAnnotation = item[2]
                toolHeight = int(item[5])
                toolIcon = os.path.normpath(
                    os.path.join(srcPath, toolName, toolName + '.png'))
                shelfIcon = os.path.normpath(
                    os.path.join(srcPath, toolName, 'icons',
                                 toolName + '_shelf.png'))
                toolShelfCommand = "import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI()".format(
                    toolName, toolPrefix)

                toolExecString = unicode(
                    "import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI(asChildLayout=True)"
                    .format(toolName, toolPrefix))

                toolButton = pm.symbolButton(prefix + '_' + toolName,
                                             image=toolIcon,
                                             annotation=toolAnnotation,
                                             command=functools.partial(
                                                 lcTb_open_tool, windowName,
                                                 toolHeight, toolExecString))
                popup = pm.popupMenu(prefix + '_' + toolName + 'popup',
                                     parent=toolButton)
                pm.menuItem(l='Open in new window',
                            parent=popup,
                            command=functools.partial(
                                lcTb_open_tool_new_window, toolShelfCommand))
                pm.menuItem(l='Add to shelf',
                            parent=popup,
                            command=functools.partial(
                                lcShelf.Shelf.makeShelfButton, toolName,
                                toolShelfCommand, shelfIcon, toolAnnotation))

                if pm.window(
                        toolName, ex=True
                ):  # if i have the tool window open seperately use the return arrow icon
                    pm.symbolButton(
                        prefix + '_' + toolName,
                        edit=True,
                        image=os.path.normpath(
                            os.path.join(srcPath, toolName, 'icons',
                                         toolName + '_Return.png')),
                        command=functools.partial(lcTb_open_tool, windowName,
                                                  toolHeight, toolExecString))

                # if i am loading a specific tool back into the window update its icon to standard
                if commandString and toolName in commandString:
                    pm.symbolButton(
                        toolButton,
                        edit=True,
                        image=os.path.normpath(
                            os.path.join(srcPath, toolName, 'icons',
                                         toolName + '_Release.png')),
                        command=functools.partial(lcTb_open_tool_new_window,
                                                  toolShelfCommand))

        rowCount = max(1, math.ceil(toolCount / 5.0))
        shelfHeight = shelfHeight * rowCount + 4
        pm.flowLayout(fl_flow_layout, edit=True, height=shelfHeight)

        pm.setParent('fl_form')
        fl_form_tool = pm.columnLayout('fl_form_tool',
                                       width=224,
                                       columnOffset=('left', 10))

        pm.separator(style='double', h=5, w=205)

        if not commandString:
            pm.picture(image=os.path.join(iconPath, 'none.png'))
        else:
            exec commandString in locals()
            lct_cfg.set('lcToolboxCurrentTool', commandString)
            lct_cfg.set('lcToolboxHeight', heightAdjust)

        if lct_conf['release'] == 'dev':
            pm.formLayout('fl_form',
                          edit=True,
                          attachForm=[('fl_form_header', 'top', 0),
                                      ('fl_form_shelf', 'top', 54),
                                      ('fl_form_shelf', 'left', 25),
                                      ('fl_form_reload', 'top', 0),
                                      ('fl_form_reload', 'left', 103)],
                          attachControl=[(fl_form_tool, 'top', 0,
                                          'fl_form_shelf')])
        else:
            pm.formLayout('fl_form',
                          edit=True,
                          attachForm=[('fl_form_header', 'top', 0),
                                      ('fl_form_shelf', 'top', 54),
                                      ('fl_form_shelf', 'left', 25)],
                          attachControl=[(fl_form_tool, 'top', 0,
                                          'fl_form_shelf')])

        pm.setParent(prefix + '_columLayout_holder')
        pm.picture('fl_form_footer',
                   image=os.path.join(
                       iconPath, 'footer_{}.png'.format(lct_conf['release'])))

        pm.window(windowName,
                  edit=True,
                  height=heightAdjust + shelfHeight +
                  122)  # +conf['height'])#, width=mainWindow.width)
    else:
        pm.separator(style='none', h=30)
        pm.text(l='Your Maya Version:',
                al='center',
                w=231,
                h=25,
                font='boldLabelFont')
        pm.text(l='{}'.format(versions.shortName()),
                al='center',
                w=231,
                h=10,
                font='boldLabelFont')
        pm.separator(style='none', h=10)
        pm.text(
            l='You must have\nMaya 2014 or greater\nto run the\nLEOCOV Toolbox',
            al='center',
            w=231,
            h=60,
            font='boldLabelFont')
        pm.window(windowName, edit=True, height=231)
Example #7
0
def lcRetopoBasicUI(dockable=False, asChildLayout=False, *args, **kwargs):
    """ """
    global lct_cfg
    global prefix

    ci = 0  # color index iterator
    windowName = 'lcRetopoBasic'
    shelfCommand = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI()'.format(
        windowName, prefix)
    commandString = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI(asChildLayout=True)'.format(
        windowName, prefix)
    icon = os.path.join(basePath, 'lcRetopoBasic.png')
    winWidth = 205
    winHeight = height

    if pm.window(windowName, ex=True):
        pm.deleteUI(windowName)

    if not asChildLayout:
        lcUI.UI.lcToolbox_child_popout(prefix + '_columnLayout_main',
                                       windowName, height, commandString,
                                       iconPath, lct_cfg)
        mainWindow = lcUI.lcWindow(prefix=prefix,
                                   windowName=windowName,
                                   width=winWidth,
                                   height=winHeight,
                                   icon=icon,
                                   shelfCommand=shelfCommand,
                                   annotation=annotation,
                                   dockable=dockable,
                                   menuBar=True)
        mainWindow.create()

    pm.columnLayout(prefix + '_columnLayout_main')

    # SETUP
    pm.button(l='Setup for Retopo',
              bgc=colorWheel.getColorRGB(ci),
              w=200,
              h=25,
              annotation='Setup a high res mesh for retopology',
              command=lambda *args: rtb_setup_live_mesh(highresListDropdown))
    ci += 1

    # List
    pm.rowColumnLayout(nc=3, cw=([1, 25], [2, 150], [3, 25]))
    pm.symbolButton(
        h=25,
        image=os.path.join(iconPath, 'reloadMeshList.png'),
        annotation='Reload the list of high res meshes',
        command=lambda *args: rtb_highres_list_populate(highresListDropdown))
    highresListDropdown = pm.optionMenu(
        prefix + '_optionMenu_highres_list',
        w=150,
        h=23,
        bgc=[0.5, 0.5, 0.5],
        annotation='List of high res meshes in the scene')
    highresListDropdown.changeCommand(
        lambda *args: rtb_choose_active(highresListDropdown))
    remove_mesh_button = pm.symbolButton(
        h=25,
        image=os.path.join(iconPath, 'removeMeshFromList.png'),
        annotation=
        'Remove current high res mesh from the list and return it to a normal state',
        command=lambda *args: rtb_remove(highresListDropdown))
    popup_remove_mesh = pm.popupMenu(parent=remove_mesh_button)
    pm.menuItem(l='Remove all live meshes',
                parent=popup_remove_mesh,
                command=lambda *args: rtb_remove_all(highresListDropdown))
    pm.setParent(prefix + '_columnLayout_main')

    # Scale
    pm.rowColumnLayout(nc=4, cw=([1, 50], [2, 100], [3, 25], [4, 25]))
    pm.picture(prefix + '_picture_layer_mesh',
               image=os.path.join(iconPath, 'meshLayering.png'),
               annotation='Drag slider to change mesh layering')
    pm.floatSlider(
        prefix + '_floatSlider_layer_mesh',
        h=25,
        step=0.01,
        min=0,
        max=1,
        v=lct_cfg.get('lcRetopoBasicLayering'),
        dragCommand=lambda *args: rtb_scale_layer_mesh(highresListDropdown))
    button_xray = pm.symbolButton(
        prefix + '_symbolButton_xray',
        h=25,
        image=os.path.join(iconPath, 'toggleXray.png'),
        bgc=[0.27, 0.27, 0.27],
        annotation='Toggle Mesh X-Ray',
        command=lambda *args: rtb_toggle_xray(highresListDropdown, 'active'))
    popup_xray = pm.popupMenu(parent=button_xray)
    pm.menuItem(l='xRay on/off all',
                parent=popup_xray,
                command=lambda *args: rtb_toggle_xray(highresListDropdown))

    button_hide = pm.symbolButton(
        prefix + '_symbolButton_hide',
        h=25,
        image=os.path.join(iconPath, 'hideMesh.png'),
        bgc=[0.27, 0.27, 0.27],
        annotation='Hide/Show Current High-Res',
        command=lambda *args: rtb_toggle_hide(highresListDropdown, 'active'))
    popup_hide = pm.popupMenu(parent=button_hide)
    pm.menuItem(
        l='Hide/Show all',
        parent=popup_hide,
        command=lambda *args: rtb_toggle_hide(highresListDropdown, 'all'))
    pm.menuItem(
        l='Hide/Show others',
        parent=popup_hide,
        command=lambda *args: rtb_toggle_hide(highresListDropdown, 'others'))
    pm.setParent(prefix + '_columnLayout_main')

    # Shader
    pm.rowColumnLayout(nc=3, cw=([1, 50], [2, 100], [3, 50]))
    pm.picture(image=os.path.join(iconPath, 'shaderOpacity.png'),
               enable=False,
               annotation='Drag slider to change shader transparency')
    pm.floatSlider(prefix + '_floatSlider_topo_trans',
                   h=25,
                   step=0.1,
                   min=0,
                   max=1,
                   v=lct_cfg.get('lcRetopoBasicShader'),
                   dragCommand=lambda *args: rtb_update_topo_transparency())
    pm.symbolButton(
        h=25,
        image=os.path.join(iconPath, 'assignShader.png'),
        bgc=[0.27, 0.27, 0.27],
        annotation=
        'Create and/or assign a semi-transparent shader to selected low res mesh',
        command=lambda *args: rtb_create_retopo_shader())
    pm.setParent(prefix + '_columnLayout_main')
    pm.separator(style='in', h=5)

    # Relax and Shrinkwrap
    pm.rowColumnLayout(nc=2)
    pm.button(
        l='Relax',
        bgc=colorWheel.getColorRGB(ci),
        w=100,
        h=25,
        annotation='Relax selected verts and shrink-wrap them to the live mesh',
        command=lambda *args: rtb_vert_ops(highresListDropdown,
                                           operation='relax'))
    ci += 1
    pm.button(l='Shrink-Wrap',
              bgc=colorWheel.getColorRGB(ci),
              w=100,
              h=25,
              annotation='Shrink-wrap selected verts to the live mesh',
              command=lambda *args: rtb_vert_ops(highresListDropdown,
                                                 operation='shrink'))
    ci += 1
    pm.setParent(prefix + '_columnLayout_main')

    # PROG Bar
    pm.progressBar(prefix + '_progress_control',
                   en=False,
                   w=202,
                   isInterruptable=True)
    pm.separator(style='in', h=5)

    # Tool List
    pm.gridLayout(nrc=[1, 5], cwh=[40, 40])
    ##1
    pm.symbolButton(prefix + '_symbolButton_select_mode',
                    image='selectByComponent.png',
                    c=lambda *args: rtb_toggle_select_mode(),
                    annotation='Toggle Object/Component Modes')
    ##2
    create_mesh = pm.symbolButton(
        image='polyCylinder.png',
        c=lambda *args: pm.polyCylinder(
            r=1, h=2, sx=8, sy=1, sz=1, ax=(0, 1, 0), rcp=0, cuv=3, ch=1),
        annotation='Create Poly Cylinder')
    popup_create_mesh = pm.popupMenu(parent=create_mesh)
    pm.menuItem(l='polyPlane',
                parent=popup_create_mesh,
                command=lambda *args: pm.polyPlane(
                    w=2, h=2, sx=1, sy=1, ax=(0, 1, 0), cuv=2, ch=1))
    pm.menuItem(l='polyCube',
                parent=popup_create_mesh,
                command=lambda *args: pm.polyCube(
                    w=2, h=2, d=2, sx=1, sy=1, ax=(0, 1, 0), cuv=2, ch=1))
    ##3
    pm.symbolButton(image='polyUnite.png',
                    command=lambda *args: lcGeometry.Geometry.merge_and_weld(),
                    annotation='Combine and Weld')
    ##4
    button_zeroX = pm.symbolButton(image=os.path.join(iconPath, 'zeroX.png'),
                                   command=lambda *args: rtb_zero('x'),
                                   annotation='Zero to world axis')
    popup_zeroX = pm.popupMenu(parent=button_zeroX)
    pm.menuItem(l='Zero X',
                parent=popup_zeroX,
                command=lambda *args: rtb_zero('x'))
    pm.menuItem(l='Zero Y',
                parent=popup_zeroX,
                command=lambda *args: rtb_zero('y'))
    pm.menuItem(l='Zero Z',
                parent=popup_zeroX,
                command=lambda *args: rtb_zero('z'))
    ##5
    pm.symbolButton(image='modelToolkit.png',
                    c=lambda *args: pm.mel.eval('ToggleModelingToolkit'),
                    annotation='Modeling Toolkit')

    #
    if not asChildLayout:
        mainWindow.show()
        pm.window(mainWindow.mainWindow, edit=True, h=winHeight, w=winWidth)
    else:
        pm.setParent('..')
        pm.setParent('..')

    # edit menus
    optionsMenu, helpMenu = lcUI.UI.lcToolbox_child_menu_edit(
        asChildLayout, windowName)

    pm.menuItem(parent=optionsMenu, divider=True, dividerLabel=windowName)
    pm.menuItem(parent=optionsMenu,
                l='Remove all live meshes',
                command=lambda *args: rtb_remove_all(highresListDropdown))

    # populate drowpdowns
    rtb_highres_list_populate(highresListDropdown)

    # restore interface selections
    highresListDropdown.setSelect(lct_cfg.get('lcRetopoBasicListItem'))
    rtb_choose_active(highresListDropdown)

    # vertex animation cache in viewport 2.0 must be disabled or the mesh will not update properly
    if pm.objExists('hardwareRenderingGlobals'):
        pm.PyNode('hardwareRenderingGlobals').vertexAnimationCache.set(0)
    rtb_init_select_mode()
    if not pm.scriptJob(ex=lct_cfg.get('lcRetopoBasicScriptJob')
                        ) or lct_cfg.get('lcRetopoBasicScriptJob') == 0:
        jobNum = pm.scriptJob(
            e=["SelectModeChanged", lambda *args: rtb_init_select_mode()],
            protected=True)
        lct_cfg.set('lcRetopoBasicScriptJob', jobNum)