Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Picard <dam.pic@free.fr>2020-01-24 12:30:51 +0300
committerDamien Picard <dam.pic@free.fr>2020-03-09 14:07:23 +0300
commitf4cf9b00db36bf096e1cf5ad50127ade8b985dd2 (patch)
tree794eda051cf81946121337f110ad7d24a979cd8c /add_camera_rigs/operators.py
parentcebfa3b6e6f4a436a937baf9549963dde2dedc6c (diff)
Add camera rigs: add 2D camera rig
This rig is mostly useful for 2D shots, when the camera is static and the action happens in front of it (like a theatre stage). In a 2D production (and some shots in 3D as well), you sometimes need to rotate the camera while zooming, effectively "cropping" the field, just as you would using a rostrum camera. This is tedious and error-prone if animating built-in basic transforms, so this rig implements a more intuitive way to do that, by just animating the two lower corners of the camera's field. Also improved other stuff in the add-on: - add the GPL license block to create_widgets.py; - rename "arm[ature]" to "rig" in some functions, for consistency and to avoid confusion with the crane's arm; - changes to the UI panel: - remove the boxes, - put focal length at the top of the panel, - group related properties using aligned columns, - change the Make Camera Active operator's poll method, so that it is always visible in the UI, but greyed out when the camera is already active.
Diffstat (limited to 'add_camera_rigs/operators.py')
-rw-r--r--add_camera_rigs/operators.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/add_camera_rigs/operators.py b/add_camera_rigs/operators.py
index 7468007e..058ed146 100644
--- a/add_camera_rigs/operators.py
+++ b/add_camera_rigs/operators.py
@@ -20,7 +20,7 @@ import bpy
from bpy.types import Operator
-def get_arm_and_cam(obj):
+def get_rig_and_cam(obj):
if obj.type == 'ARMATURE':
cam = None
for child in obj.children:
@@ -32,7 +32,8 @@ def get_arm_and_cam(obj):
elif (obj.type == 'CAMERA'
and obj.parent is not None
and "rig_id" in obj.parent
- and obj.parent["rig_id"].lower() in {"dolly_rig", "crane_rig"}):
+ and obj.parent["rig_id"].lower() in {"dolly_rig",
+ "crane_rig", "2d_rig"}):
return obj.parent, obj
return None, None
@@ -41,25 +42,31 @@ class CameraRigMixin():
@classmethod
def poll(cls, context):
if context.active_object is not None:
- return get_arm_and_cam(context.active_object) != (None, None)
+ return get_rig_and_cam(context.active_object) != (None, None)
return False
-class ADD_CAMERA_RIGS_OT_set_scene_camera(Operator, CameraRigMixin):
+class ADD_CAMERA_RIGS_OT_set_scene_camera(Operator):
bl_idname = "add_camera_rigs.set_scene_camera"
bl_label = "Make Camera Active"
bl_description = "Makes the camera parented to this rig the active scene camera"
+ @classmethod
+ def poll(cls, context):
+ if context.active_object is not None:
+ rig, cam = get_rig_and_cam(context.active_object)
+ if cam is not None:
+ return cam is not context.scene.camera
+
+ return False
+
def execute(self, context):
- arm, cam = get_arm_and_cam(context.active_object)
+ rig, cam = get_rig_and_cam(context.active_object)
scene_cam = context.scene.camera
- if cam is not None and cam is not scene_cam:
- context.scene.camera = cam
- return {'FINISHED'}
-
- return {'CANCELLED'}
+ context.scene.camera = cam
+ return {'FINISHED'}
class ADD_CAMERA_RIGS_OT_add_marker_bind(Operator, CameraRigMixin):
@@ -68,7 +75,7 @@ class ADD_CAMERA_RIGS_OT_add_marker_bind(Operator, CameraRigMixin):
bl_description = "Add marker to current frame then bind rig camera to it (for camera switching)"
def execute(self, context):
- arm, cam = get_arm_and_cam(context.active_object)
+ rig, cam = get_rig_and_cam(context.active_object)
marker = context.scene.timeline_markers.new(
"cam_" + str(context.scene.frame_current),
@@ -85,15 +92,15 @@ class ADD_CAMERA_RIGS_OT_add_dof_object(Operator, CameraRigMixin):
bl_description = "Create Empty and add as DOF Object"
def execute(self, context):
- arm, cam = get_arm_and_cam(context.active_object)
- bone = arm.data.bones['Aim_shape_rotation-MCH']
+ rig, cam = get_rig_and_cam(context.active_object)
+ bone = rig.data.bones['Aim_shape_rotation-MCH']
# Add Empty
empty_obj = bpy.data.objects.new("EmptyDOF", None)
context.scene.collection.objects.link(empty_obj)
# Parent to Aim Child bone
- empty_obj.parent = arm
+ empty_obj.parent = rig
empty_obj.parent_type = "BONE"
empty_obj.parent_bone = "Aim_shape_rotation-MCH"