generated from stilobique/BlenderTemplate
Make a very basic plugin setup
This commit is contained in:
@@ -1,103 +0,0 @@
|
|||||||
"""
|
|
||||||
Pipeline to export Placeholder inside Unity
|
|
||||||
|
|
||||||
About building setup:
|
|
||||||
- Get each placeholder collection, and export it has unique mesh with the `SM_` prefix
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
import bpy
|
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
# Init all data
|
|
||||||
coll_layout = bpy.data.collections.get('Placeholder')
|
|
||||||
output = Path("W:\\", "Graou Studio", "Game Projects", "Fange Prototype", "Assets", "Graph", "Buildings").resolve()
|
|
||||||
fbx_preset = 'sm-unity-building'
|
|
||||||
|
|
||||||
bpy.ops.object.select_all(action='DESELECT')
|
|
||||||
|
|
||||||
def get_export_preset():
|
|
||||||
fbx_preset_paths = bpy.utils.preset_paths(r"operator\export_scene.fbx")
|
|
||||||
fbx_preset = Path(fbx_preset_paths[0], "sm-unity-building.py")
|
|
||||||
|
|
||||||
if fbx_preset_paths:
|
|
||||||
print(f'[Pipeline] Get the preset path "{fbx_preset}"')
|
|
||||||
#select_preset = bpy.utils.preset_find(name=preset_name, preset_path=fbx_preset.as_posix())
|
|
||||||
#print(f'[Pipeline] Preset get {select_preset}')
|
|
||||||
|
|
||||||
return fbx_preset
|
|
||||||
|
|
||||||
else:
|
|
||||||
print(f'[Pipeline] Preset folder not found')
|
|
||||||
|
|
||||||
|
|
||||||
def apply_mesh_and_join():
|
|
||||||
"""
|
|
||||||
This function make a new mesh with all selected asset.
|
|
||||||
It's usefull to
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
if coll_layout:
|
|
||||||
if len(coll_layout.collection_children):
|
|
||||||
for coll in coll_layout.children:
|
|
||||||
print(f'[Pipeline] Update "{coll.name}" mesh')
|
|
||||||
child = bpy.data.collections.get(coll.name)
|
|
||||||
|
|
||||||
print(f'[Pipeline] Select all mesh inside the collection "{child.name}"')
|
|
||||||
for ob in child.all_objects:
|
|
||||||
print(f'\tLook "{ob.name}", his type are "{type(ob.data)}"')
|
|
||||||
if isinstance(ob.data, bpy.types.Mesh):
|
|
||||||
ob.select_set(True)
|
|
||||||
|
|
||||||
# Export this collection
|
|
||||||
abs_export = output.joinpath("Garden", "Meshes")
|
|
||||||
if not abs_export.exists():
|
|
||||||
abs_export.mkdir()
|
|
||||||
|
|
||||||
bpy.ops.export_scene.fbx(filepath=abs_export.joinpath(f"SM_{coll.name}.fbx").as_posix(),
|
|
||||||
use_selection=True,
|
|
||||||
use_visible=False,
|
|
||||||
use_active_collection=False,
|
|
||||||
global_scale=1.0,
|
|
||||||
apply_unit_scale=True,
|
|
||||||
apply_scale_options='FBX_SCALE_NONE',
|
|
||||||
use_space_transform=True,
|
|
||||||
bake_space_transform=True,
|
|
||||||
object_types={'MESH','EMPTY'},
|
|
||||||
use_mesh_modifiers=True,
|
|
||||||
use_mesh_modifiers_render=True,
|
|
||||||
mesh_smooth_type='OFF',
|
|
||||||
colors_type='SRGB',
|
|
||||||
prioritize_active_color=False,
|
|
||||||
use_subsurf=False,
|
|
||||||
use_mesh_edges=False,
|
|
||||||
use_tspace=False,
|
|
||||||
use_triangles=False,
|
|
||||||
use_custom_props=False,
|
|
||||||
add_leaf_bones=True,
|
|
||||||
primary_bone_axis='Y',
|
|
||||||
secondary_bone_axis='X',
|
|
||||||
use_armature_deform_only=False,
|
|
||||||
armature_nodetype = 'NULL',
|
|
||||||
bake_anim = False,
|
|
||||||
bake_anim_use_all_bones = True,
|
|
||||||
bake_anim_use_nla_strips = True,
|
|
||||||
bake_anim_use_all_actions = True,
|
|
||||||
bake_anim_force_startend_keying = True,
|
|
||||||
bake_anim_step = 1.0,
|
|
||||||
bake_anim_simplify_factor = 1.0,
|
|
||||||
path_mode = 'AUTO',
|
|
||||||
embed_textures = False,
|
|
||||||
batch_mode = 'OFF',
|
|
||||||
use_batch_own_dir = True,
|
|
||||||
axis_forward = 'X',
|
|
||||||
axis_up = 'Y'
|
|
||||||
)
|
|
||||||
print(f'[Pipeline] Export here "{abs_export}"')
|
|
||||||
bpy.ops.object.select_all(action='DESELECT')
|
|
||||||
|
|
||||||
#for coll in coll_layout.children:
|
|
||||||
# print(f'[Pipeline] Check {coll}. Item type {type(coll)}')
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
|
from .ui import GRAOU_PT_panel
|
||||||
|
from .ops import ExportForFange
|
||||||
|
|
||||||
bl_info = {
|
bl_info = {
|
||||||
'name': 'Fange Pipeline',
|
'name': 'Fange Pipeline',
|
||||||
'description': 'Pipeline about the game project "Fange"',
|
'description': 'Pipeline about the game project "Fange"',
|
||||||
@@ -14,6 +17,9 @@ bl_info = {
|
|||||||
|
|
||||||
modules_class = [
|
modules_class = [
|
||||||
# Main Property
|
# Main Property
|
||||||
|
ExportForFange,
|
||||||
|
# UI
|
||||||
|
GRAOU_PT_panel
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
import bpy
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
class ExportForFange(bpy.types.Operator):
|
||||||
|
"""Export a building for fange"""
|
||||||
|
bl_idname = "graou.building_export"
|
||||||
|
bl_label = "Easily export a building asset"
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.coll_layout = bpy.data.collections.get('Placeholder')
|
||||||
|
self.output = Path("W:\\", "Graou Studio", "Game Projects", "Fange Prototype", "Assets", "Graph", "Buildings")
|
||||||
|
self.fbx_preset = 'sm-unity-building'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
col = bpy.data.collections.get('Placeholder')
|
||||||
|
|
||||||
|
if col is not None:
|
||||||
|
return True
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
print(f'[Pipeline] Start to export the building props.')
|
||||||
|
|
||||||
|
if len(self.coll_layout.collection_children):
|
||||||
|
for coll in self.coll_layout.children:
|
||||||
|
print(f'[Pipeline] Update "{coll.name}" mesh')
|
||||||
|
child = bpy.data.collections.get(coll.name)
|
||||||
|
|
||||||
|
print(f'[Pipeline] Select all mesh inside the collection "{child.name}"')
|
||||||
|
for ob in child.all_objects:
|
||||||
|
print(f'\tLook "{ob.name}", his type are "{type(ob.data)}"')
|
||||||
|
if isinstance(ob.data, bpy.types.Mesh):
|
||||||
|
ob.select_set(True)
|
||||||
|
|
||||||
|
# TODO The plugin export only the garden building
|
||||||
|
abs_export = self.output.joinpath("Garden", "Meshes")
|
||||||
|
if not abs_export.exists():
|
||||||
|
abs_export.mkdir()
|
||||||
|
|
||||||
|
# TODO Use a preset system
|
||||||
|
bpy.ops.export_scene.fbx(filepath=abs_export.joinpath(f"SM_{coll.name}.fbx").as_posix(),
|
||||||
|
use_selection=True,
|
||||||
|
use_visible=False,
|
||||||
|
use_active_collection=False,
|
||||||
|
global_scale=1.0,
|
||||||
|
apply_unit_scale=True,
|
||||||
|
apply_scale_options='FBX_SCALE_NONE',
|
||||||
|
use_space_transform=True,
|
||||||
|
bake_space_transform=True,
|
||||||
|
object_types={'MESH', 'EMPTY'},
|
||||||
|
use_mesh_modifiers=True,
|
||||||
|
use_mesh_modifiers_render=True,
|
||||||
|
mesh_smooth_type='OFF',
|
||||||
|
colors_type='SRGB',
|
||||||
|
prioritize_active_color=False,
|
||||||
|
use_subsurf=False,
|
||||||
|
use_mesh_edges=False,
|
||||||
|
use_tspace=False,
|
||||||
|
use_triangles=False,
|
||||||
|
use_custom_props=False,
|
||||||
|
add_leaf_bones=True,
|
||||||
|
primary_bone_axis='Y',
|
||||||
|
secondary_bone_axis='X',
|
||||||
|
use_armature_deform_only=False,
|
||||||
|
armature_nodetype='NULL',
|
||||||
|
bake_anim=False,
|
||||||
|
bake_anim_use_all_bones=True,
|
||||||
|
bake_anim_use_nla_strips=True,
|
||||||
|
bake_anim_use_all_actions=True,
|
||||||
|
bake_anim_force_startend_keying=True,
|
||||||
|
bake_anim_step=1.0,
|
||||||
|
bake_anim_simplify_factor=1.0,
|
||||||
|
path_mode='AUTO',
|
||||||
|
embed_textures=False,
|
||||||
|
batch_mode='OFF',
|
||||||
|
use_batch_own_dir=True,
|
||||||
|
axis_forward='X',
|
||||||
|
axis_up='Y'
|
||||||
|
)
|
||||||
|
|
||||||
|
print(f'[Pipeline] Export here "{abs_export}"')
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
|
||||||
|
# for coll in coll_layout.children:
|
||||||
|
# print(f'[Pipeline] Check {coll}. Item type {type(coll)}')
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import bpy
|
||||||
|
|
||||||
|
|
||||||
|
class GRAOU_PT_panel(bpy.types.Panel):
|
||||||
|
bl_idname = 'GRAOU_PT_MAIN'
|
||||||
|
bl_space_type = 'VIEW_3D'
|
||||||
|
bl_region_type = 'UI'
|
||||||
|
bl_label = 'Pipeline'
|
||||||
|
bl_category = 'Graou Studio'
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
|
||||||
|
layout.use_property_split = True
|
||||||
|
layout.use_property_decorate = False
|
||||||
|
|
||||||
|
layout.label(text='Building', icon='WORLD_DATA')
|
||||||
|
layout.operator('graou.building_export')
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import bpy
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def get_export_preset():
|
||||||
|
"""
|
||||||
|
Select a FBX preset you want use.
|
||||||
|
"""
|
||||||
|
# TODO Subdir need to be exposed
|
||||||
|
fbx_preset_paths = bpy.utils.preset_paths(r"operator\export_scene.fbx")
|
||||||
|
# TODO Preset name need to be exposed
|
||||||
|
fbx_preset = Path(fbx_preset_paths[0], "sm-unity-building.py")
|
||||||
|
|
||||||
|
if fbx_preset_paths:
|
||||||
|
print(f'[Pipeline] Get the preset path "{fbx_preset}"')
|
||||||
|
|
||||||
|
return fbx_preset
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(f'[Pipeline] Preset folder not found')
|
||||||
|
|
||||||
|
|
||||||
|
def apply_mesh_and_join():
|
||||||
|
"""
|
||||||
|
This function make a new mesh with all selected asset.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
Reference in New Issue
Block a user