Exemple #1
0
    def _register_operations(self):
        """Register operations that should be run by the manager.

        :return:

        """
        files = _find_operation_files()

        for file_path in files:
            data = _get_operation_data(file_path)

            if "operations" not in data:
                continue

            for operation in data["operations"]:
                module_name, class_name = operation

                # Import the operation class.
                cls = _get_class(module_name, class_name)

                if cls is None:
                    logger.warning("Could not load {} from {}".format(
                        class_name, module_name))

                    continue

                else:
                    logger.debug("Registering {} ({})".format(
                        class_name, module_name))

                # Add an instance of it to our operations list.
                self.operations.append(cls(self))
    def _register_operations(self):
        """Register operations that should be run by the manager.

        :return:

        """
        files = _find_operation_files()

        for file_path in files:
            data = _get_operation_data(file_path)

            if "operations" not in data:
                continue

            for operation in data["operations"]:
                module_name, class_name = operation

                # Import the operation class.
                cls = _get_class(module_name, class_name)

                if cls is None:
                    logger.warning(
                        "Could not load {} from {}".format(class_name, module_name)
                    )

                    continue

                else:
                    logger.debug(
                        "Registering {} ({})".format(class_name, module_name)
                    )

                # Add an instance of it to our operations list.
                self.operations.append(cls(self))
def filterCameraSegment():
    """Modify properties for a camera motion segment.

    Called just prior to the ray_end statement locking the settings for a
    camera motion segment.

    """
    logger.debug("filterCameraSegment")

    PYFILTER_MANAGER.run_operations_for_stage("filterCameraSegment")
def filterFog():
    """Modify fog related properties.

    Called just prior to the ray_end statement which locks off the settings for
    a fog object. The function can query fog: settings and possibly alter them.

    """
    logger.debug("filterFog ({})".format(mantra.property("object:name")[0]))

    PYFILTER_MANAGER.run_operations_for_stage("filterFog")
def filterFog():
    """Modify fog related properties.

    Called just prior to the ray_end statement which locks off the settings for
    a fog object. The function can query fog: settings and possibly alter them.

    """
    logger.debug("filterFog ({})".format(mantra.property("object:name")[0]))

    PYFILTER_MANAGER.run_operations_for_stage("filterFog")
def filterCameraSegment():
    """Modify properties for a camera motion segment.

    Called just prior to the ray_end statement locking the settings for a
    camera motion segment.

    """
    logger.debug("filterCameraSegment")

    PYFILTER_MANAGER.run_operations_for_stage("filterCameraSegment")
def filterOutputAssets(assets):
    """Filter assets generated by Mantra.

    Called after the render completes, and is passed a list of assets generated
    during the render.

    """
    logger.debug("filterOutputAssets")

    PYFILTER_MANAGER.run_operations_for_stage("filterOutputAssets")
def filterOutputAssets(assets):
    """Filter assets generated by Mantra.

    Called after the render completes, and is passed a list of assets generated
    during the render.

    """
    logger.debug("filterOutputAssets")

    PYFILTER_MANAGER.run_operations_for_stage("filterOutputAssets")
def filterPlane():
    """Change query and modify image plane properties."""
    variable = mantra.property("plane:variable")[0]
    channel = mantra.property("plane:channel")[0]

    if variable == channel or channel == "":
        logger.debug("filterPlane ({})".format(variable))
    else:
        logger.debug("filterPlane ({} -> {})".format(variable, channel))

    PYFILTER_MANAGER.run_operations_for_stage("filterPlane")
def filterRender():
    """Query render related properties.

    Called just before the ray_raytrace command.  It's not possible to change
    any properties at this time in the IFD processing.  However, for
    statistics or validation, it might be useful to have this method available.

    """
    logger.debug("filterRender")

    PYFILTER_MANAGER.run_operations_for_stage("filterRender")
Exemple #11
0
def filterGeometry():
    """Modify geometry related properties.

    Called just prior to the ray_end statement which locks off a geometry
    object. This allows the program to query geometry: settings and possibly
    alter them.

    """
    logger.debug("filterGeometry")

    PYFILTER_MANAGER.run_operations_for_stage("filterGeometry")
def filterPlane():
    """Change query and modify image plane properties."""
    variable = mantra.property("plane:variable")[0]
    channel = mantra.property("plane:channel")[0]

    if variable == channel or channel == "":
        logger.debug("filterPlane ({})".format(variable))
    else:
        logger.debug("filterPlane ({} -> {})".format(variable, channel))

    PYFILTER_MANAGER.run_operations_for_stage("filterPlane")
def filterGeometry():
    """Modify geometry related properties.

    Called just prior to the ray_end statement which locks off a geometry
    object. This allows the program to query geometry: settings and possibly
    alter them.

    """
    logger.debug("filterGeometry")

    PYFILTER_MANAGER.run_operations_for_stage("filterGeometry")
Exemple #14
0
def filterMaterial():
    """Modify material related properties.

    Mantra has material blocks which can be applied on a per-primitive basis.
    This function is called before a material is locked off. The function can
    add or change properties on the material.

    """
    logger.debug("filterMaterial")

    PYFILTER_MANAGER.run_operations_for_stage("filterMaterial")
Exemple #15
0
def filterRender():
    """Query render related properties.

    Called just before the ray_raytrace command.  It's not possible to change
    any properties at this time in the IFD processing.  However, for
    statistics or validation, it might be useful to have this method available.

    """
    logger.debug("filterRender")

    PYFILTER_MANAGER.run_operations_for_stage("filterRender")
def filterMaterial():
    """Modify material related properties.

    Mantra has material blocks which can be applied on a per-primitive basis.
    This function is called before a material is locked off. The function can
    add or change properties on the material.

    """
    logger.debug("filterMaterial")

    PYFILTER_MANAGER.run_operations_for_stage("filterMaterial")
Exemple #17
0
        def wrapper(*args, **kwargs):
            func_name = func.__name__
            class_name = args[0].__class__.__name__

            msg = "{}.{}()".format(class_name, func_name)

            if isinstance(method_or_name, str):
                import mantra

                msg = "{} ({})".format(msg, mantra.property(method_or_name)[0])

            logger.debug(msg)

            func(*args, **kwargs)
    def load_from_file(self, file_path):
        """Load properties from a file.

        :param file_path: A file containing json property data.
        :type file_path: str
        :return:

        """
        logger.debug("Reading properties from {}".format(file_path))

        # Load json data from the file.
        with open(file_path) as f:
            data = json.load(f)

        self._load_from_data(data)
def filterCamera():
    """Modify image related properties.

    Called just before the global properties are locked off for the render.
    This is usually prior to the declaration of any objects in the IFD.  If you
    change global properties after this, they probably will have no effect.

    Since mantra calls this function before any lights or instances are
    declared, you can set default light or instance properties here.  Mantra
    will apply any Instance/Light properties you set here to any objects which
    don't declare the property explicitly.

    """
    logger.debug("filterCamera")

    PYFILTER_MANAGER.run_operations_for_stage("filterCamera")
Exemple #20
0
def filterCamera():
    """Modify image related properties.

    Called just before the global properties are locked off for the render.
    This is usually prior to the declaration of any objects in the IFD.  If you
    change global properties after this, they probably will have no effect.

    Since mantra calls this function before any lights or instances are
    declared, you can set default light or instance properties here.  Mantra
    will apply any Instance/Light properties you set here to any objects which
    don't declare the property explicitly.

    """
    logger.debug("filterCamera")

    PYFILTER_MANAGER.run_operations_for_stage("filterCamera")
        def wrapper(*args, **kwargs):
            func_name = func.__name__
            class_name = args[0].__class__.__name__

            msg = "{}.{}()".format(class_name, func_name)

            if isinstance(method_or_name, str):
                import mantra

                msg = "{} ({})".format(
                    msg,
                    mantra.property(method_or_name)[0]
                )

            logger.debug(msg)

            func(*args, **kwargs)
Exemple #22
0
def _find_operation_files():
    """Find any operation loading files.

    :return: Any found operations files.
    :rtype: tuple(str)

    """
    import hou

    # Look for files containing a list of operations.
    try:
        files = hou.findFiles("pyfilter/operations.json")

    # If no files could be found then abort.
    except hou.OperationFailed:
        logger.debug("Could not find any operations to load")
        files = ()

    return files
def _find_operation_files():
    """Find any operation loading files.

    :return: Any found operations files.
    :rtype: tuple(str)

    """
    import hou

    # Look for files containing a list of operations.
    try:
        files = hou.findFiles("pyfilter/operations.json")

    # If no files could be found then abort.
    except hou.OperationFailed:
        logger.debug("Could not find any operations to load")
        files = ()

    return files
    def filterCamera(self):
        """Apply camera properties.

        :return:

        """
        render_type = get_property("renderer:rendertype")

        if not self.all_passes and render_type != "beauty":
            logger.warning("Not a beauty render, skipping deepresolver")
            return

        if self.disable_deep_image:
            logger.info("Disabling deep resolver")
            set_property("image:deepresolver", [])

        else:
            # Look for existing args.
            deep_args = get_property("image:deepresolver")

            # If deep rendering is not enabled the args will be empty.
            if not deep_args:
                # If a resolver type and filename was passed then we will create
                # args for the resolver type to enable deep output.
                if self.resolver and self.filename:
                    deep_args = [self.resolver]

                # Log an error and abort.
                else:
                    logger.error("Cannot set deepresolver: deep output is not enabled")

                    return

            # Modify the args to include any passed along options.
            self._modify_deep_args(deep_args)

            logger.debug(
                "Setting 'image:deepresolver': {}".format(" ".join([str(arg) for arg in deep_args]))
            )

            set_property("image:deepresolver", deep_args)
Exemple #25
0
    def filterCamera(self):
        """Apply camera properties.

        :return:

        """
        render_type = get_property("renderer:rendertype")

        if not self.all_passes and render_type != "beauty":
            logger.warning("Not a beauty render, skipping deepresolver")
            return

        if self.disable_deep_image:
            logger.info("Disabling deep resolver")
            set_property("image:deepresolver", [])

        else:
            # Look for existing args.
            deep_args = get_property("image:deepresolver")

            # If deep rendering is not enabled the args will be empty.
            if not deep_args:
                # If a resolver type and filename was passed then we will create
                # args for the resolver type to enable deep output.
                if self.resolver and self.filename:
                    deep_args = [self.resolver]

                # Log an error and abort.
                else:
                    logger.error(
                        "Cannot set deepresolver: deep output is not enabled")

                    return

            # Modify the args to include any passed along options.
            self._modify_deep_args(deep_args)

            logger.debug("Setting 'image:deepresolver': {}".format(" ".join(
                [str(arg) for arg in deep_args])))

            set_property("image:deepresolver", deep_args)
    def set_property(self):
        """Set the property to the value.

        :return:

        """
        import hou

        # Is this property being applied to a specific render type.
        if self.rendertype is not None:
            # Get the rendertype for the current pass.
            rendertype = get_property("renderer:rendertype")

            # If the type pattern doesn't match, abort.
            if not hou.patternMatch(self.rendertype, rendertype):
                return

        logger.debug("Setting property '{}' to {}".format(
            self.name, self.value))

        # Update the property value.
        set_property(self.name, self.value)
def filterQuit():
    """Perform actions just before Mantra quits."""
    logger.debug("filterQuit")

    PYFILTER_MANAGER.run_operations_for_stage("filterQuit")
def filterEndRender():
    """Perform actions just after the image has been rendered."""
    logger.debug("filterEndRender")

    PYFILTER_MANAGER.run_operations_for_stage("filterEndRender")
Exemple #29
0
def filterEndRender():
    """Perform actions just after the image has been rendered."""
    logger.debug("filterEndRender")

    PYFILTER_MANAGER.run_operations_for_stage("filterEndRender")
Exemple #30
0
def filterQuit():
    """Perform actions just before Mantra quits."""
    logger.debug("filterQuit")

    PYFILTER_MANAGER.run_operations_for_stage("filterQuit")