import bpy

from ..utils import get_export_path, get_asset_name
from pathlib import Path


class ConfigRendering(bpy.types.Operator):
    """Setup camera and rendering config"""
    bl_idname = 'graou_config.rendering_thumbnail'
    bl_label = 'Setup the blend file to be ready'

    def __init__(self):
        self.scene = bpy.data.scenes['Scene']

        self.path_export = get_export_path()
        self.asset_name = get_asset_name()
        self.filename_export = Path(self.path_export, self.asset_name, f'TX_Icon{self.asset_name}.tga')

    def execute(self, context):
        self.set_camera_used()
        self.set_rendering_panel()
        self.set_output_file()

        return {'FINISHED'}

    def set_rendering_panel(self):
        self.scene.render.engine = 'BLENDER_EEVEE'
        self.scene.eevee.use_gtao = True
        self.scene.eevee.use_ssr = True
        self.scene.render.use_high_quality_normals = True
        self.scene.render.film_transparent = True

    def set_output_file(self):
        self.scene.render.resolution_x = self.scene.render.resolution_y = 512
        self.scene.render.image_settings.file_format = 'TARGA'
        self.scene.render.filepath = self.filename_export.as_posix()

    def set_camera_used(self):
        """Find the best camera position"""
        pass
