diff --git a/Fange_Pipeline/operators/exports.py b/Fange_Pipeline/operators/exports.py index e2651f1..6d1dd8e 100644 --- a/Fange_Pipeline/operators/exports.py +++ b/Fange_Pipeline/operators/exports.py @@ -1,6 +1,7 @@ import bpy from ..properties.models import FangeProject +from ..utils import get_export_path, get_asset_name from pathlib import Path @@ -12,9 +13,8 @@ Requiert your blend file are write on your hard-drive.""" def __init__(self): self.coll_layout = bpy.data.collections.get('Placeholder') - self.path = FangeProject() - self.asset = self.get_asset_name() - self.category = self.get_asset_type() + self.asset = get_asset_name() + self.category = get_export_path() self.instance_type_dict = {} self.temp_copy = {} @@ -120,32 +120,6 @@ Requiert your blend file are write on your hard-drive.""" self.report({'INFO'}, 'Placeholder exported') return {'FINISHED'} - def get_asset_type(self) -> Path: - """Look the file path, to understand if the asset are a Character, Buildings or Props""" - abs_blend_path = Path(bpy.data.filepath) - - if 'Buildings' in abs_blend_path.parts: - print(f'[Pipeline] Export here "{self.path.buildings}"') - return self.path.buildings - - elif 'Props' in abs_blend_path.parts: - print(f'[Pipeline] Export here "{self.path.props}"') - return self.path.props - - elif 'Characters' in abs_blend_path.parts: - print(f'[Pipeline] Export here "{self.path.characters}"') - return self.path.characters - - else: - print(f'[Pipeline] Can\'t find asset category') - return Path() - - @staticmethod - def get_asset_name() -> str: - """From the .blend file, return the blend name.""" - abs_blend_path = Path(bpy.data.filepath) - return abs_blend_path.stem - def set_instance_type(self): for key, value in self.instance_type_dict.items(): ob = bpy.data.objects.get(key) diff --git a/Fange_Pipeline/operators/thumbnails.py b/Fange_Pipeline/operators/thumbnails.py index 3c9f655..701b1aa 100644 --- a/Fange_Pipeline/operators/thumbnails.py +++ b/Fange_Pipeline/operators/thumbnails.py @@ -1,5 +1,6 @@ import bpy +from ..utils import get_export_path, get_asset_name from pathlib import Path @@ -11,6 +12,10 @@ class ConfigRendering(bpy.types.Operator): 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() @@ -27,7 +32,8 @@ class ConfigRendering(bpy.types.Operator): def set_output_file(self): self.scene.render.resolution_x = self.scene.render.resolution_y = 512 - self.scene.render.filepath = Path() + 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""" diff --git a/Fange_Pipeline/ui/icon.py b/Fange_Pipeline/ui/icon.py index de0f2d2..996781a 100644 --- a/Fange_Pipeline/ui/icon.py +++ b/Fange_Pipeline/ui/icon.py @@ -10,3 +10,4 @@ class GraouPanel_thumbnail(GraouPanel): layout.label(text='Thumbnail:') layout.operator('graou_config.rendering_thumbnail', text='Generate Thumbnail', icon='FILE_IMAGE') + # TODO Add the thumbnail view diff --git a/Fange_Pipeline/utils.py b/Fange_Pipeline/utils.py index ab7300d..90b8531 100644 --- a/Fange_Pipeline/utils.py +++ b/Fange_Pipeline/utils.py @@ -1,5 +1,6 @@ import bpy +from .properties.models import FangeProject from pathlib import Path @@ -21,8 +22,25 @@ def get_export_preset(): print(f'[Pipeline] Preset folder not found') -def apply_mesh_and_join(): - """ - This function make a new mesh with all selected asset. - """ - pass +def get_export_path(): + """Look the file path, to understand if the asset are a Character, Buildings or Props""" + abs_blend_path = Path(bpy.data.filepath) + game_path = FangeProject() + + if 'Buildings' in abs_blend_path.parts: + return game_path.buildings + + elif 'Props' in abs_blend_path.parts: + return game_path.props + + elif 'Characters' in abs_blend_path.parts: + return game_path.characters + + else: + return Path() + + +def get_asset_name() -> str: + """From the .blend file, return the blend name.""" + abs_blend_path = Path(bpy.data.filepath) + return abs_blend_path.stem