mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
roy's comment
This commit is contained in:
parent
582bdb51a2
commit
45f02e8db3
5 changed files with 27 additions and 14 deletions
|
|
@ -282,3 +282,13 @@ def get_max_version():
|
|||
"""
|
||||
max_info = rt.MaxVersion()
|
||||
return max_info[7]
|
||||
|
||||
@contextlib.contextmanager
|
||||
def viewport_camera(camera):
|
||||
original = rt.viewport.getCamera()
|
||||
review_camera = rt.getNodeByName(camera)
|
||||
try:
|
||||
rt.viewport.setCamera(review_camera)
|
||||
yield
|
||||
finally:
|
||||
rt.viewport.setCamera(original)
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ class CreateReview(plugin.MaxCreator):
|
|||
instance_data["percentSize"] = pre_create_data.get("percentSize")
|
||||
instance_data["rndLevel"] = pre_create_data.get("rndLevel")
|
||||
|
||||
_ = super(CreateReview, self).create(
|
||||
super(CreateReview, self).create(
|
||||
subset_name,
|
||||
instance_data,
|
||||
pre_create_data) # type: CreatedInstance
|
||||
pre_create_data)
|
||||
|
||||
def get_pre_create_attr_defs(self):
|
||||
attrs = super(CreateReview, self).get_pre_create_attr_defs()
|
||||
|
|
|
|||
|
|
@ -19,16 +19,15 @@ class CollectReview(pyblish.api.InstancePlugin,
|
|||
def process(self, instance):
|
||||
nodes = instance.data["members"]
|
||||
focal_length = None
|
||||
camera = None
|
||||
camera_name = None
|
||||
for node in nodes:
|
||||
if rt.classOf(node) in rt.Camera.classes:
|
||||
rt.viewport.setCamera(node)
|
||||
camera = node.name
|
||||
camera_name = node.name
|
||||
focal_length = node.fov
|
||||
|
||||
attr_values = self.get_attr_values_from_data(instance.data)
|
||||
data = {
|
||||
"review_camera": camera,
|
||||
"review_camera": camera_name,
|
||||
"frameStart": instance.context.data["frameStart"],
|
||||
"frameEnd": instance.context.data["frameEnd"],
|
||||
"fps": instance.context.data["fps"],
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import os
|
||||
import pyblish.api
|
||||
from openpype.pipeline import publish
|
||||
from pymxs import runtime as rt
|
||||
from openpype.pipeline import publish
|
||||
from openpype.hosts.max.api.lib import viewport_camera
|
||||
|
||||
|
||||
class ExtractReviewAnimation(publish.Extractor):
|
||||
|
|
@ -30,9 +31,11 @@ class ExtractReviewAnimation(publish.Extractor):
|
|||
"Writing Review Animation to"
|
||||
" '%s' to '%s'" % (filename, staging_dir))
|
||||
|
||||
preview_arg = self.set_preview_arg(
|
||||
instance, filepath, start, end, fps)
|
||||
rt.execute(preview_arg)
|
||||
review_camera = instance.data["review_camera"]
|
||||
with viewport_camera(review_camera):
|
||||
preview_arg = self.set_preview_arg(
|
||||
instance, filepath, start, end, fps)
|
||||
rt.execute(preview_arg)
|
||||
|
||||
tags = ["review"]
|
||||
if not instance.data.get("keepImages"):
|
||||
|
|
@ -49,7 +52,7 @@ class ExtractReviewAnimation(publish.Extractor):
|
|||
"frameEnd": instance.data["frameEnd"],
|
||||
"tags": tags,
|
||||
"preview": True,
|
||||
"camera_name": instance.data["review_camera"]
|
||||
"camera_name": review_camera
|
||||
}
|
||||
self.log.debug(f"{representation}")
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class ExtractThumbnail(publish.Extractor):
|
|||
f"Create temp directory {tmp_staging} for thumbnail"
|
||||
)
|
||||
fps = int(instance.data["fps"])
|
||||
frame = int(instance.data["frameStart"])
|
||||
instance.context.data["cleanupFullPaths"].append(tmp_staging)
|
||||
filename = "{name}_thumbnail..jpg".format(**instance.data)
|
||||
filepath = os.path.join(tmp_staging, filename)
|
||||
|
|
@ -34,7 +35,7 @@ class ExtractThumbnail(publish.Extractor):
|
|||
" '%s' to '%s'" % (filename, tmp_staging))
|
||||
|
||||
preview_arg = self.set_preview_arg(
|
||||
instance, filepath, fps)
|
||||
instance, filepath, fps, frame)
|
||||
rt.execute(preview_arg)
|
||||
|
||||
representation = {
|
||||
|
|
@ -54,11 +55,11 @@ class ExtractThumbnail(publish.Extractor):
|
|||
def get_filename(self, filename):
|
||||
return f"{filename}_thumbnail.0001.jpg"
|
||||
|
||||
def set_preview_arg(self, instance, filepath, fps):
|
||||
def set_preview_arg(self, instance, filepath, fps, frame):
|
||||
job_args = list()
|
||||
default_option = f'CreatePreview filename:"{filepath}"'
|
||||
job_args.append(default_option)
|
||||
frame_option = f"outputAVI:false start:1 end:1 fps:{fps}" # noqa
|
||||
frame_option = f"outputAVI:false start:{frame} end:{frame} fps:{fps}" # noqa
|
||||
job_args.append(frame_option)
|
||||
rndLevel = instance.data.get("rndLevel")
|
||||
if rndLevel:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue