generated from stilobique/BlenderTemplate
Compare commits
8 Commits
a9564255da
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 88f5deeda0 | |||
| 4017020909 | |||
| 65ef02eb26 | |||
| 44b0781b94 | |||
| cfb7a8b514 | |||
| c61ba477ad | |||
| 83d321c69d | |||
| cd8301e29c |
@@ -1,10 +1,17 @@
|
||||
import bpy
|
||||
|
||||
from .ui.export import GRAOU_PT_panel
|
||||
from .operators.outline import ConfigBlendScene
|
||||
# UI and Interface
|
||||
from .ui.asset import GraouPanel_asset
|
||||
from .ui.export import GRAOU_PT_export
|
||||
from .ui.icon import GraouPanel_thumbnail
|
||||
from .ui.setup import GRAOU_PT_setup
|
||||
# All operators
|
||||
from .operators.exports import ExportForFange
|
||||
from .operators.outline import ConfigBlendScene
|
||||
from .operators.misc import MakeBasicCollision
|
||||
from .operators.lighting import ConfigLighting
|
||||
from .operators.thumbnails import ConfigRendering
|
||||
# Preferences and properties
|
||||
from .preference import GRAOU_AddonPreference
|
||||
from .properties.main import FangeProperties
|
||||
|
||||
@@ -22,9 +29,9 @@ bl_info = {
|
||||
|
||||
modules_class = [
|
||||
# Main operators property
|
||||
ExportForFange, MakeBasicCollision, ConfigBlendScene, ConfigLighting,
|
||||
# UI
|
||||
GRAOU_PT_panel,
|
||||
ExportForFange, MakeBasicCollision, ConfigBlendScene, ConfigLighting, ConfigRendering,
|
||||
# UI, the order are the way to select how show each panel
|
||||
GRAOU_PT_setup, GraouPanel_asset, GRAOU_PT_export, GraouPanel_thumbnail,
|
||||
# Preference
|
||||
GRAOU_AddonPreference, FangeProperties
|
||||
]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import bpy
|
||||
|
||||
from ..properties.models import FangeProject
|
||||
from pathlib import Path
|
||||
from ..utils import get_export_path, get_asset_name
|
||||
|
||||
|
||||
class ExportForFange(bpy.types.Operator):
|
||||
@@ -12,9 +11,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,34 +118,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)
|
||||
print(f'[Pipeline] Get blend file path "{abs_blend_path}"')
|
||||
print(f'[Pipeline] Convert to List "{abs_blend_path.parts}"')
|
||||
|
||||
if 'Buildings' in abs_blend_path.parts:
|
||||
print(f'[Pipeline] Export here "{self.path.buildings}"')
|
||||
return self.path.buildings
|
||||
|
||||
elif 'Pros' 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)
|
||||
|
||||
@@ -13,7 +13,27 @@ class ConfigLighting(bpy.types.Operator):
|
||||
self.clear_light_on_scene()
|
||||
|
||||
r = self.get_blend_resources_file()
|
||||
print(f'[Pipeline] Get file resource {r}')
|
||||
|
||||
world = bpy.data.worlds.get('WorldIconRendering')
|
||||
if not world:
|
||||
with bpy.data.libraries.load(r, link=True) as (data_from, data_to):
|
||||
data_to.worlds = data_from.worlds
|
||||
|
||||
world = bpy.data.worlds.get('WorldIconRendering')
|
||||
|
||||
context.scene.world = world
|
||||
|
||||
if not bpy.data.collections.get('Lighting'):
|
||||
print(f'[Pipeline] Need to import the lighting collection')
|
||||
with bpy.data.libraries.load(r, link=False) as (data_from, data_to):
|
||||
for collection in data_from.collections:
|
||||
print(f'[Pipeline] Collection can be import "{collection}"')
|
||||
if 'Lighting' in collection:
|
||||
print(f'[Pipeline] Append {collection}.')
|
||||
data_to.collections.append(collection)
|
||||
|
||||
print('[Pipeline] Link lighting collection with the scene collection')
|
||||
bpy.data.collections['Scene'].children.link(bpy.data.collections.get('Lighting'))
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
@@ -21,23 +41,15 @@ class ConfigLighting(bpy.types.Operator):
|
||||
def get_blend_resources_file():
|
||||
"""Get the blend file shared with the addon"""
|
||||
addon_folder = Path(bpy.utils.user_resource('SCRIPTS'))
|
||||
print(f'[Pipeline] Get addon folder "{addon_folder}"')
|
||||
addon_name = str(bpy.context.preferences.addons[__name__.split(".")[0]])
|
||||
print(f'[Pipeline] The addon name "{addon_name}"')
|
||||
addon_name = __name__.split(".")[0]
|
||||
|
||||
return addon_folder.joinpath("addons", addon_name, "resources").as_posix()
|
||||
|
||||
def get_world(self):
|
||||
pass
|
||||
|
||||
def get_light_collection(self):
|
||||
pass
|
||||
return addon_folder.joinpath("addons", addon_name, "resources", "Lighting.blend").as_posix()
|
||||
|
||||
def clear_light_on_scene(self):
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
|
||||
for ob in bpy.data.objects:
|
||||
if ob.type == 'LIGHT' and self.find_collection(ob):
|
||||
if ob.type == 'LIGHT' and not self.find_collection(ob):
|
||||
ob.select_set(True)
|
||||
bpy.ops.object.delete()
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
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()
|
||||
|
||||
bpy.ops.render.render(write_still=True, use_viewport=True)
|
||||
|
||||
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.image_settings.color_mode = 'RGBA'
|
||||
self.scene.render.filepath = self.filename_export.as_posix()
|
||||
|
||||
def set_camera_used(self):
|
||||
"""Find the best camera position"""
|
||||
# TODO
|
||||
pass
|
||||
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
from .main import GraouPanel
|
||||
|
||||
|
||||
class GraouPanel_asset(GraouPanel):
|
||||
bl_idname = 'GRAOU_PT_asset'
|
||||
bl_label = 'Generate Assets'
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.label(text='Asset:')
|
||||
layout.operator('graou.make_collision', text='Generate collision', icon='MOD_PHYSICS')
|
||||
@@ -1,45 +1,13 @@
|
||||
import bpy
|
||||
# import os
|
||||
|
||||
# from pathlib import Path
|
||||
#
|
||||
# preview_collection = {}
|
||||
# icon_sauropod_path = Path(os.path.dirname(os.path.abspath(__file__)), "icons")
|
||||
#
|
||||
# pcoll = bpy.utils.previews.new()
|
||||
#
|
||||
# for entry in os.scandir(icon_sauropod_path):
|
||||
# if entry.name.endswith(".png"):
|
||||
# name = os.path.splitext(entry.name)[0]
|
||||
# print(f'[Pipeline] Add icon "{name}"')
|
||||
# pcoll.load(name.upper(), entry.path, "IMAGE")
|
||||
from .main import GraouPanel
|
||||
|
||||
|
||||
class GRAOU_PT_panel(bpy.types.Panel):
|
||||
class GRAOU_PT_export(GraouPanel):
|
||||
bl_idname = 'GRAOU_PT_MAIN'
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
bl_label = 'Pipeline'
|
||||
bl_category = 'Graou Studio'
|
||||
bl_label = 'Export'
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
# layout.label(text='Graou Pipeline', icon_value=pcoll["GRAOU"].icon_id)
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text='Main Config:')
|
||||
col.operator('graou.build_scene', text='Init Scene', icon='OUTLINER')
|
||||
col.prop(context.scene.graou_props, 'socket_collection', text='Use socket', toggle=True)
|
||||
col.operator('graou.lighting', text='Set basic lighting', icon='OUTLINER_OB_LIGHT')
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.label(text='Asset:')
|
||||
layout.operator('graou.make_collision', text='Generate collision', icon='MOD_PHYSICS')
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.label(text='Export scene:')
|
||||
box = layout.box()
|
||||
box.label(text='Sanity Check')
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
from .main import GraouPanel
|
||||
|
||||
|
||||
class GraouPanel_thumbnail(GraouPanel):
|
||||
bl_idname = 'GRAOU_PT_thumbnail'
|
||||
bl_label = 'Thumbnail'
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.label(text='Thumbnail:')
|
||||
layout.operator('graou_config.rendering_thumbnail', text='Generate Thumbnail', icon='FILE_IMAGE')
|
||||
# TODO Add the thumbnail view
|
||||
@@ -0,0 +1,25 @@
|
||||
import bpy
|
||||
# import os
|
||||
|
||||
# from pathlib import Path
|
||||
#
|
||||
# preview_collection = {}
|
||||
# icon_sauropod_path = Path(os.path.dirname(os.path.abspath(__file__)), "icons")
|
||||
#
|
||||
# pcoll = bpy.utils.previews.new()
|
||||
#
|
||||
# for entry in os.scandir(icon_sauropod_path):
|
||||
# if entry.name.endswith(".png"):
|
||||
# name = os.path.splitext(entry.name)[0]
|
||||
# print(f'[Pipeline] Add icon "{name}"')
|
||||
# pcoll.load(name.upper(), entry.path, "IMAGE")
|
||||
|
||||
# layout.label(text='Graou Pipeline', icon_value=pcoll["GRAOU"].icon_id)
|
||||
|
||||
|
||||
class GraouPanel(bpy.types.Panel):
|
||||
bl_idname = 'GRAOU_PT_MAIN'
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
bl_label = 'Export'
|
||||
bl_category = 'Graou Studio'
|
||||
@@ -0,0 +1,15 @@
|
||||
from .main import GraouPanel
|
||||
|
||||
|
||||
class GRAOU_PT_setup(GraouPanel):
|
||||
bl_idname = 'GRAOU_PT_setup'
|
||||
bl_label = 'Setup Pipeline'
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text='Main Config:')
|
||||
col.operator('graou.build_scene', text='Init Scene', icon='OUTLINER')
|
||||
col.prop(context.scene.graou_props, 'socket_collection', text='Use socket', toggle=True)
|
||||
col.operator('graou.lighting', text='Set basic lighting', icon='OUTLINER_OB_LIGHT')
|
||||
+23
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user