Пример #1
0
def getGameExport(name=''):
    """
    Gets the game path for the given scene. If no scene open, will use game root directory.

    Args:
        name (string): Name of file to return.

    Returns:
        (string): Full path with given name.
    """
    scene_path = pm.sceneName()
    game_directory = store.get(pcfg.game_directory)
    relative_directory = ''

    if not game_directory:
        pm.error(
            'Game directory is not set. Please use "Piper>Export>Set Game Directory" to set export directory.'
        )

    if scene_path:
        source_directory = os.path.dirname(scene_path)
        art_directory = store.get(pcfg.art_directory)

        # gets the relative path using the art directory
        if scene_path.startswith(art_directory):
            relative_directory = source_directory.lstrip(art_directory)
        else:
            pm.warning(
                scene_path +
                ' is not in art directory! Returning game directory root.')

    export_path = os.path.join(game_directory, relative_directory,
                               name).replace('\\', '/')
    return export_path
Пример #2
0
def getGameTextureExport(texture):
    """
    Gets the path to export the given texture to.

    Args:
        texture (string): Full art directory path of texture file.

    Returns:
        (string): Full game directory path of where given texture would export to.
    """
    relative_directory = ''
    art_directory = store.get(pcfg.art_directory)
    game_directory = store.get(pcfg.game_directory)

    if texture.startswith(art_directory):
        relative_directory = texture.lstrip(art_directory)
    else:
        pm.warning(texture +
                   ' is not in art directory! Returning game directory root.')

    export_path = os.path.join(game_directory,
                               relative_directory).replace('\\', '/')
    export_path = export_path.replace(pcfg.art_textures_directory_name,
                                      pcfg.game_textures_directory_name)
    return export_path
Пример #3
0
def onNewSceneOpened(*args):
    """
    Called when a new scene is opened, usually through a callback.
    """
    if store.get(pcfg.use_piper_units):
        loadDefaults()

    if store.get(pcfg.use_piper_render):
        loadRender()
Пример #4
0
def startup():
    """
    To called when Maya starts up.
    """
    if store.get(pcfg.use_piper_units):
        loadDefaults()

    if store.get(pcfg.unload_unwanted):
        plugin.unloadUnwanted()

    setStartupProject()
    loadRender()
Пример #5
0
    def getHdrImagePath():
        """
        Gets the path to the HDR image set in the piper settings. Tries to make path relative to art directory.

        Returns:
            (string): Path to the user set HDR image. Empty string if not set.
        """
        # get user defined settings
        hdr_image_path = store.get(pcfg.hdr_image_path)
        art_directory = store.get(pcfg.art_directory)

        # attempt to make path relative to art directory
        hdr_image_path = hdr_image_path.split(art_directory + '/')[-1]

        return hdr_image_path
Пример #6
0
def getRelativeArt(path='', name=''):
    """
    Gets the relative art path of given path. If path not given will use current scene path.

    Args:
        path (string): Path to get relative art directory of.

        name (string): If given, will change the name of the file to the given name.

    Returns:
        (string): Path relative to art directory set through settings.
    """
    if not path:
        path = pm.sceneName()

    if not path:
        pm.error('Scene is not saved! ')

    art_directory = store.get(pcfg.art_directory)
    if not path.startswith(art_directory):
        pm.error(path + ' is not in the art directory: ' + art_directory)

    if name:
        directory = os.path.dirname(path)
        old_name, extension = os.path.splitext(os.path.basename(path))
        path = os.path.join(directory, name + extension)

    return path.lstrip(art_directory)
Пример #7
0
    def build(self):
        self.addCheckbox('Use Piper Units', store.get(pcfg.use_piper_units),
                         self.onUseUnitsPressed)
        self.addCheckbox('Use Piper Render', store.get(pcfg.use_piper_render),
                         self.onUseRenderPressed)
        self.addCheckbox('Export In Ascii', store.get(pcfg.export_ascii),
                         self.onExportInAsciiPressed)
        self.addCheckbox('Unload Unwanted Plug-ins',
                         store.get(pcfg.unload_unwanted),
                         self.onUnloadUnwantedPressed)
        self.add('Set HDR Image', self.onSetHdrImagePressed)
        self.addSeparator()
        self.add('Assign Hotkeys', settings.hotkeys)

        self.addSeparator()
        self.add('Uninstall Piper', self.uninstall)