-
Notifications
You must be signed in to change notification settings - Fork 16
/
hka_import_op.py
48 lines (33 loc) · 1.3 KB
/
hka_import_op.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
"""hka import operator
"""
import os
import subprocess
import bpy
from bpy.props import BoolProperty
from bpy_extras.io_utils import ImportHelper
from io_anim_hkx.hka_import import import_hkafile
class hkaImportOperator(bpy.types.Operator, ImportHelper):
"""Import a hkaAnimationContainer file
"""
bl_idname = "import_anim.hkx"
bl_label = "Import hkx"
filename_ext = ".hkx"
filter_glob = bpy.props.StringProperty(default="*.hkx", options={'HIDDEN'})
use_anim = BoolProperty(
name="Import to Animation",
description="if uncheck then import to Pose",
default=False,
)
def execute(self, context):
dirname = os.path.dirname(os.path.abspath(__file__))
skeleton_file = dirname + "/resources/skeleton.bin"
anim_hkx_file = self.properties.filepath
basename = os.path.basename(anim_hkx_file)
basename, extension = os.path.splitext(basename)
anim_bin_file = dirname + '/tmp/' + basename + '.bin'
command = dirname + '/bin/hkdump-bin.exe'
process = subprocess.run([command, '-o', anim_bin_file, anim_hkx_file])
use_anim = self.properties.use_anim
if process.returncode == 0:
import_hkafile(skeleton_file, anim_bin_file, use_anim)
return {'FINISHED'}