Compare commits

...

4 Commits

Author SHA1 Message Date
stilobique 9758304066 Update the outline operators.
Make a setup to generate the socket collection
2024-05-14 00:04:10 +02:00
stilobique 61e3bcaaf3 Tweak the UI 2024-05-13 23:17:33 +02:00
stilobique 7418be4196 Update socket config 2024-05-13 22:31:31 +02:00
stilobique 4f539912eb Refactoring model inside properties
Make a Property Group for blender
2024-05-12 18:15:19 +02:00
7 changed files with 118 additions and 16 deletions
+6 -1
View File
@@ -5,6 +5,7 @@ from .operators.outline import ConfigBlendScene
from .operators.exports import ExportForFange
from .operators.misc import MakeBasicCollision
from .preference import GRAOU_AddonPreference
from .properties.main import FangeProperties
bl_info = {
'name': 'Fange Pipeline',
@@ -24,7 +25,7 @@ modules_class = [
# UI
GRAOU_PT_panel,
# Preference
GRAOU_AddonPreference
GRAOU_AddonPreference, FangeProperties
]
@@ -32,11 +33,15 @@ def register():
for cls in modules_class:
bpy.utils.register_class(cls)
bpy.types.Scene.graou_props = bpy.props.PointerProperty(type=FangeProperties)
def unregister():
for cls in reversed(modules_class):
bpy.utils.unregister_class(cls)
del bpy.types.Scene.graou_props
if __name__ == "__main__":
register()
+9 -3
View File
@@ -1,6 +1,6 @@
import bpy
from ..models import FangeProject
from ..properties.models import FangeProject
from pathlib import Path
@@ -44,14 +44,20 @@ class ExportForFange(bpy.types.Operator):
print(f'\tLook "{ob.name}", his type are "{type(ob.data)}"')
# TODO Support another type object, not only SM/SK
if ob.type == 'MESH' or 'EMPTY':
print(f'[Pipeline] Check ob {ob.name} and is type {type(ob)}')
ob.select_set(True)
abs_export = self.category.joinpath(self.asset, "Meshes")
if not abs_export.exists():
abs_export.mkdir(parents=True)
# TODO Use a preset system
bpy.ops.export_scene.fbx(filepath=abs_export.joinpath(f"SM_{coll.name}.fbx").as_posix(),
if coll.name != 'Socket':
asset_name = f"SM_{coll.name}.fbx"
else:
asset_name = f"{coll.name}.fbx"
# TODO Use the preset system
bpy.ops.export_scene.fbx(filepath=abs_export.joinpath(asset_name).as_posix(),
use_selection=True,
use_visible=False,
use_active_collection=False,
+65 -2
View File
@@ -1,16 +1,31 @@
import bpy
from ..models import Outline
from ..properties.models import Outline
class ConfigBlendScene(bpy.types.Operator):
"""Init the opened blend scene"""
"""
This operator init a news blend file, or update it.
Prepare a set of collection (from the models in `properties/models/Outline`.
Hierarchy design give that:
- Placeholder
| ${StaticMesh}
| Socket (Optional)
- Icon
- Game Object
"""
bl_idname = 'graou.build_scene'
bl_label = 'Config or update the outline'
def __init__(self):
self._outline = Outline()
# Main property
self._settings = bpy.context.scene.graou_props
self._socket = self._settings.socket_collection
def execute(self, context):
for key, value in self._outline.collections.items():
collection = bpy.data.collections.get(key)
@@ -24,4 +39,52 @@ class ConfigBlendScene(bpy.types.Operator):
if collection.color_tag is not value.color:
collection.color_tag = value.color
# Check child collection color
if collection.children:
for child in collection.children:
if isinstance(child, bpy.types.Collection):
child.color_tag = value.color
# Set or update socket collection
if self._socket:
self.set_socket_collection()
else:
self.del_socket_collection()
return {'FINISHED'}
def set_socket_collection(self):
"""Make or update the socket collection"""
col_socket = bpy.data.collections.get(self._outline.socket.name)
col_placeholder = self._outline.get_placeholder_collection
col_game_object = self._outline.get_game_object_collection
if col_socket is None:
col_socket = bpy.data.collections.new(self._outline.socket.name)
# Attach to Placeholder and Game Icon if they collection exist
if col_placeholder.children.get(self._outline.socket.name) is None:
col_placeholder.children.link(col_socket)
if col_game_object.children.get(self._outline.socket.name) is None:
col_game_object.children.link(col_socket)
# Set the COLOR Tag
col_socket.color_tag = self._outline.socket.color
def del_socket_collection(self):
"""Remove the socket collection, however, if the collection doesn't exist, terminate the function"""
socket = bpy.data.collections.get(self._outline.socket.name)
if socket is not None:
bpy.data.collections.remove(socket)
class SetCollectionSocket(bpy.types.Operator):
"""Configure a/the collection with socket param"""
bl_idname = 'graou.collection.socket_setup'
bl_label = 'Set param to be socket functional'
def __init__(self):
self.socket = bpy.data.collections.get('Socket')
def execute(self, context):
return {'FINISHED'}
+10
View File
@@ -0,0 +1,10 @@
import bpy
class FangeProperties(bpy.types.PropertyGroup):
socket_collection: bpy.props.BoolProperty(
name='State Socket use',
description='Use the socket collection setup',
default=False
)
@@ -49,7 +49,25 @@ class Outline:
'Game Object': Collection(name='Game Object', color='COLOR_05')
}
self._socket = Collection(name='Socket', color='NONE')
@property
def collections(self) -> [str]:
"""Returns all collections in a dict"""
return self._collections
@property
def get_placeholder_collection(self):
return bpy.data.collections.get(self.collections['Placeholder'].name)
@property
def get_icon_collection(self):
return bpy.data.collections.get(self.collections['Icon'].name)
@property
def get_game_object_collection(self):
return bpy.data.collections.get(self.collections['Game Object'].name)
@property
def socket(self) -> Collection:
return self._socket
+10 -10
View File
@@ -11,19 +11,19 @@ class GRAOU_PT_panel(bpy.types.Panel):
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
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)
row = layout.row(align=False)
row.label(text='Main Config:')
layout.operator('graou.build_scene', text='Init Scene', icon='OUTLINER')
layout.separator()
row = layout.row(align=False)
row.label(text='Asset:')
layout.operator('graou.make_collision', text='Make all collision', icon='MOD_PHYSICS')
layout.label(text='Asset:')
layout.operator('graou.make_collision', text='Generate collision', icon='MOD_PHYSICS')
row = layout.row(align=True)
row.label(text='Export scene:')
layout.separator()
layout.label(text='Export scene:')
box = layout.box()
box.label(text='Sanity Check')
layout.operator('graou.building_export', text='Export all assets', icon='EXPORT')