Shot Viewer: sequence field, cameras named CAM_sq0000_sh0000
The Shot Viewer panel gets a Sequence number, saved with the scene. New
shot cameras are named from it with SHOT_CAMERA_NAME_FORMAT
("{prefix}{sequence}_{shot}") and SEQUENCE_NAME_FORMAT ("sq{:04d}"),
both overridable in the config JSON.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c376a92591
commit
00788bb3bf
4 files changed
+44
-8
No files matched your search
+26
-6
@@ -110,16 +110,27 @@ def next_shot_name(scene):
|
||||
return config.SHOT_NAME_FORMAT.format((max(numbers, default=0) // step + 1) * step)
|
||||
|
||||
|
||||
def _new_camera(scene, name, source=None):
|
||||
def sequence_name(scene):
|
||||
return config.SEQUENCE_NAME_FORMAT.format(scene.wtd_sequence)
|
||||
|
||||
|
||||
def camera_name(scene, shot):
|
||||
"""Name of a new shot camera (config SHOT_CAMERA_NAME_FORMAT)."""
|
||||
return config.SHOT_CAMERA_NAME_FORMAT.format(
|
||||
prefix=config.OBJECT_PREFIXES.get("CAMERA", ""), sequence=sequence_name(scene), shot=shot
|
||||
)
|
||||
|
||||
|
||||
def _new_camera(scene, shot, source=None):
|
||||
"""New camera in the scene collection, copying ``source`` (lens and placement) when given."""
|
||||
camera_name = config.OBJECT_PREFIXES.get("CAMERA", "") + name
|
||||
name = camera_name(scene, shot)
|
||||
if source is not None and source.type == "CAMERA":
|
||||
data = source.data.copy()
|
||||
data.name = camera_name
|
||||
data.name = name
|
||||
else:
|
||||
source = None
|
||||
data = bpy.data.cameras.new(camera_name)
|
||||
camera = bpy.data.objects.new(camera_name, data)
|
||||
data = bpy.data.cameras.new(name)
|
||||
camera = bpy.data.objects.new(name, data)
|
||||
if source is not None:
|
||||
camera.matrix_world = source.matrix_world.copy()
|
||||
else:
|
||||
@@ -231,7 +242,10 @@ class WTD_OT_shot_viewer_new_shot(bpy.types.Operator):
|
||||
layout.prop(self, "name")
|
||||
layout.prop(self, "duration")
|
||||
layout.prop(self, "new_camera")
|
||||
if not self.new_camera:
|
||||
if self.new_camera:
|
||||
name = self.name.strip() or next_shot_name(context.scene)
|
||||
layout.label(text=camera_name(context.scene, name), icon="CAMERA_DATA")
|
||||
else:
|
||||
layout.prop_search(self, "camera_name", context.scene, "objects", icon="CAMERA_DATA")
|
||||
|
||||
def execute(self, context):
|
||||
@@ -358,12 +372,18 @@ def register():
|
||||
for cls in classes:
|
||||
bpy.utils.register_class(cls)
|
||||
bpy.types.WindowManager.wtd_shot_viewer = PointerProperty(type=WTD_ShotViewerSettings)
|
||||
bpy.types.Scene.wtd_sequence = IntProperty(
|
||||
name="Sequence",
|
||||
description="Sequence number of the scene, used in the names of new cameras (config SEQUENCE_NAME_FORMAT)",
|
||||
min=0,
|
||||
)
|
||||
bpy.app.handlers.frame_change_post.append(_on_frame_change)
|
||||
|
||||
|
||||
def unregister():
|
||||
if _on_frame_change in bpy.app.handlers.frame_change_post:
|
||||
bpy.app.handlers.frame_change_post.remove(_on_frame_change)
|
||||
del bpy.types.Scene.wtd_sequence
|
||||
del bpy.types.WindowManager.wtd_shot_viewer
|
||||
for cls in reversed(classes):
|
||||
bpy.utils.unregister_class(cls)
|
||||
Reference in new issue
Block a user