forked from JonnylikesJazz/Wadblender-Anim-Tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimport_anim.py
More file actions
87 lines (63 loc) · 2.52 KB
/
import_anim.py
File metadata and controls
87 lines (63 loc) · 2.52 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import bpy
from .anim import import_anim
def do_import(context, filepath, rig_name, use_current_frame, start_frame, baseline_offsets):
if use_current_frame:
start_frame = context.scene.frame_current
import_anim(filepath, rig_name=rig_name, start_frame=start_frame, baseline_offsets=baseline_offsets)
return {'FINISHED'}
from bpy_extras.io_utils import ImportHelper
from bpy.props import StringProperty, BoolProperty, IntProperty
from bpy.types import Operator
class ImportWadToolAnim(Operator, ImportHelper):
"""Import a Tomb Editor / WadTool Animation (.anim) as a new Action on an armature"""
bl_idname = "import_anim.data"
bl_label = "Import Wad Tool Animation"
filename_ext = ".anim"
filter_glob: StringProperty(
default="*.anim;*.ANIM",
options={'HIDDEN'},
maxlen=255,
)
rig_name: StringProperty(
default="LARA_RIG",
description="Armature object name. If not found, the active armature is used.",
maxlen=255,
)
use_current_frame: BoolProperty(
name="Start at Current Frame",
description="Insert imported keys starting at the current scene frame",
default=True,
)
start_frame: IntProperty(
name="Start Frame",
description="Frame to start inserting keys at (ignored if 'Start at Current Frame' is enabled)",
default=1,
min=-100000,
max=100000,
)
baseline_offsets: BoolProperty(
name="Baseline Offsets",
description="Treat the first frame's offsets as baseline and import deltas only (recommended)",
default=True,
)
def draw(self, context):
layout = self.layout
layout.prop(self, "rig_name")
layout.prop(self, "use_current_frame")
if not self.use_current_frame:
layout.prop(self, "start_frame")
layout.prop(self, "baseline_offsets")
def execute(self, context):
return do_import(context, self.filepath, self.rig_name, self.use_current_frame, self.start_frame, self.baseline_offsets)
def menu_func_import(self, context):
self.layout.operator(ImportWadToolAnim.bl_idname, text="Tomb Editor Animation (.anim)")
def register():
bpy.utils.register_class(ImportWadToolAnim)
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
def unregister():
bpy.utils.unregister_class(ImportWadToolAnim)
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
if __name__ == "__main__":
register()
# test call
bpy.ops.import_anim.data('INVOKE_DEFAULT')