Blender Kitsu: Refactor Shot Builder #183
@ -107,3 +107,14 @@ OUTPUT_COL_CREATE = {
|
||||
"storyboard": True,
|
||||
}
|
||||
|
||||
OUTPUT_COL_LINK_MAPPING = {
|
||||
"anim": None,
|
||||
"comp": ['anim', 'fx', 'lighting'],
|
||||
"fx": ['anim', 'lighting'],
|
||||
"layout": None,
|
||||
"lighting": ['anim'],
|
||||
"previz": None,
|
||||
"rendering": None,
|
||||
"smear_to_mesh": None,
|
||||
"storyboard": None,
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import bpy
|
||||
from pathlib import Path
|
||||
|
||||
from .. import bkglobals
|
||||
from ..types import (
|
||||
Sequence,
|
||||
Shot,
|
||||
@ -80,6 +81,16 @@ def set_frame_range(shot: Shot, scene: bpy.types.Scene):
|
||||
scene.frame_end = start_3d + shot.nb_frames - 1
|
||||
|
||||
|
||||
def link_collection(file_path: str, collection_name: str):
|
||||
bpy.ops.wm.link(
|
||||
filepath=file_path,
|
||||
directory=file_path + "/Collection",
|
||||
filename=collection_name,
|
||||
instance_collections=False,
|
||||
)
|
||||
return bpy.data.collections.get(collection_name)
|
||||
|
||||
|
||||
def link_and_override_collection(
|
||||
file_path: str, collection_name: str, scene: bpy.types.Scene
|
||||
) -> bpy.types.Collection:
|
||||
@ -93,13 +104,7 @@ def link_and_override_collection(
|
||||
Returns:
|
||||
bpy.types.Collection: Overriden Collection linked to Scene Collection
|
||||
"""
|
||||
bpy.ops.wm.link(
|
||||
filepath=file_path,
|
||||
directory=file_path + "/Collection",
|
||||
filename=collection_name,
|
||||
instance_collections=False,
|
||||
)
|
||||
camera_col = bpy.data.collections.get(collection_name)
|
||||
camera_col = link_collection(file_path, collection_name)
|
||||
override_camera_col = camera_col.override_hierarchy_create(
|
||||
scene, bpy.context.view_layer, do_fully_editable=True
|
||||
)
|
||||
@ -141,7 +146,7 @@ def link_camera_rig(
|
||||
scene.camera = camera
|
||||
|
||||
|
||||
def task_type_output_collection(
|
||||
def create_task_type_output_collection(
|
||||
scene: bpy.types.Scene, shot: Shot, task_type: TaskType
|
||||
) -> bpy.types.Collection:
|
||||
collections = bpy.data.collections
|
||||
@ -161,3 +166,14 @@ def task_type_output_collection(
|
||||
)
|
||||
view_layer_output_collection.exclude = True
|
||||
return output_collection
|
||||
|
||||
|
||||
def link_task_type_output_collections(shot: Shot, task_short_name: str):
|
||||
# TODO TEST IF THIS WORKS
|
||||
for short_name in bkglobals.OUTPUT_COL_LINK_MAPPING.get(task_short_name):
|
||||
external_filepath = dir.joinpath(short_name)
|
||||
if not external_filepath.exists():
|
||||
print(f"Unable to link output collection for {external_filepath.name}")
|
||||
file_path = external_filepath.__str__()
|
||||
colection_name = shot.get_shot_task_name(short_name)
|
||||
link_collection(file_path, colection_name)
|
||||
|
@ -7,10 +7,11 @@ from .core import (
|
||||
get_file_dir,
|
||||
set_render_engine,
|
||||
link_camera_rig,
|
||||
task_type_output_collection,
|
||||
create_task_type_output_collection,
|
||||
set_shot_scene,
|
||||
set_resolution_and_fps,
|
||||
set_frame_range,
|
||||
link_task_type_output_collections,
|
||||
)
|
||||
|
||||
active_project = None
|
||||
@ -152,13 +153,17 @@ class KITSU_OT_build_new_shot(bpy.types.Operator):
|
||||
else:
|
||||
set_render_engine(context.scene)
|
||||
|
||||
# Create Output Collection & Link Camera
|
||||
if bkglobals.OUTPUT_COL_CREATE.get(task_short_name):
|
||||
output_col = task_type_output_collection( # TODO imporve
|
||||
output_col = create_task_type_output_collection( # TODO imporve
|
||||
context.scene, shot, task_type
|
||||
)
|
||||
if task_short_name == 'anim':
|
||||
link_camera_rig(context.scene, output_col)
|
||||
|
||||
# Link External Output Collections
|
||||
link_task_type_output_collections(shot, task_short_name)
|
||||
|
||||
print("Create shot with the following details") # TODO Remove
|
||||
print(f"Seq Name: '{seq.name}' Seq ID: '{self.seq_id}'")
|
||||
print(f"Shot Name: '{shot.name}' Shot ID: '{self.shot_id}'")
|
||||
|
Loading…
Reference in New Issue
Block a user