Add camera rigs: workaround for the 2D rig dependency cycle #105293
@ -5,8 +5,8 @@
|
|||||||
bl_info = {
|
bl_info = {
|
||||||
"name": "Add Camera Rigs",
|
"name": "Add Camera Rigs",
|
||||||
"author": "Wayne Dixon, Brian Raschko, Kris Wittig, Damien Picard, Flavio Perez",
|
"author": "Wayne Dixon, Brian Raschko, Kris Wittig, Damien Picard, Flavio Perez",
|
||||||
"version": (1, 6, 0),
|
"version": (1, 7, 0),
|
||||||
"blender": (4, 0, 0),
|
"blender": (4, 1, 0),
|
||||||
"location": "View3D > Add > Camera > Dolly or Crane Rig",
|
"location": "View3D > Add > Camera > Dolly or Crane Rig",
|
||||||
"description": "Adds a Camera Rig with UI",
|
"description": "Adds a Camera Rig with UI",
|
||||||
"doc_url": "{BLENDER_MANUAL_URL}/addons/camera/camera_rigs.html",
|
"doc_url": "{BLENDER_MANUAL_URL}/addons/camera/camera_rigs.html",
|
||||||
|
@ -337,7 +337,12 @@ def create_2d_bones(context, rig, cam):
|
|||||||
# Property to switch between rotation and switch mode
|
# Property to switch between rotation and switch mode
|
||||||
pose_bones["Camera"]['rotation_shift'] = 0.0
|
pose_bones["Camera"]['rotation_shift'] = 0.0
|
||||||
ui_data = pose_bones["Camera"].id_properties_ui('rotation_shift')
|
ui_data = pose_bones["Camera"].id_properties_ui('rotation_shift')
|
||||||
ui_data.update(min=0.0, max=1.0, description="rotation_shift")
|
ui_data.update(min=0.0, max=1.0, description="Switch between rotating the camera, or using its shift to track the controllers")
|
||||||
|
|
||||||
|
# Intermediate prop to avoid a dependency cycle in the lens driver
|
||||||
|
pose_bones["Camera"]['lens'] = 0.0
|
||||||
|
ui_data = pose_bones["Camera"].id_properties_ui('lens')
|
||||||
|
ui_data.update(min=1.0, soft_max=5000.0, description="Intermediate lens property, should not be used")
|
||||||
|
|
||||||
# Rotation / shift switch driver
|
# Rotation / shift switch driver
|
||||||
driver = con.driver_add('influence').driver
|
driver = con.driver_add('influence').driver
|
||||||
@ -349,8 +354,8 @@ def create_2d_bones(context, rig, cam):
|
|||||||
var.targets[0].id = rig
|
var.targets[0].id = rig
|
||||||
var.targets[0].data_path = 'pose.bones["Camera"]["rotation_shift"]'
|
var.targets[0].data_path = 'pose.bones["Camera"]["rotation_shift"]'
|
||||||
|
|
||||||
# Focal length driver
|
# Intermediate focal length driver
|
||||||
driver = cam.data.driver_add('lens').driver
|
driver = pose_bones["Camera"].driver_add('["lens"]').driver
|
||||||
driver.expression = 'abs({distance_z} - (left_z + right_z)/2 + cam_z) * 36 / frame_width'.format(
|
driver.expression = 'abs({distance_z} - (left_z + right_z)/2 + cam_z) * 36 / frame_width'.format(
|
||||||
distance_z=corner_distance_z)
|
distance_z=corner_distance_z)
|
||||||
|
|
||||||
@ -381,6 +386,16 @@ def create_2d_bones(context, rig, cam):
|
|||||||
var.targets[0].transform_type = 'LOC_Z'
|
var.targets[0].transform_type = 'LOC_Z'
|
||||||
var.targets[0].transform_space = 'TRANSFORM_SPACE'
|
var.targets[0].transform_space = 'TRANSFORM_SPACE'
|
||||||
|
|
||||||
|
# Actual focal length driver
|
||||||
|
driver = cam.data.driver_add('lens').driver
|
||||||
|
driver.type = 'AVERAGE'
|
||||||
|
|
||||||
|
var = driver.variables.new()
|
||||||
|
var.name = 'lens'
|
||||||
|
var.type = 'SINGLE_PROP'
|
||||||
|
var.targets[0].id = rig
|
||||||
|
var.targets[0].data_path = 'pose.bones["Camera"]["lens"]'
|
||||||
|
|
||||||
# Orthographic scale driver
|
# Orthographic scale driver
|
||||||
driver = cam.data.driver_add('ortho_scale').driver
|
driver = cam.data.driver_add('ortho_scale').driver
|
||||||
driver.expression = 'abs({distance_x} - (left_x - right_x))'.format(distance_x=corner_distance_x)
|
driver.expression = 'abs({distance_x} - (left_x - right_x))'.format(distance_x=corner_distance_x)
|
||||||
@ -427,9 +442,8 @@ def create_2d_bones(context, rig, cam):
|
|||||||
var = driver.variables.new()
|
var = driver.variables.new()
|
||||||
var.name = 'lens'
|
var.name = 'lens'
|
||||||
var.type = 'SINGLE_PROP'
|
var.type = 'SINGLE_PROP'
|
||||||
var.targets[0].id_type = 'CAMERA'
|
var.targets[0].id = rig
|
||||||
var.targets[0].id = cam.data
|
var.targets[0].data_path = 'pose.bones["Camera"]["lens"]'
|
||||||
var.targets[0].data_path = 'lens'
|
|
||||||
|
|
||||||
# Shift driver Y
|
# Shift driver Y
|
||||||
driver = cam.data.driver_add('shift_y').driver
|
driver = cam.data.driver_add('shift_y').driver
|
||||||
@ -472,9 +486,8 @@ def create_2d_bones(context, rig, cam):
|
|||||||
var = driver.variables.new()
|
var = driver.variables.new()
|
||||||
var.name = 'lens'
|
var.name = 'lens'
|
||||||
var.type = 'SINGLE_PROP'
|
var.type = 'SINGLE_PROP'
|
||||||
var.targets[0].id_type = 'CAMERA'
|
var.targets[0].id = rig
|
||||||
var.targets[0].id = cam.data
|
var.targets[0].data_path = 'pose.bones["Camera"]["lens"]'
|
||||||
var.targets[0].data_path = 'lens'
|
|
||||||
|
|
||||||
|
|
||||||
def build_camera_rig(context, mode):
|
def build_camera_rig(context, mode):
|
||||||
|
@ -104,6 +104,8 @@ class ADD_CAMERA_RIGS_PT_camera_rig_ui(Panel, CameraRigMixin):
|
|||||||
col.label(text="2D Rig:")
|
col.label(text="2D Rig:")
|
||||||
col.prop(pose_bones["Camera"], '["rotation_shift"]',
|
col.prop(pose_bones["Camera"], '["rotation_shift"]',
|
||||||
text="Rotation/Shift")
|
text="Rotation/Shift")
|
||||||
|
col.prop(pose_bones["Camera"], '["aperture_fstop"]',
|
||||||
|
text="F-Stop")
|
||||||
if cam.data.sensor_width != 36:
|
if cam.data.sensor_width != 36:
|
||||||
col.label(text="Please set Camera Sensor Width to 36", icon="ERROR")
|
col.label(text="Please set Camera Sensor Width to 36", icon="ERROR")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user