1 # SPDX-FileCopyrightText: 2019-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 from bpy
.types
import Panel
8 from .operators
import get_rig_and_cam
, CameraRigMixin
11 class ADD_CAMERA_RIGS_PT_camera_rig_ui(Panel
, CameraRigMixin
):
12 bl_label
= "Camera Rig"
13 bl_space_type
= 'VIEW_3D'
17 def draw(self
, context
):
18 active_object
= context
.active_object
19 rig
, cam
= get_rig_and_cam(context
.active_object
)
20 pose_bones
= rig
.pose
.bones
25 if rig
["rig_id"].lower() in ("dolly_rig", "crane_rig"):
26 layout
.prop(pose_bones
["Camera"], '["lens"]',
27 text
="Focal Length (mm)")
29 col
= layout
.column(align
=True)
30 col
.label(text
="Clipping:")
31 col
.prop(cam_data
, "clip_start", text
="Start")
32 col
.prop(cam_data
, "clip_end", text
="End")
34 layout
.prop(cam_data
, "type")
37 col
= layout
.column(align
=False)
38 col
.prop(cam_data
.dof
, "use_dof")
39 if cam_data
.dof
.use_dof
:
40 sub
= col
.column(align
=True)
41 if cam_data
.dof
.focus_object
is None:
42 sub
.operator("add_camera_rigs.set_dof_bone")
43 sub
.prop(cam_data
.dof
, "focus_object")
44 if (cam_data
.dof
.focus_object
is not None
45 and cam_data
.dof
.focus_object
.type == 'ARMATURE'):
46 sub
.prop_search(cam_data
.dof
, "focus_subtarget",
47 cam_data
.dof
.focus_object
.data
, "bones")
48 sub
= col
.column(align
=True)
49 row
= sub
.row(align
=True)
50 row
.active
= cam_data
.dof
.focus_object
is None
51 row
.prop(pose_bones
["Camera"],
52 '["focus_distance"]', text
="Focus Distance")
53 sub
.prop(pose_bones
["Camera"],
54 '["aperture_fstop"]', text
="F-Stop")
57 layout
.prop(active_object
, 'show_in_front',
58 toggle
=False, text
='Show in Front')
59 layout
.prop(cam_data
, "show_limits")
60 col
= layout
.column(align
=True)
61 col
.prop(cam_data
, "show_passepartout")
62 if cam_data
.show_passepartout
:
63 col
.prop(cam_data
, "passepartout_alpha")
67 panel
="ADD_CAMERA_RIGS_PT_composition_guides",
68 text
="Composition Guides",)
71 col
= layout
.column(align
=True)
73 "hide_select", text
="Make Camera Unselectable")
74 col
.operator("add_camera_rigs.add_marker_bind",
75 text
="Add Marker and Bind", icon
="MARKER_HLT")
76 col
.operator("add_camera_rigs.set_scene_camera",
77 text
="Make Camera Active", icon
='CAMERA_DATA')
79 if rig
["rig_id"].lower() in ("dolly_rig", "crane_rig"):
81 col
= layout
.column(align
=True)
82 track_to_constraint
= None
83 for con
in pose_bones
["Camera"].constraints
:
84 if con
.type == 'TRACK_TO':
85 track_to_constraint
= con
87 if track_to_constraint
is not None:
88 col
.label(text
="Tracking:")
89 col
.prop(track_to_constraint
, 'influence',
90 text
="Aim Lock", slider
=True)
93 if rig
["rig_id"].lower() == "crane_rig":
94 col
= layout
.column(align
=True)
95 col
.label(text
="Crane Arm:")
96 col
.prop(pose_bones
["Crane_height"],
97 'scale', index
=1, text
="Arm Height")
98 col
.prop(pose_bones
["Crane_arm"],
99 'scale', index
=1, text
="Arm Length")
102 elif rig
["rig_id"].lower() == "2d_rig":
103 col
= layout
.column(align
=True)
104 col
.label(text
="2D Rig:")
105 col
.prop(pose_bones
["Camera"], '["rotation_shift"]',
106 text
="Rotation/Shift")
107 if cam
.data
.sensor_width
!= 36:
108 col
.label(text
="Please set Camera Sensor Width to 36", icon
="ERROR")
112 bpy
.utils
.register_class(ADD_CAMERA_RIGS_PT_camera_rig_ui
)
116 bpy
.utils
.unregister_class(ADD_CAMERA_RIGS_PT_camera_rig_ui
)