-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathSpritesAsPlanes.py
99 lines (73 loc) · 3.53 KB
/
SpritesAsPlanes.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
bl_info = {
'name': 'SpritesAsPlanes',
'author': 'bay raitt',
'version': (0, 1),
'blender': (2, 92, 0),
'category': 'Animation',
'location': '3D Comic > Assets > Sprites As Cards',
'wiki_url': ''}
import bpy
class SpritesAsPlanesSettings(bpy.types.PropertyGroup):
treadmillSourceCollection : bpy.props.PointerProperty(
type=bpy.types.Collection,
name="Source",
description="The collection to use as a treadmill"
)
speed_strategy : bpy.props.EnumProperty(
name="Target",
description="Type of object to recieve baked textures",
items={
("speed_slow", "Speed Slow","slow", 0),
("speed_medium","Speed Medium", "medium", 1),
("speed_fast", "Speed Fast","fast", 2),
},
default="speed_medium"
)
class BR_OT_key_collection_treadmill(bpy.types.Operator):
"""key selected collection as a stationary treadmill with two reinstances"""
bl_idname = "wm.spiraloid_key_collection_readmill"
bl_label = "key collection treadmill..."
bl_options = {'REGISTER', 'UNDO'}
config: bpy.props.PointerProperty(type=SpritesAsPlanesSettings)
def draw(self, context):
layout = self.layout
scene = context.scene
key_collection_treadmill_settings = scene.key_collection_treadmill_settings
strategy_row = layout.row(align=True)
layout.prop(key_collection_treadmill_settings, "treadmillSourceCollection" )
layout.prop(key_collection_treadmill_settings, "speed_strategy")
def execute(self, context):
settings = context.scene.key_collection_treadmill_settings
source_collection = settings.treadmillSourceCollection
source_collection_name = source_collection.name
scene_collection = bpy.context.view_layer.layer_collection
treadmill_collection_name = (source_collection_name + "_treadmill")
bpy.context.scene.tool_settings.use_keyframe_insert_auto = False
if bpy.ops.object.mode_set.poll():
bpy.ops.object.mode_set(mode='OBJECT')
# cleanup previous bake collection
if bpy.data.collections.get(treadmill_collection_name) :
old_bake_collection = bpy.data.collections.get(treadmill_collection_name)
bpy.context.view_layer.active_layer_collection = bpy.context.view_layer.layer_collection.children[treadmill_collection_name]
bpy.data.collections.remove(old_bake_collection)
empty_trash(self, context)
self.report({'INFO'}, 'Deleted Previous Treadmill collection!')
treadmill_collection = bpy.data.collections.new(treadmill_collection_name)
return {'FINISHED'}
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
def menu_draw(self, context):
self.layout.operator(BR_OT_bake_mesh_flipbook.bl_idname)
def register():
bpy.utils.register_class(BR_OT_key_collection_treadmill)
bpy.utils.register_class(SpritesAsPlanesSettings)
bpy.types.Scene.key_collection_treadmill_settings = bpy.props.PointerProperty(type=SpritesAsPlanesSettings)
bpy.types.VIEW3D_MT_object_animation.append(menu_draw)
def unregister():
bpy.utils.unregister_class(BR_OT_key_collection_treadmill)
bpy.types.VIEW3D_MT_object_animation.remove(menu_draw)
bpy.utils.unregister_class(SpritesAsPlanesSettings)
if __name__ != "__main__":
bpy.types.VIEW3D_MT_view.remove(menu_draw)
if __name__ == "__main__":
register()