How to use the translators.object.InstanceTranslator 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 / object.py View on Github external
def __init__(self, obj, master_translator, asset_handler):
        super(InstanceTranslator, self).__init__(obj, asset_handler)
        self.__master = master_translator
github appleseedhq / blenderseed / translators / group.py View on Github external
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:
                        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:
github appleseedhq / blenderseed / translators / dupli.py View on Github external
def __create_dupli_instances(self, obj, scene, settings):
        with DupliListBuilder(obj, scene, settings):
            for dupli in obj.dupli_list:
                # Create translators for dupli instances.
                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)