STRP importing, Teancum's highsinger and xizor break implying adaptations needed for ZETools-exported MSHs
This commit is contained in:
@@ -6,7 +6,7 @@ from typing import List, Dict
|
||||
from copy import copy
|
||||
import bpy
|
||||
from mathutils import Vector
|
||||
from .msh_model import Model
|
||||
from .msh_model import Model, Animation
|
||||
from .msh_model_gather import gather_models
|
||||
from .msh_model_utilities import sort_by_parent, has_multiple_root_models, reparent_model_roots, get_model_world_matrix
|
||||
from .msh_model_triangle_strips import create_models_triangle_strips
|
||||
@@ -44,9 +44,11 @@ class Scene:
|
||||
materials: Dict[str, Material] = field(default_factory=dict)
|
||||
models: List[Model] = field(default_factory=list)
|
||||
|
||||
animation: Animation = None
|
||||
|
||||
skeleton: List[int] = field(default_factory=list)
|
||||
|
||||
def create_scene(generate_triangle_strips: bool, apply_modifiers: bool, export_target: str, skel_only: bool) -> Scene:
|
||||
def create_scene(generate_triangle_strips: bool, apply_modifiers: bool, export_target: str, skel_only: bool, export_anim: bool) -> Scene:
|
||||
""" Create a msh Scene from the active Blender scene. """
|
||||
|
||||
scene = Scene()
|
||||
@@ -55,7 +57,7 @@ def create_scene(generate_triangle_strips: bool, apply_modifiers: bool, export_t
|
||||
|
||||
scene.materials = gather_materials()
|
||||
|
||||
scene.models = gather_models(apply_modifiers=apply_modifiers, export_target=export_target, skeleton_only=skel_only)
|
||||
scene.models, armature_obj = gather_models(apply_modifiers=apply_modifiers, export_target=export_target, skeleton_only=skel_only)
|
||||
scene.models = sort_by_parent(scene.models)
|
||||
|
||||
if generate_triangle_strips:
|
||||
@@ -71,12 +73,17 @@ def create_scene(generate_triangle_strips: bool, apply_modifiers: bool, export_t
|
||||
|
||||
scene.materials = remove_unused_materials(scene.materials, scene.models)
|
||||
|
||||
#creates a dummy basepose if no Action is selected
|
||||
if "Armature" in bpy.context.scene.objects.keys():
|
||||
scene.anims = [extract_anim(bpy.context.scene.objects["Armature"])]
|
||||
|
||||
root = scene.models[0]
|
||||
|
||||
if export_anim:
|
||||
if armature_obj is not None:
|
||||
scene.animation = extract_anim(armature_obj, root.name)
|
||||
else:
|
||||
raise Exception("Export Error: Could not find an armature object from which to export an animation!")
|
||||
|
||||
if skel_only and root.model_type == ModelType.NULL:
|
||||
# For ZenAsset
|
||||
inject_dummy_data(root)
|
||||
|
||||
return scene
|
||||
|
||||
Reference in New Issue
Block a user