예제 #1
0
    def create_cache(self, selection=True):
        register_time_callback()
        if self.cacheoptions.verbose is True:
            add_to_time_callback(time_verbose)

        start_frame, end_frame = self.cacheoptions.range
        workspace = self.workspace_widget.directory
        if workspace is None:
            return cmds.warning("no workspace set")
        set_last_used_workspace(workspace)
        self.workspace_widget.populate()

        if selection is True:
            nodes = self.nodetable.selected_nodes or []
        else:
            nodes = cmds.ls(type=DYNAMIC_NODES)
            nodes = filter_invisible_nodes_for_manager(nodes)

        create_and_record_cacheversion(
            workspace=workspace,
            start_frame=start_frame,
            end_frame=end_frame,
            nodes=nodes,
            behavior=self.cacheoptions.behavior,
            evaluate_every_frame=self.cacheoptions.samples_evaluated,
            save_every_evaluation=self.cacheoptions.samples_recorded,
            playblast=self.playblast.record_playblast,
            playblast_viewport_options=self.playblast.viewport_options)

        self.nodetable.set_workspace(workspace)
        self.nodetable.update_layout()
        self.selection_changed()
        unregister_time_callback()
        clear_time_callback_functions()
예제 #2
0
    def append_cache(self, selection=True):
        register_time_callback()
        if self.cacheoptions.verbose is True:
            add_to_time_callback(time_verbose)

        workspace = self.workspace_widget.directory
        if workspace is None:
            return cmds.warning("no workspace set")
        set_last_used_workspace(workspace)
        self.workspace_widget.populate()

        if selection is True:
            nodes = self.nodetable.selected_nodes or []
        else:
            nodes = cmds.ls(type=DYNAMIC_NODES)
            nodes = filter_invisible_nodes_for_manager(nodes)
        if not nodes:
            return cmds.warning("no nodes selected")

        cacheversion = None
        for node in nodes:
            cacheversions = filter_connected_cacheversions(
                [node], list_available_cacheversions(workspace))
            if not cacheversions:
                message = "some nodes doesn't have cache connected to append"
                return cmds.warning(message)
            if cacheversion is None:
                cacheversion = cacheversions[0]
            if cacheversions[0] != cacheversion:
                message = "append cache on multiple version is not suppported."
                return cmds.warning(message)

        append_to_cacheversion(
            nodes=nodes,
            cacheversion=cacheversion,
            evaluate_every_frame=self.cacheoptions.samples_evaluated,
            save_every_evaluation=self.cacheoptions.samples_recorded,
            playblast=self.playblast.record_playblast,
            playblast_viewport_options=self.playblast.viewport_options)
        self.nodetable.update_layout()
        self.selection_changed()
        unregister_time_callback()
        clear_time_callback_functions()
예제 #3
0
    def erase_cache(self, selection=True):
        register_time_callback()
        if self.cacheoptions.verbose is True:
            add_to_time_callback(time_verbose)

        start_frame, end_frame = self.cacheoptions.range
        workspace = self.workspace_widget.directory
        if workspace is None:
            return cmds.warning("no workspace set")
        set_last_used_workspace(workspace)
        self.workspace_widget.populate()

        if selection is True:
            nodes = self.nodetable.selected_nodes or []
        else:
            nodes = cmds.ls(type=DYNAMIC_NODES)
            nodes = filter_invisible_nodes_for_manager(nodes)
        cacheversions = filter_connected_cacheversions(
            nodes, list_available_cacheversions(workspace))

        if not cacheversions or len(cacheversions) > 1:
            cmds.warning(
                'no valid cache version or more than one cacheversion are '
                'connected to the selected dynamic nodes')
            self.create_cache(selection=selection)
            return

        record_in_existing_cacheversion(
            cacheversion=cacheversions[0],
            start_frame=start_frame,
            end_frame=end_frame,
            nodes=nodes,
            behavior=self.cacheoptions.behavior,
            evaluate_every_frame=self.cacheoptions.samples_evaluated,
            save_every_evaluation=self.cacheoptions.samples_recorded,
            playblast=self.playblast.record_playblast,
            playblast_viewport_options=self.playblast.viewport_options)
        self.nodetable.update_layout()
        self.selection_changed()
        unregister_time_callback()
        clear_time_callback_functions()
예제 #4
0
def start_playblast_record(
        directory, camera='perspShape', width=1024, height=748,
        viewport_display_values=None):
    for cam in cmds.ls(type="camera"):
        cmds.setAttr(cam + '.renderable', cam == camera)
    # the current global render settings are backup to be reset at the end of
    # the record. That's saved in the global dict BACKUPED_RENDER_SETTINGS
    # which is cleaned at the end. Ok global variables are evil, but there the
    # simplest solution found and I don't see case where this function will be
    # called two time before a stop_record_playblast call
    backup_current_render_settings()
    set_render_settings_for_playblast(viewport_display_values)
    # change the maya settings for the playblast
    # set the camera background to grey, that black by default
    attribute = "{}.backgroundColor".format(camera)
    cmds.setAttr(attribute, 0.375, 0.375, 0.375, type="double3")
    cmds.workspace(fileRule=['images', directory])

    global _registered_callback_function
    _registered_callback_function = partial(shoot_frame, camera, width, height)
    add_to_time_callback(_registered_callback_function)
예제 #5
0
    attribute = arguments.attribute_override
    value = arguments.attribute_override_value
    if attribute:
        if not cmds.objExists(attribute):
            msg = "{} doesn't exists and cannot be overrided".format(attribute)
            raise ValueError(msg)
        cmds.setAttr(attribute, value)
        force_log_info("attribute \"{}\" set to {}".format(attribute, value))

    text = '{}\n{}'.format(cacheversion.name, cacheversion.infos['comment'])
    create_viewport_text(text, arguments.playblast_camera)

    cmds.currentTime(arguments.start_frame, edit=True)
    # add the check to callbacks
    add_to_time_callback(time_verbose)
    func = partial(simulation_sanity_checks, arguments.nodes.split(', '),
                   arguments.timelimit, arguments.stretchmax)
    add_to_time_callback(func)
    register_time_callback()

    display_values = [
        bool(int(value))
        for value in arguments.viewport_display_values.split(' ')
    ]
    if display_values[-1] == 1:
        display_values[-1] = 0
        msg = 'Ornament option in viewport is not supported and turned off'
        force_log_info(msg)

    width, height = map(int, arguments.playblast_resolution.split(" "))