-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.py
67 lines (56 loc) · 2.19 KB
/
plugin.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
bl_info = {
"name": "Camera Rig Setup",
"blender": (2, 80, 0),
"category": "Object",
}
import bpy
class CamRigSetupOperator(bpy.types.Operator):
"""Set up a camera rig along a path with a target"""
bl_idname = "object.camrig_setup"
bl_label = "Set Up Camera Rig"
bl_options = {'REGISTER', 'UNDO'}
# Properties to be set by the user
camera: bpy.props.PointerProperty(name="Camera", type=bpy.types.Object, poll=lambda self, obj: obj.type == 'CAMERA')
path: bpy.props.PointerProperty(name="Path", type=bpy.types.Object, poll=lambda self, obj: obj.type == 'CURVE')
target: bpy.props.PointerProperty(name="Target", type=bpy.types.Object)
forward_axis: bpy.props.EnumProperty(
name="Forward Axis",
items=[
('TRACK_NEGATIVE_X', '-X', ""),
('TRACK_X', 'X', ""),
('TRACK_NEGATIVE_Y', '-Y', ""),
('TRACK_Y', 'Y', ""),
('TRACK_NEGATIVE_Z', '-Z', ""),
('TRACK_Z', 'Z', "")
],
default='TRACK_NEGATIVE_Z'
)
up_axis: bpy.props.EnumProperty(
name="Up Axis",
items=[
('UP_X', 'X', ""),
('UP_Y', 'Y', ""),
('UP_Z', 'Z', "")
],
default='UP_Y'
)
def execute(self, context):
# Setup camera constraints here
# This is a placeholder for the actual setup logic you've implemented
# For example, setting up a "Follow Path" constraint
follow_path_constraint = self.camera.constraints.new(type='FOLLOW_PATH')
follow_path_constraint.target = self.path
# Assume similar setup for "Track To" constraint and any animation keyframes
# You would use self.forward_axis and self.up_axis where appropriate
self.report({'INFO'}, "Camera Rig Setup Complete")
return {'FINISHED'}
def menu_func(self, context):
self.layout.operator(CamRigSetupOperator.bl_idname)
def register():
bpy.utils.register_class(CamRigSetupOperator)
bpy.types.VIEW3D_MT_object.append(menu_func)
def unregister():
bpy.utils.unregister_class(CamRigSetupOperator)
bpy.types.VIEW3D_MT_object.remove(menu_func)
if __name__ == "__main__":
register()