Rename the main folder

This commit is contained in:
2024-05-16 22:12:11 +02:00
parent 814e158eb5
commit 9cbe89e4b8
12 changed files with 10 additions and 0 deletions
+150
View File
@@ -0,0 +1,150 @@
import bpy
from ..properties.models import FangeProject
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.path = FangeProject()
self.asset = self.get_asset_name()
self.category = self.get_asset_type()
self.instance_type_dict = {}
@classmethod
def poll(cls, context):
col = bpy.data.collections.get('Placeholder')
if col is not None and bpy.data.is_saved:
return True
def execute(self, context):
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
if not bpy.data.is_saved:
self.report({'ERROR'}, 'Your blend file is not saved.')
return {'CANCELLED'}
if not self.category:
self.report({'ERROR'}, 'Can\'t find the asset category.')
return {'CANCELLED'}
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)
for ob in child.all_objects:
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)
if ob.type == 'EMPTY':
if ob.instance_type != 'NONE':
self.instance_type_dict[ob.name] = ob.instance_type
ob.instance_type = 'NONE'
abs_export = self.category.joinpath(self.asset, "Meshes")
if not abs_export.exists():
abs_export.mkdir(parents=True)
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,
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')
self.set_instance_type()
# for coll in coll_layout.children:
# print(f'[Pipeline] Check {coll}. Item type {type(coll)}')
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():
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)
ob.instance_type = value
self.instance_type_dict.clear()
+14
View File
@@ -0,0 +1,14 @@
import bpy
class MakeBasicCollision(bpy.types.Operator):
"""From selected mesh, make a collision object"""
bl_idname = 'graou.make_collision'
bl_label = 'Generate a collision from selected mesh'
@classmethod
def poll(cls, context):
return bpy.context.object
def execute(self, context):
return {'FINISHED'}
+90
View File
@@ -0,0 +1,90 @@
import bpy
from ..properties.models import Outline
class ConfigBlendScene(bpy.types.Operator):
"""
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)
# Make the collection if this item not exist
if collection is None:
collection = bpy.data.collections.new(value.name)
context.scene.collection.children.link(collection)
# Check if the color are correctly setup, if not update-it
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'}