Blender Kitsu: Refactor Shot Builder #183
@ -107,3 +107,14 @@ OUTPUT_COL_CREATE = {
|
|||||||
"storyboard": True,
|
"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
|
import bpy
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from .. import bkglobals
|
||||||
from ..types import (
|
from ..types import (
|
||||||
Sequence,
|
Sequence,
|
||||||
Shot,
|
Shot,
|
||||||
@ -80,6 +81,16 @@ def set_frame_range(shot: Shot, scene: bpy.types.Scene):
|
|||||||
scene.frame_end = start_3d + shot.nb_frames - 1
|
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(
|
def link_and_override_collection(
|
||||||
file_path: str, collection_name: str, scene: bpy.types.Scene
|
file_path: str, collection_name: str, scene: bpy.types.Scene
|
||||||
) -> bpy.types.Collection:
|
) -> bpy.types.Collection:
|
||||||
@ -93,13 +104,7 @@ def link_and_override_collection(
|
|||||||
Returns:
|
Returns:
|
||||||
bpy.types.Collection: Overriden Collection linked to Scene Collection
|
bpy.types.Collection: Overriden Collection linked to Scene Collection
|
||||||
"""
|
"""
|
||||||
bpy.ops.wm.link(
|
camera_col = link_collection(file_path, collection_name)
|
||||||
filepath=file_path,
|
|
||||||
directory=file_path + "/Collection",
|
|
||||||
filename=collection_name,
|
|
||||||
instance_collections=False,
|
|
||||||
)
|
|
||||||
camera_col = bpy.data.collections.get(collection_name)
|
|
||||||
override_camera_col = camera_col.override_hierarchy_create(
|
override_camera_col = camera_col.override_hierarchy_create(
|
||||||
scene, bpy.context.view_layer, do_fully_editable=True
|
scene, bpy.context.view_layer, do_fully_editable=True
|
||||||
)
|
)
|
||||||
@ -141,7 +146,7 @@ def link_camera_rig(
|
|||||||
scene.camera = camera
|
scene.camera = camera
|
||||||
|
|
||||||
|
|
||||||
def task_type_output_collection(
|
def create_task_type_output_collection(
|
||||||
scene: bpy.types.Scene, shot: Shot, task_type: TaskType
|
scene: bpy.types.Scene, shot: Shot, task_type: TaskType
|
||||||
) -> bpy.types.Collection:
|
) -> bpy.types.Collection:
|
||||||
collections = bpy.data.collections
|
collections = bpy.data.collections
|
||||||
@ -161,3 +166,14 @@ def task_type_output_collection(
|
|||||||
)
|
)
|
||||||
view_layer_output_collection.exclude = True
|
view_layer_output_collection.exclude = True
|
||||||
return output_collection
|
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,
|
get_file_dir,
|
||||||
set_render_engine,
|
set_render_engine,
|
||||||
link_camera_rig,
|
link_camera_rig,
|
||||||
task_type_output_collection,
|
create_task_type_output_collection,
|
||||||
set_shot_scene,
|
set_shot_scene,
|
||||||
set_resolution_and_fps,
|
set_resolution_and_fps,
|
||||||
set_frame_range,
|
set_frame_range,
|
||||||
|
link_task_type_output_collections,
|
||||||
)
|
)
|
||||||
|
|
||||||
active_project = None
|
active_project = None
|
||||||
@ -152,13 +153,17 @@ class KITSU_OT_build_new_shot(bpy.types.Operator):
|
|||||||
else:
|
else:
|
||||||
set_render_engine(context.scene)
|
set_render_engine(context.scene)
|
||||||
|
|
||||||
|
# Create Output Collection & Link Camera
|
||||||
if bkglobals.OUTPUT_COL_CREATE.get(task_short_name):
|
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
|
context.scene, shot, task_type
|
||||||
)
|
)
|
||||||
if task_short_name == 'anim':
|
if task_short_name == 'anim':
|
||||||
link_camera_rig(context.scene, output_col)
|
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("Create shot with the following details") # TODO Remove
|
||||||
print(f"Seq Name: '{seq.name}' Seq ID: '{self.seq_id}'")
|
print(f"Seq Name: '{seq.name}' Seq ID: '{self.seq_id}'")
|
||||||
print(f"Shot Name: '{shot.name}' Shot ID: '{self.shot_id}'")
|
print(f"Shot Name: '{shot.name}' Shot ID: '{self.shot_id}'")
|
||||||
|
Loading…
Reference in New Issue
Block a user