jasongzy commited on
Commit
8080e63
ยท
1 Parent(s): b14d5c1

๐Ÿž fix: misc

Browse files
animation/a-pose.fbx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ff64cd4eb4bbef96951b9ca7f51400a9fa38d9bbd85bbea9955a87e4793a3c93
3
+ size 392780
animation/da-pose.fbx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c052c2a47927f9b83c99b37a216acce793e14d81c34fbe601e6b51a331139545
3
+ size 392844
apply_animation.py CHANGED
@@ -3,36 +3,23 @@ from glob import glob
3
 
4
  from tqdm import tqdm
5
 
6
- from utils import HiddenPrints, bpy, load_mixamo_anim, remove_all, reset, select_objs, update
7
-
8
  if __name__ == "__main__":
9
  character_dir = "./character_vroid_refined"
10
  animation_dir = "./animation"
11
  output_dir = "./animated_vroid"
12
  os.makedirs(output_dir, exist_ok=True)
13
 
14
- reset()
15
  character_list = sorted(glob(os.path.join(character_dir, "*.fbx")))
16
  assert character_list
17
  animation_list = sorted(glob(os.path.join(animation_dir, "*.fbx")))
18
  assert animation_list
 
19
  for char_file in tqdm(character_list, dynamic_ncols=True, desc="Character"):
20
  for anim_file in tqdm(animation_list, dynamic_ncols=True, leave=False, desc="Animation"):
21
- with HiddenPrints():
22
- remove_all()
23
- objs = load_mixamo_anim(char_file, anim_file, do_retarget=True, inplace=False)
24
- update()
25
- get_base_name = lambda s: os.path.splitext(os.path.basename(s))[0]
26
- output_filename = f"{get_base_name(char_file)}-{get_base_name(anim_file)}"
27
- # bpy.ops.wm.save_as_mainfile(filepath=os.path.join(output_dir, f"{output_filename}.blend"))
28
- select_objs(objs, deselect_first=True)
29
- bpy.ops.export_scene.fbx(
30
- filepath=os.path.join(output_dir, f"{output_filename}.fbx"),
31
- check_existing=False,
32
- use_selection=True,
33
- use_triangles=True,
34
- add_leaf_bones=False,
35
- bake_anim=True,
36
- # path_mode="COPY",
37
- # embed_textures=True,
38
- )
 
3
 
4
  from tqdm import tqdm
5
 
 
 
6
  if __name__ == "__main__":
7
  character_dir = "./character_vroid_refined"
8
  animation_dir = "./animation"
9
  output_dir = "./animated_vroid"
10
  os.makedirs(output_dir, exist_ok=True)
11
 
 
12
  character_list = sorted(glob(os.path.join(character_dir, "*.fbx")))
13
  assert character_list
14
  animation_list = sorted(glob(os.path.join(animation_dir, "*.fbx")))
15
  assert animation_list
16
+ get_base_name = lambda s: os.path.splitext(os.path.basename(s))[0]
17
  for char_file in tqdm(character_list, dynamic_ncols=True, desc="Character"):
18
  for anim_file in tqdm(animation_list, dynamic_ncols=True, leave=False, desc="Animation"):
19
+ output_filename = f"{get_base_name(char_file)}-{get_base_name(anim_file)}"
20
+ if os.path.isfile(os.path.join(output_dir, f"{output_filename}.fbx")):
21
+ continue
22
+ # Call subprocess to avoid accumulation bugs that gradually slow down the process
23
+ os.system(
24
+ f"python apply_animation_blender.py --char_path {char_file} --anim_path {anim_file} --output_dir {output_dir}"
25
+ )
 
 
 
 
 
 
 
 
 
 
 
apply_animation_blender.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import os
3
+
4
+ from utils import HiddenPrints, bpy, load_mixamo_anim, remove_all, reset, select_objs, update
5
+
6
+ if __name__ == "__main__":
7
+ parser = argparse.ArgumentParser()
8
+ parser.add_argument("--char_path", type=str, required=True)
9
+ parser.add_argument("--anim_path", type=str, required=True)
10
+ parser.add_argument("--output_dir", type=str, required=True)
11
+ args = parser.parse_args()
12
+
13
+ get_base_name = lambda s: os.path.splitext(os.path.basename(s))[0]
14
+ output_filename = f"{get_base_name(args.char_path)}-{get_base_name(args.anim_path)}"
15
+ with HiddenPrints():
16
+ # remove_all()
17
+ reset()
18
+ objs = load_mixamo_anim(args.char_path, args.anim_path, do_retarget=True, inplace=False)
19
+ update()
20
+ # bpy.ops.wm.save_as_mainfile(filepath=os.path.join(args.output_dir, f"{output_filename}.blend"))
21
+ select_objs(objs, deselect_first=True)
22
+ bpy.ops.export_scene.fbx(
23
+ filepath=os.path.join(args.output_dir, f"{output_filename}.fbx"),
24
+ check_existing=False,
25
+ use_selection=True,
26
+ use_triangles=True,
27
+ add_leaf_bones=False,
28
+ bake_anim=True,
29
+ # path_mode="COPY",
30
+ # embed_textures=True,
31
+ )
bones_vroid.fbx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:39907f8772741bcc892c581a38e36bf6d46968997a19e16abc13b8317a9e51da
3
+ size 65756
character_refine.py CHANGED
@@ -15,7 +15,7 @@ from utils import (
15
  )
16
 
17
 
18
- def rename_maxiamo_bone(armature_obj):
19
  """Replace name like 'mixamorig10:xxx' to 'mixamorig:xxx, so that character can be correctly animated.'"""
20
  import re
21
 
@@ -59,7 +59,7 @@ if __name__ == "__main__":
59
  assert len(armature_obj) == 1, "Armature number is not 1"
60
  armature_obj = armature_obj[0]
61
  if unposed_list is None or file in unposed_list:
62
- rename_maxiamo_bone(armature_obj)
63
  rest_bones, bones_idx_dict = get_rest_bones(armature_obj)
64
 
65
  # mesh_quads2tris(get_all_mesh_obj(obj_list))
 
15
  )
16
 
17
 
18
+ def rename_mixamo_bone(armature_obj):
19
  """Replace name like 'mixamorig10:xxx' to 'mixamorig:xxx, so that character can be correctly animated.'"""
20
  import re
21
 
 
59
  assert len(armature_obj) == 1, "Armature number is not 1"
60
  armature_obj = armature_obj[0]
61
  if unposed_list is None or file in unposed_list:
62
+ rename_mixamo_bone(armature_obj)
63
  rest_bones, bones_idx_dict = get_rest_bones(armature_obj)
64
 
65
  # mesh_quads2tris(get_all_mesh_obj(obj_list))
utils.py CHANGED
@@ -267,8 +267,8 @@ def enable_arp(armature_obj: Object, addon_path=os.path.join(os.path.dirname(__f
267
 
268
  assert os.path.isfile(os.path.join(addon_path, "__init__.py")), "Auto-Rig Pro not found"
269
  dirname, addon_name = os.path.split(addon_path)
270
- if addon_name in get_enabled_addons():
271
- return
272
  sys.path.insert(0, dirname)
273
  with Mode("POSE", armature_obj):
274
  # import addon_utils
 
267
 
268
  assert os.path.isfile(os.path.join(addon_path, "__init__.py")), "Auto-Rig Pro not found"
269
  dirname, addon_name = os.path.split(addon_path)
270
+ # if addon_name in get_enabled_addons():
271
+ # return
272
  sys.path.insert(0, dirname)
273
  with Mode("POSE", armature_obj):
274
  # import addon_utils