generated from stilobique/BlenderTemplate
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9758304066 | |||
| 61e3bcaaf3 | |||
| 7418be4196 | |||
| 4f539912eb |
@@ -5,6 +5,7 @@ from .operators.outline import ConfigBlendScene
|
|||||||
from .operators.exports import ExportForFange
|
from .operators.exports import ExportForFange
|
||||||
from .operators.misc import MakeBasicCollision
|
from .operators.misc import MakeBasicCollision
|
||||||
from .preference import GRAOU_AddonPreference
|
from .preference import GRAOU_AddonPreference
|
||||||
|
from .properties.main import FangeProperties
|
||||||
|
|
||||||
bl_info = {
|
bl_info = {
|
||||||
'name': 'Fange Pipeline',
|
'name': 'Fange Pipeline',
|
||||||
@@ -24,7 +25,7 @@ modules_class = [
|
|||||||
# UI
|
# UI
|
||||||
GRAOU_PT_panel,
|
GRAOU_PT_panel,
|
||||||
# Preference
|
# Preference
|
||||||
GRAOU_AddonPreference
|
GRAOU_AddonPreference, FangeProperties
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -32,11 +33,15 @@ def register():
|
|||||||
for cls in modules_class:
|
for cls in modules_class:
|
||||||
bpy.utils.register_class(cls)
|
bpy.utils.register_class(cls)
|
||||||
|
|
||||||
|
bpy.types.Scene.graou_props = bpy.props.PointerProperty(type=FangeProperties)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
for cls in reversed(modules_class):
|
for cls in reversed(modules_class):
|
||||||
bpy.utils.unregister_class(cls)
|
bpy.utils.unregister_class(cls)
|
||||||
|
|
||||||
|
del bpy.types.Scene.graou_props
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
register()
|
register()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
from ..models import FangeProject
|
from ..properties.models import FangeProject
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
@@ -44,14 +44,20 @@ class ExportForFange(bpy.types.Operator):
|
|||||||
print(f'\tLook "{ob.name}", his type are "{type(ob.data)}"')
|
print(f'\tLook "{ob.name}", his type are "{type(ob.data)}"')
|
||||||
# TODO Support another type object, not only SM/SK
|
# TODO Support another type object, not only SM/SK
|
||||||
if ob.type == 'MESH' or 'EMPTY':
|
if ob.type == 'MESH' or 'EMPTY':
|
||||||
|
print(f'[Pipeline] Check ob {ob.name} and is type {type(ob)}')
|
||||||
ob.select_set(True)
|
ob.select_set(True)
|
||||||
|
|
||||||
abs_export = self.category.joinpath(self.asset, "Meshes")
|
abs_export = self.category.joinpath(self.asset, "Meshes")
|
||||||
if not abs_export.exists():
|
if not abs_export.exists():
|
||||||
abs_export.mkdir(parents=True)
|
abs_export.mkdir(parents=True)
|
||||||
|
|
||||||
# TODO Use a preset system
|
if coll.name != 'Socket':
|
||||||
bpy.ops.export_scene.fbx(filepath=abs_export.joinpath(f"SM_{coll.name}.fbx").as_posix(),
|
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_selection=True,
|
||||||
use_visible=False,
|
use_visible=False,
|
||||||
use_active_collection=False,
|
use_active_collection=False,
|
||||||
|
|||||||
@@ -1,16 +1,31 @@
|
|||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
from ..models import Outline
|
from ..properties.models import Outline
|
||||||
|
|
||||||
|
|
||||||
class ConfigBlendScene(bpy.types.Operator):
|
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_idname = 'graou.build_scene'
|
||||||
bl_label = 'Config or update the outline'
|
bl_label = 'Config or update the outline'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._outline = Outline()
|
self._outline = Outline()
|
||||||
|
|
||||||
|
# Main property
|
||||||
|
self._settings = bpy.context.scene.graou_props
|
||||||
|
self._socket = self._settings.socket_collection
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
for key, value in self._outline.collections.items():
|
for key, value in self._outline.collections.items():
|
||||||
collection = bpy.data.collections.get(key)
|
collection = bpy.data.collections.get(key)
|
||||||
@@ -24,4 +39,52 @@ class ConfigBlendScene(bpy.types.Operator):
|
|||||||
if collection.color_tag is not value.color:
|
if collection.color_tag is not value.color:
|
||||||
collection.color_tag = 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'}
|
return {'FINISHED'}
|
||||||
|
|||||||
@@ -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')
|
'Game Object': Collection(name='Game Object', color='COLOR_05')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self._socket = Collection(name='Socket', color='NONE')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def collections(self) -> [str]:
|
def collections(self) -> [str]:
|
||||||
"""Returns all collections in a dict"""
|
"""Returns all collections in a dict"""
|
||||||
return self._collections
|
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
@@ -11,19 +11,19 @@ class GRAOU_PT_panel(bpy.types.Panel):
|
|||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
layout.use_property_split = True
|
col = layout.column(align=True)
|
||||||
layout.use_property_decorate = False
|
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)
|
layout.separator()
|
||||||
row.label(text='Main Config:')
|
|
||||||
layout.operator('graou.build_scene', text='Init Scene', icon='OUTLINER')
|
|
||||||
|
|
||||||
row = layout.row(align=False)
|
layout.label(text='Asset:')
|
||||||
row.label(text='Asset:')
|
layout.operator('graou.make_collision', text='Generate collision', icon='MOD_PHYSICS')
|
||||||
layout.operator('graou.make_collision', text='Make all collision', icon='MOD_PHYSICS')
|
|
||||||
|
|
||||||
row = layout.row(align=True)
|
layout.separator()
|
||||||
row.label(text='Export scene:')
|
|
||||||
|
layout.label(text='Export scene:')
|
||||||
box = layout.box()
|
box = layout.box()
|
||||||
box.label(text='Sanity Check')
|
box.label(text='Sanity Check')
|
||||||
layout.operator('graou.building_export', text='Export all assets', icon='EXPORT')
|
layout.operator('graou.building_export', text='Export all assets', icon='EXPORT')
|
||||||
|
|||||||
Reference in New Issue
Block a user