generated from stilobique/BlenderTemplate
Compare commits
4 Commits
ebbb80a2da
...
940bc14d77
| Author | SHA1 | Date | |
|---|---|---|---|
| 940bc14d77 | |||
| d20a7d2198 | |||
| e380e894d7 | |||
| 30531affba |
@@ -4,6 +4,7 @@ from .ui.export import GRAOU_PT_panel
|
|||||||
from .operators.outline import ConfigBlendScene
|
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 .operators.lighting import ConfigLighting
|
||||||
from .preference import GRAOU_AddonPreference
|
from .preference import GRAOU_AddonPreference
|
||||||
from .properties.main import FangeProperties
|
from .properties.main import FangeProperties
|
||||||
|
|
||||||
@@ -20,8 +21,8 @@ bl_info = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modules_class = [
|
modules_class = [
|
||||||
# Main Property
|
# Main operators property
|
||||||
ExportForFange, MakeBasicCollision, ConfigBlendScene,
|
ExportForFange, MakeBasicCollision, ConfigBlendScene, ConfigLighting,
|
||||||
# UI
|
# UI
|
||||||
GRAOU_PT_panel,
|
GRAOU_PT_panel,
|
||||||
# Preference
|
# Preference
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ from pathlib import Path
|
|||||||
|
|
||||||
|
|
||||||
class ExportForFange(bpy.types.Operator):
|
class ExportForFange(bpy.types.Operator):
|
||||||
"""Export a building for fange"""
|
"""Export a building for fange.
|
||||||
|
Requiert your blend file are write on your hard-drive."""
|
||||||
bl_idname = 'graou.building_export'
|
bl_idname = 'graou.building_export'
|
||||||
bl_label = 'Easily export a building asset'
|
bl_label = 'Easily export a building asset'
|
||||||
|
|
||||||
@@ -26,7 +27,6 @@ class ExportForFange(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
bpy.ops.object.select_all(action='DESELECT')
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
print(f'[Pipeline] Start to export the building props.')
|
|
||||||
|
|
||||||
# Make a check if the file are saved on the disk
|
# Make a check if the file are saved on the disk
|
||||||
if not bpy.data.is_saved:
|
if not bpy.data.is_saved:
|
||||||
@@ -37,80 +37,80 @@ class ExportForFange(bpy.types.Operator):
|
|||||||
self.report({'ERROR'}, 'Can\'t find the asset category.')
|
self.report({'ERROR'}, 'Can\'t find the asset category.')
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
if len(self.coll_layout.collection_children):
|
if not len(self.coll_layout.children):
|
||||||
for coll in self.coll_layout.children:
|
self.report({'WARNING'}, 'No children collection, nothing can be exported.')
|
||||||
print(f'[Pipeline] Update "{coll.name}" mesh')
|
return {'CANCELLED'}
|
||||||
child = bpy.data.collections.get(coll.name)
|
|
||||||
|
|
||||||
for ob in child.all_objects:
|
for coll in self.coll_layout.children:
|
||||||
print(f'\tLook "{ob.name}", his type are "{type(ob.data)}"')
|
print(f'[Pipeline] Update "{coll.name}" mesh')
|
||||||
# TODO Support another type object, not only SM/SK
|
child = bpy.data.collections.get(coll.name)
|
||||||
if ob.type == 'MESH' or 'EMPTY':
|
|
||||||
print(f'[Pipeline] Check ob {ob.name} and is type {type(ob)}')
|
|
||||||
ob.select_set(True)
|
|
||||||
|
|
||||||
if ob.type == 'EMPTY':
|
for ob in child.all_objects:
|
||||||
if ob.instance_type != 'NONE':
|
print(f'\tLook "{ob.name}", his type are "{type(ob.data)}"')
|
||||||
self.instance_type_dict[ob.name] = ob.instance_type
|
# TODO Support another type object, not only SM/SK
|
||||||
ob.instance_type = 'NONE'
|
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 ob.type == 'EMPTY':
|
||||||
if not abs_export.exists():
|
if ob.instance_type != 'NONE':
|
||||||
abs_export.mkdir(parents=True)
|
self.instance_type_dict[ob.name] = ob.instance_type
|
||||||
|
ob.instance_type = 'NONE'
|
||||||
|
|
||||||
if coll.name != 'Socket':
|
abs_export = self.category.joinpath(self.asset, "Meshes")
|
||||||
asset_name = f"SM_{coll.name}.fbx"
|
if not abs_export.exists():
|
||||||
else:
|
abs_export.mkdir(parents=True)
|
||||||
asset_name = f"{coll.name}.fbx"
|
|
||||||
|
|
||||||
# TODO Use the preset system
|
if coll.name != 'Socket':
|
||||||
bpy.ops.export_scene.fbx(filepath=abs_export.joinpath(asset_name).as_posix(),
|
asset_name = f"SM_{coll.name}.fbx"
|
||||||
use_selection=True,
|
else:
|
||||||
use_visible=False,
|
asset_name = f"{coll.name}.fbx"
|
||||||
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}"')
|
# TODO Use the preset system
|
||||||
bpy.ops.object.select_all(action='DESELECT')
|
bpy.ops.export_scene.fbx(filepath=abs_export.joinpath(asset_name).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'
|
||||||
|
)
|
||||||
|
|
||||||
self.set_instance_type()
|
print(f'[Pipeline] Export here "{abs_export}"')
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
|
||||||
# for coll in coll_layout.children:
|
self.set_instance_type()
|
||||||
# print(f'[Pipeline] Check {coll}. Item type {type(coll)}')
|
|
||||||
|
|
||||||
self.report({'INFO'}, 'Placeholder exported')
|
self.report({'INFO'}, 'Placeholder exported')
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
@@ -138,7 +138,8 @@ class ExportForFange(bpy.types.Operator):
|
|||||||
return Path()
|
return Path()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_asset_name():
|
def get_asset_name() -> str:
|
||||||
|
"""From the .blend file, return the blend name."""
|
||||||
abs_blend_path = Path(bpy.data.filepath)
|
abs_blend_path = Path(bpy.data.filepath)
|
||||||
return abs_blend_path.stem
|
return abs_blend_path.stem
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import bpy
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigLighting(bpy.types.Operator):
|
||||||
|
"""Add or conform a lighting build"""
|
||||||
|
bl_idname = 'graou.lighting'
|
||||||
|
bl_label = 'Config or update a lighting'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
print(f'[Pipeline] Start lighting operator')
|
||||||
|
|
||||||
|
return {'FINISHED'}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import bpy
|
import bpy
|
||||||
import os
|
# import os
|
||||||
|
|
||||||
# from pathlib import Path
|
# from pathlib import Path
|
||||||
#
|
#
|
||||||
@@ -31,6 +31,7 @@ class GRAOU_PT_panel(bpy.types.Panel):
|
|||||||
col.label(text='Main Config:')
|
col.label(text='Main Config:')
|
||||||
col.operator('graou.build_scene', text='Init Scene', icon='OUTLINER')
|
col.operator('graou.build_scene', text='Init Scene', icon='OUTLINER')
|
||||||
col.prop(context.scene.graou_props, 'socket_collection', text='Use socket', toggle=True)
|
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.separator()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user