-
Notifications
You must be signed in to change notification settings - Fork 5
/
blender2.92showshapkevalue.py
54 lines (46 loc) · 1.74 KB
/
blender2.92showshapkevalue.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import bpy
import os
import json
def export_metahuman_json(ob, outputpath):
"""
export metahuman curve to json
export the selected frame start frame end curve
"""
dict_ani = {}
for block in ob.data.shape_keys.key_blocks:
if block.name != "Basis":
dict_ani[block.name] = []
if block.name == "CTRL_expressions_jawChinRaiseDL":
for i in range(bpy.context.scene.frame_start, bpy.context.scene.frame_end):
bpy.context.scene.frame_current = i
bpy.context.view_layer.update() # important
tmp = {}
tmp["frameNum"] = i
tmp["value"] = block.value
# dict_ani[block.name].append(tmp)
print("block : {}, tmp:{}".format(block, tmp))
print("export over!")
def export_metahuman_json2(ob, outputpath):
"""
export metahuman curve to json
export the selected frame start frame end curve
"""
dict_channel = {}
for i in range(bpy.context.scene.frame_start, bpy.context.scene.frame_end):
bpy.context.scene.frame_set(i)
for block in ob.data.shape_keys.key_blocks:
if block.name != "Basis":
tmp = {}
tmp["frameNum"] = i
tmp['value'] = block.value
if block.name in dict_channel.keys():
dict_channel[block.name].append(tmp)
else:
dict_channel[block.name] = []
print("export {}".format(i))
# print("export over!")
write_json(outputpath, dict_channel)
if __name__ == "__main__":
ob = bpy.data.objects['head_geo']
outputpath = r""
export_metahuman_json(ob, outputpath)