How to use the translators.translator.Translator function in translators

To help you get started, we’ve selected a few translators examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appleseedhq / blenderseed / translators / lamps.py View on Github external
'color_space': as_lamp_data.radiance_multiplier_tex_color_space}, [])
            self.__radiance_mult_tex_inst = asr.TextureInstance(lamp.name + "_radiance_mult_tex_inst",
                                                                {'addressing_mode': 'wrap',
                                                                 'filtering_mode': 'bilinear'},
                                                                lamp.name + "_radiance_mult_tex",
                                                                asr.Transformf(asr.Matrix4f.identity()))

    def _reset(self, lamp):
        super(LampTranslator, self)._reset(lamp)
        self.__radiance_tex = None
        self.__radiance_tex_inst = None
        self.__radiance_mult_tex = None
        self.__radiance_mult_tex_inst = None


class AreaLampTranslator(Translator):

    #
    # Constructor.
    #

    def __init__(self, lamp, export_mode, asset_handler):
        super(AreaLampTranslator, self).__init__(lamp, asset_handler)
        self.__export_mode = export_mode
        self.__lamp_shader_group = None
        self.__edf_mat = None
        self.__has_shadergroup = False

    #
    # Properties.
    #
github appleseedhq / blenderseed / translators / shader_groups.py View on Github external
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

from .translator import Translator

import appleseed as asr
import bpy

from ..util import image_extensions


class ShaderGroupTranslator(Translator):

    def __init__(self, scene, node_group):
        self.__node_group = node_group
        self.__shaders = node_group.nodes
        self.__shader_list = None
        self.__scene = scene

    def create_entities(self):
        self.__shader_group = asr.ShaderGroup(self.__node_group.name)

        surface_shader = None
        for shader in self.__shaders:
            if shader.node_type == 'osl_surface':
                surface_shader = shader
                self.__shader_list = surface_shader.traverse_tree()
github appleseedhq / blenderseed / translators / object.py View on Github external
# THE SOFTWARE.
#

import appleseed as asr
import math
import mathutils
import os

from .assethandlers import AssetType
from .translator import Translator, ProjectExportMode, ObjectKey
from ..logger import get_logger

logger = get_logger()


class ObjectTranslator(Translator):

    #
    # Constructor.
    #

    def __init__(self, obj, asset_handler):
        super(ObjectTranslator, self).__init__(obj, asset_handler)

        self._xform_seq = asr.TransformSequence()
        self._num_instances = 1

    #
    # Properties.
    #

    @property
github appleseedhq / blenderseed / translators / objects / archive_assembly.py View on Github external
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

import appleseed as asr
from ..assethandlers import AssetType
from ..translator import Translator
from ...logger import get_logger

logger = get_logger()


class ArchiveAssemblyTranslator(Translator):
    def __init__(self, archive_obj, asset_handler):
        logger.debug(f"appleseed: Creating archive asset translator for {archive_obj.name_full}")
        super().__init__(archive_obj, asset_handler)

        self.__instance_lib = asr.BlTransformLibrary()

        self.__ass = None
        self.__ass_name = None

        self._bl_obj.appleseed.obj_name = self._bl_obj.name_full

    @property
    def orig_name(self):
        return self._bl_obj.appleseed.obj_name

    @property
github appleseedhq / blenderseed / translators / objects / mesh.py View on Github external
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

import os

import appleseed as asr
from ..translator import Translator
from ..utilites import ProjectExportMode
from ...logger import get_logger
from ...utils.util import is_object_deforming, Timer

logger = get_logger()


class MeshTranslator(Translator):
    def __init__(self, bl_obj, export_mode, asset_handler):
        logger.debug(f"appleseed: Creating mesh translator for {bl_obj.name_full}")
        super().__init__(bl_obj, asset_handler)

        self.__export_mode = export_mode

        self.__mesh_params = str()

        self.__instance_lib = asr.BlTransformLibrary()

        self.__as_mesh = None
        self.__as_mesh_inst = None
        self.__as_mesh_inst_params = dict()
        self.__front_materials = dict()
        self.__back_materials = dict()
github appleseedhq / blenderseed / translators / dupli.py View on Github external
even in the presence of exceptions.
    '''

    def __init__(self, obj, scene, settings):
        self.__obj = obj
        self.__scene = scene
        self.__settings = settings

    def __enter__(self):
        self.__obj.dupli_list_create(self.__scene, self.__settings)

    def __exit__(self, type, value, traceback):
        self.__obj.dupli_list_clear()


class DupliTranslator(Translator):

    #
    # Constructor.
    #

    def __init__(self, dupli, export_mode, asset_handler):
        super(DupliTranslator, self).__init__(dupli, asset_handler)

        self.__export_mode = export_mode
        self.__settings = 'VIEWPORT' if self.__export_mode == ProjectExportMode.INTERACTIVE_RENDER else 'RENDER'

        self.__object_translators = []
        self.__material_translators = {}
        self.__datablock_to_translator = {}

    #
github appleseedhq / blenderseed / translators / material.py View on Github external
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

import appleseed as asr

from .nodetree import NodeTreeTranslator
from .translator import Translator
from ..logger import get_logger

logger = get_logger()


class MaterialTranslator(Translator):

    def __init__(self, mat, asset_handler):
        logger.debug(f"appleseed: Creating material translator for {mat.name_full}")

        super().__init__(mat, asset_handler)

        self.__as_mat_params = dict()
        self.__as_mat = None
        self.__as_shader_params = dict()
        self.__as_shader = None

        self.__as_nodetree = None

        self._bl_obj.appleseed.obj_name = self._bl_obj.name_full

    @property
github appleseedhq / blenderseed / translators / lamps / lamp.py View on Github external
import os

import mathutils

import appleseed as asr
from ..assethandlers import AssetType
from ...logger import get_logger
from ..nodetree import NodeTreeTranslator
from ..textures import TextureTranslator
from ..translator import Translator
from ...utils.path_util import get_osl_search_paths

logger = get_logger()


class LampTranslator(Translator):
    def __init__(self, bl_lamp, asset_handler=None):
        logger.debug("Creating light translator for %s", bl_lamp.name_full)
        super().__init__(bl_lamp, asset_handler=asset_handler)

        self.__lamp_model = None
        self.__as_lamp_params = None
        self.__as_area_lamp = None

        self.__matrices = dict()
        self.__instances = dict()

        self._as_lamp_radiance = None

        self._as_area_lamp_material = None
        self._as_area_lamp_shadergroup = None
        self.__node_tree = None
github appleseedhq / blenderseed / translators / cameras / final.py View on Github external
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

import math

import appleseed as asr

from ..translator import Translator
from ...logger import get_logger
from ...utils import util

logger = get_logger()


class RenderCameraTranslator(Translator):

    def __init__(self, cam, asset_handler):
        logger.debug(f"appleseed: Creating final render camera translator for {cam.name_full}")
        super().__init__(cam, asset_handler)

        self.__as_camera = None

        self.__cam_model = None
        self.__as_cam_params = None

        self._bl_obj.appleseed.obj_name = self._bl_obj.name_full

    @property
    def bl_camera(self):
        return self._bl_obj
github appleseedhq / blenderseed / translators / nodetree.py View on Github external
import os

import bpy

import appleseed as asr
from .assethandlers import AssetType
from .cycles_shaders import cycles_nodes, cycles_parameter_mapping, parse_cycles_shader
from .translator import Translator
from ..properties.nodes import AppleseedOSLNode
from ..logger import get_logger
from ..utils.util import filter_params

logger = get_logger()


class NodeTreeTranslator(Translator):

    def __init__(self, node_tree, asset_handler, mat_name):
        logger.debug(f"appleseed: Creating node tree translator for {mat_name} node tree")

        super().__init__(node_tree, asset_handler)

        self.__mat_name = mat_name

        self.__as_shader_group = None

    @property
    def bl_nodes(self):
        return self._bl_obj.nodes

    def create_entities(self, depsgraph, engine=None):
        logger.debug(f"appleseed: Creating node tree entitiy for {self.__mat_name} node tree")