Esempio n. 1
0
def lcToolboxUI(dockable=False, *args, **kwargs):
    """ """
    prefix = conf['prefix']

    ci = 0  # color index iterator
    toolName = 'lcToolbox'
    icon = os.path.join(basePath, 'lcToolbox.png')
    winWidth = 231
    winHeight = conf['height']

    mainWindow = lcUI.lcWindow(prefix=prefix,
                               windowName=toolName,
                               width=winWidth,
                               height=winHeight,
                               icon=icon,
                               shelfCommand=shelfCommand,
                               annotation=conf['annotation'],
                               dockable=dockable,
                               menuBar=True,
                               rtf=True)
    mainWindow.create()

    principalMenus = mainWindow.menuBarLayout.getMenuArray()
    optionsMenu = principalMenus[0]
    helpMenu = principalMenus[-1]

    # add to help menu
    pm.menuItem(parent=helpMenu, divider=True, dividerLabel='Misc')
    pm.menuItem(parent=helpMenu,
                l='Reset All Tools',
                image='smallTrash.png',
                command=lambda *args: lct_cfg.reset_all_config())
    pm.menuItem(parent=helpMenu,
                l='Mini Maya Prefs',
                command=lambda *args: lcPrefs.MiniPrefsWindow().show())
    if lct_conf['release'] == 'dev':
        pm.menuItem(parent=helpMenu,
                    l='Switch to Pub',
                    image='blendColors.svg',
                    command=lambda *args: lcUpdate.Update.lct_auto_update(
                        confirmDiag=True, releaseSwitch='pub'))

    pm.columnLayout(prefix + '_columnLayout_main')
    mainWindow.show()

    lcTb_open_tool(mainWindow.windowName, lct_cfg.get('lcToolboxHeight'),
                   lct_cfg.get('lcToolboxCurrentTool'))

    # first launch window
    lcUI.UI.lcToolbox_first_launch_window()

    # check for an update
    lcUpdate.Update.update_periodic_check()
Esempio n. 2
0
def lcPolyBakeUI(dockable=False, asChildLayout=False, *args, **kwargs):
    """ """

    ci = 0  # color index iterator
    windowName = fileName
    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, '{}.png'.format(fileName))
    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')
    w = 200
    pm.text(l='', h=25)
    pm.text(l=windowName, w=w, h=25, align='center', font='boldLabelFont')
    pm.text(l='In Development', w=w, h=25, align='center', font='boldLabelFont')
    pm.text(l='', h=75)

    # Show Window
    if not asChildLayout:
        mainWindow.show()
        # force height and width
        pm.window(mainWindow.mainWindow, edit=True, h=winHeight, w=winWidth)
    else:
        pm.separator(style='none', h=5)
        pm.setParent('..')
        pm.setParent('..')

    # edit menus
    optionsMenu, helpMenu = lcUI.UI.lcToolbox_child_menu_edit(asChildLayout, windowName)
Esempio n. 3
0
def lcObjToolsUI(dockable=False, asChildLayout=False, *args, **kwargs):
    ''' '''
    global lct_cfg
    global prefix

    ci = 0 #color index iterator
    windowName = 'lcObjTools'
    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.normpath(os.path.join(basePath, 'lcObjTools.png'))
    winWidth  = 205
    winHeight = 158

    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')

    #
    lcUI.UI.lc_browse_field_button(width=200, textFieldName=prefix+'_textField_export_path', lct_cfg=lct_cfg, configAttr='lcObjToolsPath', placeholderText=defaultPath, annotation='Choose an OBJ export directory', fileMask='Wavefront Obj (*.obj)')
    pm.setParent(prefix+'_columnLayout_main')

    #
    pm.checkBox(prefix+'_checkBox_export_indi', l='Export Individual', v=True, changeCommand=lambda *args: lct_cfg.set('lcObjToolsExportIndividual', pm.checkBox(prefix+'_checkBox_export_indi', query=True, v=True)))
    pm.checkBox(prefix+'_checkBox_use_smooth', l='Use Smooth Preview', v=True, changeCommand=lambda *args: lct_cfg.set('lcObjToolsUseSmoothPreview', pm.checkBox(prefix+'_checkBox_use_smooth', query=True, v=True)))

    #
    pm.rowColumnLayout(nc=2, cw=([1,100], [2,100]) )
    pm.textField(prefix+'_textField_prefix', w=100, tx=' ', changeCommand=lambda *args: lct_cfg.set('lcObjToolsPrefix', pm.textField(prefix+'_textField_prefix', query=True, tx=True)))
    pm.text(l='   Prefix_', al='left')
    pm.setParent(prefix+'_columnLayout_main')

    #
    pm.rowColumnLayout(nc=2, cw=([1,166], [2,34]) )
    pm.columnLayout(w=169)
    pm.button(prefix+'_button_export', l='Export OBJ', bgc=colorWheel.getColorRGB(ci), annotation='Export the selected geometry', w=166, h=30, command=lambda *args: lcObj_exportObjs() )
    ci+=1
    pm.button(prefix+'_button_Import', l='Import Multiple OBJs', bgc=colorWheel.getColorRGB(ci), annotation='Clean import more than one obj', w=166, h=20, command=lambda *args: lcObj_importMultiple() )
    ci+=1
    pm.setParent('..')
    pm.columnLayout(w=31)
    pm.symbolButton(prefix+'_button_open_folder', w=30, h=50, bgc=(0.18,0.18,0.18), image=os.path.join(srcPath, 'icons', 'folder_med.png'), annotation='Open the export folder', command=lambda *args: lcObj_open_file_path(pm.textField(prefix+'_textField_export_path', query=True, text=True) ) )
    ci+=1

    #
    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="Offset External .obj's", command=lambda *args: lcObj_offsetMultiple() )

    #restore interface selections
    pm.checkBox(prefix+'_checkBox_export_indi', edit=True, value=lct_cfg.get('lcObjToolsExportIndividual'))
    pm.checkBox(prefix+'_checkBox_use_smooth', edit=True, value=lct_cfg.get('lcObjToolsUseSmoothPreview'))
    pm.textField(prefix+'_textField_export_path', edit=True, text=lct_cfg.get('lcObjToolsPath'))
    pm.textField(prefix+'_textField_prefix', edit=True, text=lct_cfg.get('lcObjToolsPrefix'))

    #run extra stuff
    lcPlugin.Plugin.reload_plugin(plugin='objExport', autoload=True)
    # validate export directory
    lcPath.Path.validatePathTextField(prefix+'_textField_export_path', lct_cfg, 'lcObjToolsPath', defaultPath)
Esempio n. 4
0
def lcTextureToolsUI(dockable=False, asChildLayout=False, *args, **kwargs):
    ''' '''
    global lct_cfg
    global prefix
    global height
    global defaultPath
    global defaultPrefix

    ci = 0  # color index iterator
    windowName = 'lcTextureTools'
    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, 'lcTextureTools.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')

    # RENAME TEXTURE NODES
    pm.text(l='- Rename File Texture Nodes -', font='boldLabelFont', al='center', w=200, h=20, bgc=colorWheel.darkgrey)
    pm.separator(style='none', h=3, w=200)

    pm.rowColumnLayout(nc=3, cw=([1, 40], [2, 110], [3, 50]))
    pm.textField(prefix + '_textField_prefix', placeholderText=defaultPrefix,
                 changeCommand=lambda *args: lct_cfg.set('lcTextureToolsPrefix',
                                                         pm.textField(prefix + '_textField_prefix', query=True,
                                                                      tx=True)),
                 receiveFocusCommand=lambda *args: lcTxT_rename_focus())
    pm.text(l="_'texture_file_name'")
    pm.button(prefix + '_button_rename', l='Rename', bgc=colorWheel.getColorRGB(ci),
              annotation='rename all file texture nodes', w=50,
              command=lambda *args: lcTxT_rename_textures(pm.textField(prefix + '_textField_prefix', q=True, tx=True)))
    ci += 1
    pm.setParent(prefix + '_columnLayout_main')
    pm.separator(style='in', h=8, w=200)

    # REPATH TEXTURE NODES
    pm.text(l='- Set new path for File Textures -', font='boldLabelFont', al='center', w=200, h=25,
            bgc=colorWheel.darkgrey)
    pm.separator(style='none', h=3, w=200)

    lcUI.UI.lc_browse_field_button(width=200, textFieldName=prefix + '_textField_new_path', lct_cfg=lct_cfg,
                                   configAttr='lcTextureToolsRepath', placeholderText=defaultPath,
                                   annotation='Choose a new texture directory')
    pm.setParent(prefix + '_columnLayout_main')

    #
    pm.rowColumnLayout(nc=2, cw=([1, 100], [2, 100]))
    pm.iconTextButton(w=100, h=25, style='iconAndTextHorizontal', label='Repath All', flat=False,
                      image=os.path.join(iconPath, 'repath.png'), bgc=colorWheel.getColorRGB(ci),
                      annotation='Repath all file texture nodes to exact path given',
                      command=lambda *args: lcTxT_repath_all())
    ci += 1
    pm.iconTextButton(w=100, h=25, style='iconAndTextHorizontal', label='Selected', flat=False,
                      image=os.path.join(iconPath, 'repath.png'), bgc=colorWheel.getColorRGB(ci),
                      annotation='Repath selected file texture nodes to exact path given',
                      command=lambda *args: lcTxT_repath_selected())
    ci += 1
    pm.setParent(prefix + '_columnLayout_main')
    #
    pm.rowColumnLayout(nc=2, cw=([1, 100], [2, 100]))
    pm.button(w=100, h=25, label='Intelli-All', bgc=colorWheel.getColorRGB(ci),
              annotation='Recursive search given path to repath all file texture nodes',
              command=lambda *args: lcTxT_intelligent_repath_all())
    ci += 1
    pm.button(w=100, h=25, label='Intelli-Selected', bgc=colorWheel.getColorRGB(ci),
              annotation='Recursive search given path to repath selected file texture nodes',
              command=lambda *args: lcTxT_intelligent_repath_selected())
    ci += 1
    pm.setParent(prefix + '_columnLayout_main')
    pm.separator(style='in', h=8, w=200)

    # REPATH SHADERS (dx11 only)
    pm.text(l='- Set new path for DX11 Shaders -', font='boldLabelFont', al='center', w=200, h=25,
            bgc=colorWheel.darkgrey)
    pm.separator(style='none', h=3, w=200)

    lcUI.UI.lc_browse_field_button(width=200, textFieldName=prefix + '_textField_new_shader_path', lct_cfg=lct_cfg,
                                   configAttr='lcTextureToolsShaderRepath', placeholderText=defaultPath,
                                   annotation='Choose a new shader directory')
    pm.setParent(prefix + '_columnLayout_main')

    #
    pm.rowColumnLayout(nc=2, cw=([1, 100], [2, 100]))
    pm.iconTextButton(w=100, h=25, style='iconAndTextHorizontal', label='Repath All', flat=False,
                      image=os.path.join(iconPath, 'shader_repath.png'), bgc=colorWheel.getColorRGB(ci),
                      annotation='Repath all dx11Shader nodes to exact path given',
                      command=lambda *args: lcTxT_shader_repath_all())
    ci += 1
    pm.iconTextButton(w=100, h=25, style='iconAndTextHorizontal', label='Selected', flat=False,
                      image=os.path.join(iconPath, 'shader_repath.png'), bgc=colorWheel.getColorRGB(ci),
                      annotation='Repath selected dx11Shader nodes to exact path given',
                      command=lambda *args: lcTxT_shader_repath_selected())
    ci += 1
    pm.setParent(prefix + '_columnLayout_main')
    pm.separator(style='in', h=8, w=200)

    # OPEN TEXTURES
    # a=170
    # b=200-a
    # pm.rowColumnLayout(nc=2, cw=([1,a], [2,b]))
    pm.text(l='- Open File Texture Nodes -', font='boldLabelFont', al='center', w=200, h=25, bgc=colorWheel.darkgrey)
    pm.separator(style='none', h=3, w=200)

    # pm.symbolButton(prefix+'_button_check_editors', visible=False, image=os.path.join(srcPath,'icons','hint.png'), annotation='Setup Image File Editors', command=lambda *args: lcTxT_update_maya_prefs(prefix+'_button_check_editors') )
    pm.setParent(prefix + '_columnLayout_main')
    pm.rowColumnLayout(nc=2, cw=([1, 100], [2, 100]))
    pm.iconTextButton(w=100, h=25, style='iconAndTextHorizontal', label='Open All', flat=False,
                      image=os.path.join(iconPath, 'open.png'), bgc=colorWheel.getColorRGB(ci),
                      annotation='Open all file texture nodes in default associated program',
                      command=lambda *args: lcTxT_open_textures('all'))
    ci += 1
    pm.iconTextButton(w=100, h=25, style='iconAndTextHorizontal', label='Selected', flat=False,
                      image=os.path.join(iconPath, 'open.png'), bgc=colorWheel.getColorRGB(ci),
                      annotation='Open selected file texture nodes in default associated program',
                      command=lambda *args: lcTxT_open_textures('selected'))
    ci += 1
    pm.separator(style='none', h=8, w=200)

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

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

    # restore interface selections
    pm.textField(prefix + '_textField_new_path', edit=True, text=lct_cfg.get('lcTextureToolsRepath'))
    pm.textField(prefix + '_textField_prefix', edit=True, text=lct_cfg.get('lcTextureToolsPrefix'))
    pm.textField(prefix + '_textField_new_shader_path', edit=True, text=lct_cfg.get('lcTextureToolsShaderRepath'))

    # run extra stuff
    pm.setFocus(prefix + '_button_rename')

    # validate export directory
    lcPath.Path.validatePathTextField(prefix + '_textField_new_path', lct_cfg, 'lcTextureToolsRepath', defaultPath)
    lcPath.Path.validatePathTextField(prefix + '_textField_new_shader_path', lct_cfg, 'lcTextureToolsShaderRepath',
                                      defaultPath)
Esempio n. 5
0
def lcBatchBakeUI(dockable=False, asChildLayout=False, *args, **kwargs):
    ''' '''
    global lct_cfg
    global prefix
    global defaultPath

    windowName = 'lcBatchBake'
    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 = basePath + 'lcBatchBake.png'
    winWidth = 205
    winHeight = 243

    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')

    # check for mental ray plugin
    mental_ray_available = lcPlugin.Plugin.reload_plugin(plugin='Mayatomr',
                                                         autoload=True)

    if mental_ray_available:
        #
        pm.rowColumnLayout(nc=2, cw=([1, 100], [2, 100]))
        pm.button(l='Make Texture Set',
                  bgc=colorWheel.getPrev(),
                  w=100,
                  h=35,
                  annotation='Create a Texture bake set',
                  command=lambda *args: lcBake_make_new_bake_set(
                      bakeSetListDropdown, 'texture'))
        pm.button(l='Make Vertex Set',
                  bgc=colorWheel.getPrev(),
                  w=100,
                  h=35,
                  annotation='Create a Texture bake set',
                  command=lambda *args: lcBake_make_new_bake_set(
                      bakeSetListDropdown, 'vertex'))
        pm.setParent(prefix + '_columnLayout_main')

        #
        pm.rowColumnLayout(nc=3, cw=([1, 25], [2, 150], [3, 25]))
        pm.symbolButton(h=25,
                        image=os.path.join(iconPath, 'reloadList.png'),
                        annotation='Reload the bake set list',
                        command=lambda *args: lcBake_populate_bake_set_list(
                            bakeSetListDropdown))
        bakeSetListDropdown = pm.optionMenu(prefix +
                                            '_optionMenu_bake_set_list',
                                            w=150,
                                            h=25,
                                            annotation='List of bake sets')
        bakeSetListDropdown.changeCommand(
            lambda *args: lcBake_choose_active(bakeSetListDropdown))
        button_delete_sets = pm.symbolButton(
            h=25,
            image=os.path.join(iconPath, 'deleteItem.png'),
            annotation='Delete this bake set',
            command=lambda *args: lcBake_delete_current_bake_set(
                bakeSetListDropdown))
        popup_delete_sets = pm.popupMenu(parent=button_delete_sets)
        pm.menuItem(l='Delete all bake sets',
                    parent=popup_delete_sets,
                    command=lambda *args: lcBake_delete_all_bake_sets(
                        bakeSetListDropdown))
        pm.setParent(prefix + '_columnLayout_main')

        #
        pm.rowColumnLayout(nc=2,
                           cw=([1, 100],
                               [2,
                                100]))  #nc=3, cw=([1,50], [2,50], [3,100] ) )
        pm.button(l='+ Add',
                  bgc=colorWheel.getPrev(),
                  w=100,
                  h=25,
                  annotation='Add geometry to bake set',
                  command=lambda *args: lcBake_add_to_current_bake_set(
                      bakeSetListDropdown))
        # pm.button(l='- Rem', bgc=colorWheel.getPrev(), w=50, h=25, annotation='Remove geometry from bake set', command=lambda *args: lcBake_fake_command() )
        # ci+=1
        pm.button(l='Edit Options',
                  bgc=colorWheel.getPrev(),
                  w=100,
                  h=25,
                  annotation='Edit the bake set options',
                  command=lambda *args: lcBake_show_bake_set_attrs(
                      bakeSetListDropdown))
        pm.setParent(prefix + '_columnLayout_main')

        #
        pm.rowColumnLayout(nc=2, cw=([1, 75], [2, 125]))
        pm.text(l='Bake Camera: ', al='right')
        cameraListDropdown = pm.optionMenu(prefix + '_optionMenu_camera_list',
                                           w=125,
                                           h=25,
                                           annotation='List of cameras')
        cameraListDropdown.changeCommand(lambda *args: lct_cfg.set(
            'lcBatchBakeCamList', cameraListDropdown.getSelect()))
        pm.text(l='')
        pm.checkBox(
            prefix + '_checkBox_shadows',
            w=125,
            h=25,
            value=True,
            label='Shadows and AO?',
            annotation='Turn on to bake shadows and ambient occlusion',
            changeCommand=lambda *args: lct_cfg.set(
                'lcBatchBakeShadows',
                pm.checkBox(prefix + '_checkBox_shadows', query=True, v=True)))
        pm.setParent(prefix + '_columnLayout_main')

        #
        pm.separator(style='none', h=10)
        lcUI.UI.lc_browse_field_button(width=200,
                                       textFieldName=prefix +
                                       '_textField_texture_path',
                                       lct_cfg=lct_cfg,
                                       configAttr='lcBatchBakePath',
                                       placeholderText=defaultPath,
                                       annotation='Choose an export directory')

        # pm.rowColumnLayout(nc=2, cw=([1,150], [2,50]) )
        # pm.textField(prefix+'_textField_texture_path', tx=defaultPath, annotation='Output directory path', w=150, changeCommand=lambda *args: lct_cfg.set('lcBatchBakePath', pm.textField(prefix+'_textField_texture_path', query=True, tx=True)))
        # pm.button(prefix+'_button_browse_path', l='Browse', bgc=colorWheel.getPrev(), annotation='Choose a directory', w=50, command=lambda *args: lcBake_setExportPath() )
        # ci+=1
        pm.setParent(prefix + '_columnLayout_main')

        #
        pm.rowColumnLayout(nc=2, cw=([1, 150], [2, 50]))
        pm.button(l='Bake It !!',
                  bgc=colorWheel.getPrev(),
                  w=150,
                  h=40,
                  annotation='Bake to texture or vertex',
                  command=lambda *args: lcBake_convert_lightmap(
                      bakeSetListDropdown, cameraListDropdown))
        pm.symbolButton(prefix + '_button_open_folder',
                        bgc=(0.18, 0.18, 0.18),
                        image=os.path.join(srcPath, 'icons', 'folder_med.png'),
                        annotation='Open the export folder',
                        command=lambda *args: lcBake_openExportPath())

    # mental ray was not found!
    else:
        pm.text(l="Mental Ray plug-in not found",
                al='center',
                w=200,
                h=215,
                font='boldLabelFont')

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

    #
    if mental_ray_available:
        #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='Delete All Bake Sets',
                    command=lambda *args: lcBake_delete_all_bake_sets(
                        bakeSetListDropdown))

        #populate lists
        lcBake_populate_bake_set_list(bakeSetListDropdown)
        lcBake_populate_camera_list(cameraListDropdown)

        #Restore Interface Selections
        bakeSetListDropdown.setSelect(lct_cfg.get('lcBatchBakeSetList'))
        cameraListDropdown.setSelect(lct_cfg.get('lcBatchBakeCamList'))
        pm.checkBox(prefix + '_checkBox_shadows',
                    edit=True,
                    value=lct_cfg.get('lcBatchBakeShadows'))
        pm.textField(prefix + '_textField_texture_path',
                     edit=True,
                     text=lct_cfg.get('lcBatchBakePath'))

        #update interface highlighting
        if lct_cfg.get('lcBatchBakeSetList') > 1:
            lcBake_glow(bakeSetListDropdown)

        # validate export directory
        lcPath.Path.validatePathTextField(prefix + '_textField_texture_path',
                                          lct_cfg, 'lcBatchBakePath',
                                          defaultPath)
Esempio n. 6
0
def lcUVToolsUI(dockable=False, asChildLayout=False, *args, **kwargs):
    ''' '''
    global lct_cfg
    global prefix
    global height

    windowName = 'lcUVTools'
    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, 'lcUVTools.png')

    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=width,
                                   height=height,
                                   icon=icon,
                                   shelfCommand=shelfCommand,
                                   annotation=annotation,
                                   dockable=dockable,
                                   menuBar=True)
        mainWindow.create()

    # column for the uv tool bar
    pm.columnLayout(prefix + '_columnLayout_main')

    # build ui in parts

    # Row 1 - basic
    pm.rowColumnLayout(nc=4, cw=[(1, 95), (2, 35), (3, 35), (4, 35)])
    pm.columnLayout()
    pm.checkBox(
        prefix + '_checkBox_shell',
        l='  Shell Mode',
        v=False,
        changeCommand=lambda *args: lct_cfg.set(
            'lcUVToolsShell',
            pm.checkBox(prefix + '_checkBox_shell', query=True, v=True)))
    pm.button(l='Grab Shell',
              bgc=colorWheel.getNext(),
              h=20,
              w=93,
              command=lambda *args: lcGeometry.UV().grabShell())
    pm.setParent('..')
    pm.symbolButton(image=os.path.join(srcPath, 'icons', 'temp.png'),
                    enable=False,
                    visible=False)

    button_snapshot = pm.symbolButton(image='polyUVSnapshot.png',
                                      annotation='Take UV Snapshot',
                                      command=lambda *args: uvmp_uv_snapshot())
    popup_snapshot = pm.popupMenu(parent=button_snapshot)
    pm.menuItem(
        prefix + '_checkBox_antiAlias',
        l='Antialias',
        checkBox=False,
        parent=popup_snapshot,
        command=lambda *args: lct_cfg.set(
            'lcUVToolsAntialias',
            pm.menuItem(
                prefix + '_checkBox_antiAlias', query=True, checkBox=True)))
    pm.menuItem(
        prefix + '_checkBox_openPS',
        l='Auto Open PS',
        checkBox=True,
        parent=popup_snapshot,
        command=lambda *args: lct_cfg.set(
            'lcUVToolsOpenPS',
            pm.menuItem(prefix + '_checkBox_openPS', query=True, checkBox=True)
        ))

    pm.symbolButton(image='textureEditor.png',
                    annotation='Open the UV Editor',
                    command=lambda *args: pm.mel.eval('TextureViewWindow'))
    # pm.text(l='')
    pm.setParent(prefix + '_columnLayout_main')

    # Row 2
    pm.separator(style='in', h=10, w=200)
    row2 = pm.rowColumnLayout(nc=3, cw=[(1, 66), (2, 66), (3, 66)])

    ##MOVE
    pm.columnLayout()
    pm.text(l='Move', w=66, align='center')
    pm.separator(style='none', h=9)
    bgc = colorWheel.getNext()
    pm.rowColumnLayout(nc=3, cw=[(1, 15), (2, 34), (3, 15)])
    pm.text(l='')
    pm.button(
        l='^',
        h=15,
        bgc=bgc,
        command=lambda *args: uvmp_move(
            [0, 1 * pm.floatField(prefix + '_move_value', q=True, v=True)]))
    pm.text(l='')
    pm.button(
        l='<',
        bgc=bgc,
        command=lambda *args: uvmp_move(
            [-1 * pm.floatField(prefix + '_move_value', q=True, v=True), 0]))
    pm.floatField(prefix + '_move_value', h=34, v=1.00, pre=2)
    pm.button(
        l='>',
        bgc=bgc,
        command=lambda *args: uvmp_move(
            [1 * pm.floatField(prefix + '_move_value', q=True, v=True), 0]))
    pm.text(l='')
    pm.button(
        l='v',
        h=15,
        bgc=bgc,
        command=lambda *args: uvmp_move(
            [0, -1 * pm.floatField(prefix + '_move_value', q=True, v=True)]))
    pm.text(l='')
    pm.setParent(row2)

    ##SCALE
    pm.columnLayout()
    pm.text(l='Scale', w=66, align='center')
    pm.separator(style='none', h=4)
    bgc = colorWheel.getNext()
    pm.rowColumnLayout(nc=3, cw=[(1, 25), (2, 14), (3, 25)])
    pm.button('U+',
              bgc=bgc,
              c=lambda *args: uvmp_scale(
                  [pm.floatField(prefix + '_scale_value', q=True, v=True), 1]))
    pm.button('+',
              bgc=bgc,
              c=lambda *args: uvmp_scale([
                  pm.floatField(prefix + '_scale_value', q=True, v=True),
                  pm.floatField(prefix + '_scale_value', q=True, v=True)
              ]))
    pm.button(
        'V+',
        bgc=bgc,
        c=lambda *args: uvmp_scale(
            [1, pm.floatField(prefix + '_scale_value', q=True, v=True)]))
    pm.setParent('..')
    pm.rowColumnLayout(nc=3, cw=[(1, 13), (2, 38), (3, 13)])
    pm.text(l='')
    pm.floatField(prefix + '_scale_value', v=2.00, min=1.0, pre=2, h=25)
    pm.text(l='')
    pm.setParent('..')
    pm.rowColumnLayout(nc=3, cw=[(1, 25), (2, 14), (3, 25)])
    pm.button(
        'U-',
        bgc=bgc,
        c=lambda *args: uvmp_scale([
            pm.floatField(prefix + '_scale_value', q=True, v=True) / pow(
                pm.floatField(prefix + '_scale_value', q=True, v=True), 2), 1
        ]))  # x/(x^2)
    pm.button(
        '-',
        bgc=bgc,
        c=lambda *args: uvmp_scale([
            pm.floatField(prefix + '_scale_value', q=True, v=True) / pow(
                pm.floatField(prefix + '_scale_value', q=True, v=True), 2),
            pm.floatField(prefix + '_scale_value', q=True, v=True) / pow(
                pm.floatField(prefix + '_scale_value', q=True, v=True), 2)
        ]))  # x/(x^2)
    pm.button(
        'V-',
        bgc=bgc,
        c=lambda *args: uvmp_scale([
            1,
            pm.floatField(prefix + '_scale_value', q=True, v=True) / pow(
                pm.floatField(prefix + '_scale_value', q=True, v=True), 2)
        ]))  # x/(x^2)
    pm.setParent(row2)

    ##ROTATE
    pm.columnLayout()
    pm.text(l='Rotate', w=66, align='center')
    pm.separator(h=2)
    bgc = colorWheel.getNext()
    pm.rowColumnLayout(nc=2, cw=[(1, 16), (2, 48)])
    pm.columnLayout()
    pm.button(prefix + '_clockwise',
              l='>',
              bgc=bgc,
              w=15,
              h=20,
              c=lambda *args: uvmp_rotate(-pm.floatField(
                  prefix + '_rotate_value', q=True, v=True)))
    pm.button(prefix + '_counter_clockwise',
              l='<',
              bgc=bgc,
              w=15,
              h=20,
              c=lambda *args: uvmp_rotate(
                  pm.floatField(prefix + '_rotate_value', q=True, v=True)))
    pm.setParent('..')
    pm.floatField(prefix + '_rotate_value', v=45.00, pre=2, h=40)
    pm.setParent('..')
    pm.floatSlider(prefix + '_rotate_free',
                   min=-1,
                   max=1,
                   v=0,
                   w=64,
                   dc=uvmp_rotate_interactive,
                   cc=uvmp_reset_slider)
    pm.button(l='align',
              bgc=bgc,
              w=65,
              h=20,
              command=lambda *args: uvmp_align_cardinal())
    pm.setParent(prefix + '_columnLayout_main')

    # Row 3
    pm.separator(style='in', h=10, w=200)
    row3 = pm.rowColumnLayout(nc=2, cw=[(1, 100), (2, 100)])
    uvmp_texture_range_UI()
    pm.setParent(row3)
    ##TOOLS
    pm.gridLayout(nrc=[2, 2], cwh=[48, 48])
    pm.symbolButton(image='expandContainer.png',
                    bgc=(0.25, 0.5, 0.25),
                    command=lambda *args: uvmp_split_edges_at_UVs(),
                    annotation='Enter UV Unfold')

    pm.symbolButton(image='collapseContainer.png',
                    bgc=(0.5, 0.25, 0.25),
                    command=lambda *args: uvmp_merge_special(),
                    annotation='Exit UV Unfold')

    pm.symbolButton(image='polyMapCut.png',
                    command=lambda *args: uvmp_cut_edge(),
                    annotation='Cut UV Edge')

    pm.symbolButton(image='textureEditorUnfoldUVsLarge.png',
                    command=lambda *args: uvmp_auto_layout(),
                    annotation='Auto UV Layout')

    pm.setParent(prefix + '_columnLayout_main')

    # #Row 4
    # pm.separator(style='in', h=10, w=200)
    # pm.rowColumnLayout(nc=2, cw=[(1,100), (2,100)])

    # pm.setParent(prefix+'_columnLayout_main')

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

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

    # restore interface selections
    pm.checkBox(prefix + '_checkBox_shell',
                edit=True,
                value=lct_cfg.get('lcUVToolsShell'))

    # extra stuff
    pm.setFocus(
        prefix + '_move_value'
    )  # set cursor focus on move value, otherwise it sets to first available ui element
    lcPlugin.Plugin.reload_plugin(plugin='Unfold3D', autoload=True)
Esempio n. 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)
Esempio n. 8
0
def lcTexGenUI(dockable=False, asChildLayout=False, *args, **kwargs):
    """ """

    ci = 0  # color index iterator
    windowName = fileName
    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, '{}.png'.format(fileName))
    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')
    w = 200

    # check for dx11Shader plugin
    dx11_available = lcPlugin.Plugin.reload_plugin(plugin='dx11Shader',
                                                   autoload=True)

    if dx11_available:
        # annotations
        anno_reset = 'Reset Shader'
        anno_attrs = 'Open Shader Attributes'
        anno_clear = 'Clear Shader Assignment'
        anno_assign = 'Assign Shader to Selection'

        ##########
        # Shader1
        a = w / 2
        b = w - a
        pm.rowColumnLayout(prefix + '_rowColumnLayout_shaders',
                           nc=2,
                           cw=([1, a], [2, b]))
        pm.frameLayout(label='Texture', mh=8, mw=8)
        pm.columnLayout()
        pm.rowColumnLayout(nc=2, cw=([1, 6], [2, 64]))
        pm.text(l='')
        pm.swatchDisplayPort(prefix + '_swatch_tex',
                             wh=(64, 64),
                             renderSize=64,
                             pc=lambda *args: lcTxGn_open_shader_attrs(
                                 shaderName=s_texgen_name))
        pm.setParent('..')
        pm.separator(style='none', h=8)
        fw = w / 2 - 21
        a = fw * 0.3
        b = fw - a
        pm.rowColumnLayout(nc=2, cw=([1, a], [2, b]))
        pm.button(l='R',
                  w=a,
                  command=lambda *args: lcTxGn_reset_shader(shaderName=
                                                            s_texgen_name),
                  annotation=anno_reset)
        pm.button(
            l='Assign',
            w=b,
            bgc=(0.75, 0.4, 0.4),
            command=lambda *args: lcTxGn_assign(shaderName=s_texgen_name),
            annotation=anno_assign)
        pm.button(l='C',
                  w=a,
                  command=lambda *args: lcTxGn_assign(shaderName=s_texgen_name,
                                                      mode='clear'),
                  annotation=anno_clear)
        pm.button(l='Attrs',
                  w=b,
                  command=lambda *args: lcTxGn_open_shader_attrs(
                      shaderName=s_texgen_name),
                  annotation=anno_attrs)

        ##########
        # Shader2
        pm.setParent(prefix + '_rowColumnLayout_shaders')
        pm.frameLayout(label='AO', mh=8, mw=8)
        pm.columnLayout()
        pm.rowColumnLayout(nc=2, cw=([1, 6], [2, 64]))
        pm.text(l='')
        pm.swatchDisplayPort(
            prefix + '_swatch_ao',
            wh=(64, 64),
            renderSize=64,
            pc=lambda *args: lcTxGn_open_shader_attrs(shaderName=s_aogen_name))
        pm.setParent('..')
        pm.separator(style='none', h=8)
        fw = w / 2 - 21
        a = fw * 0.3
        b = fw - a
        pm.rowColumnLayout(nc=2, cw=([1, a], [2, b]))
        pm.button(
            l='R',
            w=a,
            command=lambda *args: lcTxGn_reset_shader(shaderName=s_aogen_name),
            annotation=anno_reset)
        pm.button(l='Assign',
                  w=b,
                  bgc=(0.75, 0.4, 0.4),
                  command=lambda *args: lcTxGn_assign(shaderName=s_aogen_name),
                  annotation=anno_assign)
        pm.button(l='C',
                  w=a,
                  command=lambda *args: lcTxGn_assign(shaderName=s_aogen_name,
                                                      mode='clear'),
                  annotation=anno_clear)
        pm.button(l='Attrs',
                  w=b,
                  command=lambda *args: lcTxGn_open_shader_attrs(shaderName=
                                                                 s_aogen_name),
                  annotation=anno_attrs)

        ##########
        # Tools
        pm.setParent(prefix + '_columnLayout_main')
        c = 6
        a = (w / 2) - (c / 2)
        pm.rowColumnLayout(nc=3, cw=([1, a], [2, c], [3, a]))
        pm.columnLayout(w=a)
        pm.button(l='Preview',
                  w=a - 2,
                  command=lambda *args: lcTxGn_preview_shader(),
                  annotation='Preview UV flattened mesh')
        pm.separator(style='none', h=4)
        pm.text(l='VP2 Mode:', w=a)
        pm.text(prefix + '_text_vp2mode', l='OpenGL', w=a)
        pm.setParent('..')
        pm.separator(style='in', w=c, horizontal=False)
        pm.columnLayout(w=a)
        pm.button(l='Render',
                  w=a - 2,
                  command=lambda *args: lcTxGn_render_shader(),
                  annotation='Render UV flattened mesh')
        pm.checkBox(prefix + '_checkBox_overwrite', l='Overwrite Img', v=True)
        pm.checkBox(prefix + '_checkBox_open', l='Auto open PS', v=True)

    # dx11Shader was not found!
    else:
        pm.text(l="dx11Shader plug-in not found",
                al='center',
                w=200,
                h=215,
                font='boldLabelFont')

    # Show Window
    if not asChildLayout:
        mainWindow.show()
        # force height and width
        pm.window(mainWindow.mainWindow, edit=True, h=winHeight, w=winWidth)
    else:
        pm.separator(style='none', h=5)
        pm.setParent('..')
        pm.setParent('..')

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

        # restore interface from lct_cfg

        # plugins
        lcPlugin.Plugin.reload_plugin(plugin='dx11Shader', autoload=True)
        lcPlugin.Plugin.reload_plugin(plugin='glslShader', autoload=True)

        # activate texture mode
        lcUtility.Editor.update_model_editors(displayAppearance='smoothShaded',
                                              displayTextures=True)

        # extra stuff
        vp2RenderingEngine = pm.optionVar(query='vp2RenderingEngine')
        if vp2RenderingEngine in (1, 'DirectX11'):
            pm.text(prefix + '_text_vp2mode', edit=True, l='DX11')
            lcTxGn_init_shaders()
        if vp2RenderingEngine in (2, 'OpenGL'):
            pm.text(prefix + '_text_vp2mode', edit=True, l='OpenGL')
            lcUtility.Utility.lc_print(
                'Switch to DX11, OpenGL not yet implemented', mode='warning')
            pm.columnLayout(prefix + '_columnLayout_main',
                            edit=True,
                            enable=False)
Esempio n. 9
0
def lcCamUtilUI(dockable=False, asChildLayout=False, *args, **kwargs):
    """ """

    ci = 0  # color index iterator
    windowName = fileName
    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, '{}.png'.format(fileName))
    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()

    # UI HERE
    pm.columnLayout(prefix + '_columnLayout_main')
    w = 200
    pm.text(l="Values update for active camera",
            w=w,
            h=25,
            align='center',
            font='boldLabelFont')

    pm.separator(style='in', h=3, w=winWidth)

    pm.rowColumnLayout(prefix + '_rowColumnMain', nc=2, cw=([1, 150], [2, 50]))

    pm.text(l="Camera Focal Length", w=150)
    ff_focal = pm.floatField(
        v=35,
        min=2.5,
        pre=1,
        step=1.0,
        w=50,
        enterCommand=lambda *args: set_camera_attrs(ui_elements),
        dragCommand=lambda *args: set_camera_attrs(ui_elements),
        rfc=lambda *args: get_camera_attrs(ui_elements))

    pm.text(l="Camera Near Clip Plane", w=150)
    ff_near = pm.floatField(
        v=0.100,
        min=0.001,
        pre=3,
        step=0.001,
        w=50,
        enterCommand=lambda *args: set_camera_attrs(ui_elements),
        dragCommand=lambda *args: set_camera_attrs(ui_elements),
        rfc=lambda *args: get_camera_attrs(ui_elements))

    pm.text(l="Camera Far Clip Plane", w=150)
    ff_far = pm.floatField(
        v=1000.0,
        min=0.001,
        pre=0,
        step=10.0,
        w=50,
        enterCommand=lambda *args: set_camera_attrs(ui_elements),
        dragCommand=lambda *args: set_camera_attrs(ui_elements),
        rfc=lambda *args: get_camera_attrs(ui_elements))

    pm.text(l="Camera Overscan", w=150)
    ff_overscan = pm.floatField(
        v=1.0,
        min=0.001,
        pre=3,
        step=0.01,
        w=50,
        enterCommand=lambda *args: set_camera_attrs(ui_elements),
        dragCommand=lambda *args: set_camera_attrs(ui_elements),
        rfc=lambda *args: get_camera_attrs(ui_elements))

    pm.text(l="Camera Background Color", w=150)
    csg_background = pm.colorSliderGrp(
        cw1=50,
        rgb=(0.36, 0.36, 0.36),
        changeCommand=lambda *args: set_camera_attrs(ui_elements))

    pm.text(l="Camera Gradient Top", w=150)
    csg_top = pm.colorSliderGrp(
        cw1=50,
        rgb=(0.54, 0.62, 0.7),
        changeCommand=lambda *args: set_camera_attrs(ui_elements))

    pm.text(l="Camera Gradient Bottom", w=150)
    csg_bottom = pm.colorSliderGrp(
        cw1=50,
        rgb=(0.5, 0.5, 0.5),
        changeCommand=lambda *args: set_camera_attrs(ui_elements))

    pm.setParent('..')

    pm.button(l="Toggle Background Gradient",
              w=winWidth,
              h=32,
              al='center',
              bgc=(0.75, 0.5, 0.2),
              command=lambda *args: lcCamera.Camera.toggle_background())

    ui_elements = [
        ff_focal, ff_near, ff_far, ff_overscan, csg_background, csg_top,
        csg_bottom
    ]

    # Show Window
    if not asChildLayout:
        mainWindow.show()
        # force height and width
        pm.window(mainWindow.mainWindow, edit=True, h=winHeight, w=winWidth)
    else:
        pm.separator(style='none', h=5)
        pm.setParent('..')
        pm.setParent('..')

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

    # restore interface from lct_cfg

    # misc
    get_camera_attrs(ui_elements)
    set_camera_attrs(ui_elements)