Update everything
This commit is contained in:
@@ -7,18 +7,19 @@ import glob
|
||||
import shutil
|
||||
from mathutils import Vector, Matrix
|
||||
from math import radians, pi
|
||||
if bpy.app.version[0] == 3:
|
||||
sys.path.insert(0, os.getcwd() + "/assets/blender/scripts/mixamo/3.6")
|
||||
if bpy.app.version[0] == 4:
|
||||
sys.path.insert(0, os.getcwd() + "/assets/blender/scripts/mixamo/4.3")
|
||||
sys.path.insert(0, os.getcwd() + "/assets/blender/scripts")
|
||||
from vrm import rename
|
||||
from mixamo import mixamo_rig
|
||||
if bpy.app.version[0] == 3:
|
||||
from mixamo import mixamo_rig
|
||||
from mixamo.lib.armature import *
|
||||
#from mixamo.mixamoroot import import_armature
|
||||
#from mixamo.import_mixamo_root_motion import import_mixamo_root_motion
|
||||
from settings import VRMDataFemale, VRMDataMale, VRMDataMaleBabyShape, basepath
|
||||
|
||||
|
||||
imports = [VRMDataFemale(), VRMDataMale(), VRMDataMaleBabyShape()]
|
||||
|
||||
|
||||
class mkrig:
|
||||
ik_arms = True
|
||||
ik_legs = True
|
||||
@@ -27,7 +28,6 @@ class mkrig:
|
||||
mixamo_rig.remove_temp_objects()
|
||||
mixamo_rig.clean_scene()
|
||||
def get_anim(filepath, root_bone_name="Root", hip_bone_name="mixamorig:Hips", remove_prefix=False, name_prefix="mixamorig:", insert_root=False, delete_armatures=False):
|
||||
# current_context = bpy.context.area.ui_type
|
||||
old_objs = set(bpy.context.scene.objects)
|
||||
try:
|
||||
import_armature(filepath, root_bone_name, hip_bone_name, remove_prefix, name_prefix, insert_root, delete_armatures)
|
||||
@@ -36,7 +36,6 @@ def get_anim(filepath, root_bone_name="Root", hip_bone_name="mixamorig:Hips", re
|
||||
deleteArmature(imported_objects)
|
||||
except Exception as e:
|
||||
log.error("[Mixamo Root] ERROR get_all_anims raised %s when processing %s" % (str(e), filepath))
|
||||
# bpy.context.area.ui_type = current_context
|
||||
bpy.context.scene.frame_start = 0
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
def create_root_bone(anim_obj):
|
||||
@@ -53,11 +52,6 @@ def hips_to_root(anim_obj):
|
||||
print(fc, fc.data_path, fc.array_index)
|
||||
if fc.array_index in [0, 2]:
|
||||
fc.data_path = fc.data_path.replace("mixamorig:Hips", "Root")
|
||||
# if fc.array_index == 2:
|
||||
# for kp in fc.keyframe_points:
|
||||
# kp.co.z = min(0, abs(kp.co.z))
|
||||
# hip_curves = [fc for fc in anim_obj.animation_data.action.fcurves if hip_bone_name in fc.data_path and fc.data_path.startswith('location')]
|
||||
# print(hip_curves)
|
||||
def hips_to_root(anim_obj):
|
||||
for fc in anim_obj.animation_data.action.fcurves:
|
||||
if "mixamorig:Hips" in fc.data_path:
|
||||
@@ -72,18 +66,12 @@ def hips_to_root2(anim_obj):
|
||||
print(fc, fc.data_path, fc.array_index)
|
||||
if fc.array_index in [0, 2]:
|
||||
data_path = fc.data_path[:]
|
||||
# fc.data_path = data_path.replace("Ctrl_Hips", "Ctrl_Master")
|
||||
fcr = anim_obj.animation_data.action.fcurves.new(data_path = data_path.replace("Ctrl_Hips", "Root"), index = fc.array_index)
|
||||
keys = [0] * (2 * len(fc.keyframe_points))
|
||||
fcr.keyframe_points.add(len(fc.keyframe_points))
|
||||
fc.keyframe_points.foreach_get("co", keys)
|
||||
fcr.keyframe_points.foreach_set("co", keys)
|
||||
print("ROOT")
|
||||
# fc.data_path = data_path.replace("Ctrl_Hips", "Root")
|
||||
# for fcr in anim_obj.animation_data.action.fcurves:
|
||||
# if "Root" in fcr.data_path:
|
||||
# fcr.array_index = fc.array_index
|
||||
# print("ROOT")
|
||||
|
||||
for imp in imports:
|
||||
bpy.ops.wm.read_homefile(use_empty=True)
|
||||
@@ -126,8 +114,6 @@ for imp in imports:
|
||||
print("Load BVH..." + anim_path)
|
||||
old_objs = set(bpy.context.scene.objects)
|
||||
bpy.ops.import_scene.fbx(filepath=anim_path, global_scale=imp.fbx_scale)
|
||||
#import_mixamo_root_motion(bpy.context, anim_path, True, True, False, False, False, 'COPY_HIPS', True, True, True)
|
||||
#get_anim(anim_path)
|
||||
imported_objects = set(bpy.context.scene.objects) - old_objs
|
||||
for anim_obj in imported_objects:
|
||||
if anim_obj == main_armature:
|
||||
@@ -136,8 +122,6 @@ for imp in imports:
|
||||
continue
|
||||
if main_armature == anim_obj or anim_obj.type != "ARMATURE":
|
||||
continue
|
||||
# create_root_bone(anim_obj)
|
||||
# hips_to_root(anim_obj)
|
||||
if anim_obj.animation_data == None:
|
||||
print("Bad object: " + anim_obj.name + " " + anim_obj.type)
|
||||
bpy.data.objects.remove(anim_obj)
|
||||
@@ -163,23 +147,6 @@ for imp in imports:
|
||||
for anim_obj in imported_objects:
|
||||
bpy.data.objects.remove(anim_obj)
|
||||
|
||||
# bpy.ops.import_scene.fbx(filepath=anim_path,
|
||||
# directory='', filter_glob='*.fbx',
|
||||
# files=None, ui_tab='MAIN',
|
||||
# use_manual_orientation=False,
|
||||
# global_scale=1.0, bake_space_transform=False,
|
||||
# use_custom_normals=True, colors_type='SRGB',
|
||||
# use_image_search=True, use_alpha_decals=False,
|
||||
# decal_offset=0.0, use_anim=True, anim_offset=1.0,
|
||||
# use_subsurf=False, use_custom_props=True,
|
||||
# use_custom_props_enum_as_string=True,
|
||||
# ignore_leaf_bones=False, force_connect_children=False,
|
||||
# automatic_bone_orientation=False, primary_bone_axis='Y',
|
||||
# secondary_bone_axis='X', use_prepost_rot=True,
|
||||
# axis_forward='-Z', axis_up='Y')
|
||||
# bpy.context.object.name = anim
|
||||
# bpy.context.object.animation_data.action.name = anim
|
||||
# _zero_out(main_armature)
|
||||
main_armature.animation_data.action = bpy.data.actions.new(name="default")
|
||||
default_action = main_armature.animation_data.action
|
||||
bpy.context.view_layer.objects.active = main_armature
|
||||
|
||||
Reference in New Issue
Block a user