How to use the translators.mesh.MeshTranslator 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 / dupli.py View on Github external
if dupli.object.type == 'MESH':
                    obj_key = ObjectKey (dupli.object)
                    mesh_key = ObjectKey(dupli.object.data)

                    is_modified = dupli.object.is_modified(scene, 'RENDER')

                    if is_modified == False and mesh_key in self.__datablock_to_translator:
                        logger.debug("Creating instance translator for object %s, master obj: %s", obj_key, mesh_key)

                        master_translator = self.__datablock_to_translator[mesh_key]
                        self.__object_translators.append(InstanceTranslator(dupli.object, master_translator, self.asset_handler))
                        master_translator.add_instance()
                    else:
                        logger.debug("Creating mesh translator for object %s", obj_key)

                        translator = MeshTranslator(dupli.object,
                                                    self.__export_mode,
                                                    self.asset_handler)

                        self.__object_translators.append(translator)

                        for slot in dupli.object.material_slots:
                            mat = slot.material
                            mat_key = ObjectKey(mat)

                            if mat_key not in self.__material_translators:
                                logger.debug("Creating material translator for material %s", mat_key)
                                mat_translator = MaterialTranslator(mat, self.asset_handler)
                                self.__material_translators[mat_key] = mat_translator
                                mat_translator.create_entities(scene)

                        if not is_modified:
github appleseedhq / blenderseed / translators / mesh.py View on Github external
def __init__(self, obj, export_mode, asset_handler):
        super(MeshTranslator, self).__init__(obj, asset_handler)

        self.__export_mode = export_mode
        if self.__export_mode == ProjectExportMode.PROJECT_EXPORT:
            self.__geom_dir = self.asset_handler.geometry_dir

        self.__mesh_filenames = []

        # Motion blur
        self.__key_index = 0
        self.__deforming = obj.appleseed.use_deformation_blur and is_object_deforming(obj)

        # Materials
        self.__front_materials = {}
        self.__back_materials = {}

        self.__alpha_tex = None
github appleseedhq / blenderseed / translators / group.py View on Github external
# Sources of duplicated objects are not shown in renders.
                logger.debug("Skipping dupli-source object %s", obj_key)
                continue

            elif obj.type in GroupTranslator.MESH_OBJECTS:
                mesh_key = ObjectKey(obj.data)

                if obj.is_duplicator:
                    logger.debug("Creating dupli translator for object %s", obj_key)
                    self._dupli_translators[obj_key] = DupliTranslator(obj, self.export_mode, self.asset_handler)
                    if obj.dupli_type == 'NONE':
                        for particle_sys in obj.particle_systems:
                            if particle_sys.settings.use_render_emitter:
                                logger.debug("Creating mesh translator for object %s", obj_key)

                                translator = MeshTranslator(obj, self.export_mode, self.asset_handler)
                                self._object_translators[obj_key] = translator

                                if not is_modified:
                                    logger.debug("Saving translator for object %s in instance map", obj_key)
                                    self._datablock_to_translator[mesh_key] = translator

                                self.__create_material_translators(obj)

                                break

                elif obj.appleseed.object_export != 'normal':
                    logger.debug("Creating archive translator for object %s", obj_key)
                    archive_path = obj.appleseed.archive_path
                    self._object_translators[obj_key] = ArchiveTranslator(obj, archive_path, self._asset_handler)
                else:
                    if len(obj.data.polygons) > 0:
github appleseedhq / blenderseed / translators / group.py View on Github external
archive_path = obj.appleseed.archive_path
                    self._object_translators[obj_key] = ArchiveTranslator(obj, archive_path, self._asset_handler)
                else:
                    if len(obj.data.polygons) > 0:
                        is_modified = obj.is_modified(scene, 'RENDER')

                        if is_modified == False and mesh_key in self._datablock_to_translator:
                            logger.debug("Creating instance translator for object %s, master obj: %s", obj_key, mesh_key)

                            master_translator = self._datablock_to_translator[mesh_key]
                            self._object_translators[obj_key] = InstanceTranslator(obj, master_translator, self.asset_handler)
                            master_translator.add_instance()
                        else:
                            logger.debug("Creating mesh translator for object %s", obj_key)

                            translator = MeshTranslator(obj, self.export_mode, self.asset_handler)
                            self._object_translators[obj_key] = translator

                            if not is_modified:
                                logger.debug("Saving translator for object %s in instance map", obj_key)
                                self._datablock_to_translator[mesh_key] = translator

                            self.__create_material_translators(obj)
                    else:
                        logger.info("Mesh %s has no polygons, skipping export", mesh_key)

            else:
                pass  # log here unknown object found...