-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
224 lines (172 loc) · 6.08 KB
/
__init__.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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
bl_info = {
"name": "Tween Machine",
"author": "Fabien Collet",
"version": (0, 2, 0),
"blender": (2, 90, 0),
"location": "Object > Animation > Tween Machine",
"description": "Insert Breakdown Keyframes",
"warning": "",
"doc_url": "https://github.com/fabiencollet/blender-tweenMachine",
"category": "Animation",
}
import bpy
from .core import tween
# --------------------------------------------------------------
# To-Do
# --------------------------------------------------------------
# --------------------------------------------------------------
# Globals
# --------------------------------------------------------------
# --------------------------------------------------------------
# Operators
# --------------------------------------------------------------
class ANIM_OT_tween_10(bpy.types.Operator):
"""Tween Machine 10%"""
bl_idname = "anim.tween_machine_10"
bl_label = "10%"
bl_options = {'REGISTER', 'UNDO'}
bl_context = ['objectmode', 'posemode']
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
if tween(self, context, 0.10):
return {'FINISHED'}
else:
return {'CANCELLED'}
class ANIM_OT_tween_25(bpy.types.Operator):
"""Tween Machine 25%"""
bl_idname = "anim.tween_machine_25"
bl_label = "25%"
bl_options = {'REGISTER', 'UNDO'}
bl_context = ['objectmode', 'posemode']
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
if tween(self, context, 0.25):
return {'FINISHED'}
else:
return {'CANCELLED'}
class ANIM_OT_tween_50(bpy.types.Operator):
"""Tween Machine 50%"""
bl_idname = "anim.tween_machine_50"
bl_label = "50%"
bl_options = {'REGISTER', 'UNDO'}
bl_context = ['objectmode', 'posemode']
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
if tween(self, context, 0.50):
return {'FINISHED'}
else:
return {'CANCELLED'}
class ANIM_OT_tween_75(bpy.types.Operator):
"""Tween Machine 75%"""
bl_idname = "anim.tween_machine_75"
bl_label = "75%"
bl_options = {'REGISTER', 'UNDO'}
bl_context = ['objectmode', 'posemode']
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
if tween(self, context, 0.75):
return {'FINISHED'}
else:
return {'CANCELLED'}
class ANIM_OT_tween_90(bpy.types.Operator):
"""Tween Machine 90%"""
bl_idname = "anim.tween_machine_90"
bl_label = "90%"
bl_options = {'REGISTER', 'UNDO'}
bl_context = ['objectmode', 'posemode']
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
if tween(self, context, 0.90):
return {'FINISHED'}
else:
return {'CANCELLED'}
class VIEW_3D_PT_tweenMachine(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_category = "Item"
bl_label = "Tween Machine"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
def draw(self, context):
layout = self.layout
# Add the property slider Tween Mix
row = layout.row()
row.prop(context.scene, "tween_mix")
# Add all operators Tween Machine
row = layout.row()
row.operator(ANIM_OT_tween_10.bl_idname)
row.operator(ANIM_OT_tween_25.bl_idname)
row.operator(ANIM_OT_tween_50.bl_idname)
row.operator(ANIM_OT_tween_75.bl_idname)
row.operator(ANIM_OT_tween_90.bl_idname)
class VIEW_3D_PT_tweenMachineSettings(bpy.types.Panel):
"""Creates a SubPanel for advanced properties of tweenMachine"""
bl_category = "Tween Machine"
bl_label = "Advanced Settings"
bl_parent_id = "VIEW_3D_PT_tweenMachine"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
def draw(self, context):
layout = self.layout
# Add the property slider Tween Mix
row = layout.row()
row.prop(context.scene, "tween_location")
row = layout.row()
row.prop(context.scene, "tween_rotation")
row = layout.row()
row.prop(context.scene, "tween_scale")
row = layout.row()
row.prop(context.scene, "tween_custom")
def add_tween_menu_draw(self, context):
"""Creates a Menu inside Object > Animation"""
self.layout.separator()
self.layout.operator(
ANIM_OT_tween_10.bl_idname,
text="Tween Machine 10%")
self.layout.operator(
ANIM_OT_tween_25.bl_idname,
text="Tween Machine 25%")
self.layout.operator(
ANIM_OT_tween_50.bl_idname,
text="Tween Machine 50%")
self.layout.operator(
ANIM_OT_tween_75.bl_idname,
text="Tween Machine 75%")
self.layout.operator(
ANIM_OT_tween_90.bl_idname,
text="Tween Machine 90%")
def register():
# Register Operators
bpy.utils.register_class(ANIM_OT_tween_10)
bpy.utils.register_class(ANIM_OT_tween_25)
bpy.utils.register_class(ANIM_OT_tween_50)
bpy.utils.register_class(ANIM_OT_tween_75)
bpy.utils.register_class(ANIM_OT_tween_90)
# Register Panel
bpy.utils.register_class(VIEW_3D_PT_tweenMachine)
bpy.utils.register_class(VIEW_3D_PT_tweenMachineSettings)
# Register Menu
bpy.types.VIEW3D_MT_object_animation.append(add_tween_menu_draw)
def unregister():
# Unregister Operators
bpy.utils.unregister_class(ANIM_OT_tween_10)
bpy.utils.unregister_class(ANIM_OT_tween_25)
bpy.utils.unregister_class(ANIM_OT_tween_50)
bpy.utils.unregister_class(ANIM_OT_tween_75)
bpy.utils.unregister_class(ANIM_OT_tween_90)
# Unregister Panel
bpy.utils.unregister_class(VIEW_3D_PT_tweenMachine)
bpy.utils.unregister_class(VIEW_3D_PT_tweenMachineSettings)
# Unregister Menu
bpy.types.VIEW3D_MT_object_animation.remove(add_tween_menu_draw)
if __name__ == "__main__":
register()