Skeleton properties panel start
This commit is contained in:
parent
8a20c38132
commit
79543a1cd7
|
@ -60,6 +60,7 @@ from .msh_scene import create_scene
|
||||||
from .msh_scene_save import save_scene
|
from .msh_scene_save import save_scene
|
||||||
from .msh_scene_read import read_scene
|
from .msh_scene_read import read_scene
|
||||||
from .msh_material_properties import *
|
from .msh_material_properties import *
|
||||||
|
from .msh_skeleton_properties import *
|
||||||
from .msh_to_blend import *
|
from .msh_to_blend import *
|
||||||
|
|
||||||
|
|
||||||
|
@ -186,19 +187,30 @@ def menu_func_import(self, context):
|
||||||
def register():
|
def register():
|
||||||
bpy.utils.register_class(MaterialProperties)
|
bpy.utils.register_class(MaterialProperties)
|
||||||
bpy.utils.register_class(MaterialPropertiesPanel)
|
bpy.utils.register_class(MaterialPropertiesPanel)
|
||||||
|
|
||||||
|
bpy.utils.register_class(SkeletonProperties)
|
||||||
|
bpy.utils.register_class(SkeletonPropertiesPanel)
|
||||||
|
|
||||||
bpy.utils.register_class(ExportMSH)
|
bpy.utils.register_class(ExportMSH)
|
||||||
bpy.utils.register_class(ImportMSH)
|
bpy.utils.register_class(ImportMSH)
|
||||||
|
|
||||||
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
|
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
|
||||||
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
|
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
|
||||||
|
|
||||||
bpy.types.Material.swbf_msh = bpy.props.PointerProperty(type=MaterialProperties)
|
bpy.types.Material.swbf_msh = bpy.props.PointerProperty(type=MaterialProperties)
|
||||||
|
bpy.types.Armature.swbf_msh_skel = bpy.props.CollectionProperty(type=SkeletonProperties)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
bpy.utils.unregister_class(MaterialProperties)
|
bpy.utils.unregister_class(MaterialProperties)
|
||||||
bpy.utils.unregister_class(MaterialPropertiesPanel)
|
bpy.utils.unregister_class(MaterialPropertiesPanel)
|
||||||
|
|
||||||
|
bpy.utils.unregister_class(SkeletonProperties)
|
||||||
|
bpy.utils.unregister_class(SkeletonPropertiesPanel)
|
||||||
|
|
||||||
bpy.utils.unregister_class(ExportMSH)
|
bpy.utils.unregister_class(ExportMSH)
|
||||||
bpy.utils.unregister_class(ImportMSH)
|
bpy.utils.unregister_class(ImportMSH)
|
||||||
|
|
||||||
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
|
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
|
||||||
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
|
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
""" Contains Blender properties and UI for .msh materials. """
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
from bpy.props import StringProperty, BoolProperty, EnumProperty, FloatVectorProperty, IntProperty
|
||||||
|
from bpy.types import PropertyGroup
|
||||||
|
from .msh_material_ui_strings import *
|
||||||
|
from .msh_model import *
|
||||||
|
|
||||||
|
|
||||||
|
class SkeletonProperties(PropertyGroup):
|
||||||
|
name: StringProperty(name="Name", default="Bone Name")
|
||||||
|
parent: StringProperty(name="Parent", default="Bone Parent")
|
||||||
|
loc: FloatVectorProperty(name="Local Position", default=(0.0, 0.0, 0.0), subtype="XYZ", size=3)
|
||||||
|
rot: FloatVectorProperty(name="Local Rotation", default=(0.0, 0.0, 0.0, 0.0), subtype="QUATERNION", size=4)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class SkeletonPropertiesPanel(bpy.types.Panel):
|
||||||
|
""" Creates a Panel in the Object properties window """
|
||||||
|
bl_label = "SWBF Skeleton Properties"
|
||||||
|
bl_idname = "SKELETON_PT_swbf_msh"
|
||||||
|
bl_space_type = 'PROPERTIES'
|
||||||
|
bl_region_type = 'WINDOW'
|
||||||
|
bl_context = "data"
|
||||||
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return context.object.type == 'ARMATURE'
|
||||||
|
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
if context.object is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
layout = self.layout
|
||||||
|
|
||||||
|
skel_props = context.object.data.swbf_msh_skel
|
||||||
|
|
||||||
|
for prop in skel_props:
|
||||||
|
layout.prop(prop, "name")
|
||||||
|
layout.prop(prop, "parent")
|
||||||
|
layout.prop(prop, "loc")
|
||||||
|
layout.prop(prop, "rot")
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
layout.prop(skel_props, "name")
|
||||||
|
layout.prop(skel_props, "parent")
|
||||||
|
layout.prop(skel_props, "loc")
|
||||||
|
layout.prop(skel_props, "rot")
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
#self.layout.label(text=context.object.swbf_msh_skel.yolo[1])
|
||||||
|
|
|
@ -12,6 +12,7 @@ from .msh_model import *
|
||||||
from .msh_model_utilities import *
|
from .msh_model_utilities import *
|
||||||
from .msh_utilities import *
|
from .msh_utilities import *
|
||||||
from .msh_model_gather import *
|
from .msh_model_gather import *
|
||||||
|
from .msh_skeleton_properties import *
|
||||||
from .crc import *
|
from .crc import *
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -126,6 +127,16 @@ def refined_skeleton_to_armature(refined_skeleton : List[Model], model_map):
|
||||||
bpy.context.view_layer.active_layer_collection.collection.objects.link(armature_obj)
|
bpy.context.view_layer.active_layer_collection.collection.objects.link(armature_obj)
|
||||||
armature_obj.select_set(True)
|
armature_obj.select_set(True)
|
||||||
|
|
||||||
|
preserved = armature_obj.data.swbf_msh_skel
|
||||||
|
for model in refined_skeleton:
|
||||||
|
loc,rot,_ = model_map[model.name].matrix_world.decompose()
|
||||||
|
print(str(loc))
|
||||||
|
entry = preserved.add()
|
||||||
|
entry.name = model.name
|
||||||
|
entry.loc = loc
|
||||||
|
entry.rot = rot
|
||||||
|
entry.parent = model.parent
|
||||||
|
|
||||||
bpy.context.view_layer.objects.active = armature_obj
|
bpy.context.view_layer.objects.active = armature_obj
|
||||||
bpy.ops.object.mode_set(mode='EDIT')
|
bpy.ops.object.mode_set(mode='EDIT')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue