From 64c4e5f2bbae767e6f2e126c884853a1fab39eaf Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Wed, 1 Dec 2021 16:42:18 +0100 Subject: [PATCH 1/4] Add static and allView option in imagePlaneLoader --- .../maya/plugins/load/load_image_plane.py | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_image_plane.py b/openpype/hosts/maya/plugins/load/load_image_plane.py index f2640dc2ebe..f7a5a7ea18f 100644 --- a/openpype/hosts/maya/plugins/load/load_image_plane.py +++ b/openpype/hosts/maya/plugins/load/load_image_plane.py @@ -13,10 +13,14 @@ def __init__(self, cameras): self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint) self.camera = None + self.static_image_plane = False + self.show_in_all_views = False self.widgets = { "label": QtWidgets.QLabel("Select camera for image plane."), "list": QtWidgets.QListWidget(), + "staticImagePlane": QtWidgets.QCheckBox(), + "showInAllViews": QtWidgets.QCheckBox(), "warning": QtWidgets.QLabel("No cameras selected!"), "buttons": QtWidgets.QWidget(), "okButton": QtWidgets.QPushButton("Ok"), @@ -31,6 +35,9 @@ def __init__(self, cameras): for camera in cameras: self.widgets["list"].addItem(camera) + self.widgets["staticImagePlane"].setText("Make Image Plane Static") + self.widgets["showInAllViews"].setText("Show Image Plane in All Views") + # Build buttons. layout = QtWidgets.QHBoxLayout(self.widgets["buttons"]) layout.addWidget(self.widgets["okButton"]) @@ -40,6 +47,8 @@ def __init__(self, cameras): layout = QtWidgets.QVBoxLayout(self) layout.addWidget(self.widgets["label"]) layout.addWidget(self.widgets["list"]) + layout.addWidget(self.widgets["staticImagePlane"]) + layout.addWidget(self.widgets["showInAllViews"]) layout.addWidget(self.widgets["buttons"]) layout.addWidget(self.widgets["warning"]) @@ -54,6 +63,8 @@ def on_ok_pressed(self): if self.camera is None: self.widgets["warning"].setVisible(True) return + self.show_in_all_views = self.widgets["showInAllViews"].isChecked() + self.static_image_plane = self.widgets["staticImagePlane"].isChecked() self.close() @@ -65,15 +76,15 @@ def on_cancel_pressed(self): class ImagePlaneLoader(api.Loader): """Specific loader of plate for image planes on selected camera.""" - families = ["plate", "render"] + families = ["image", "plate", "render"] label = "Load imagePlane." representations = ["mov", "exr", "preview", "png"] icon = "image" color = "orange" - def load(self, context, name, namespace, data): + def load(self, context, name, namespace, data, option=None): import pymel.core as pm - + new_nodes = [] image_plane_depth = 1000 asset = context['asset']['name'] @@ -85,18 +96,16 @@ def load(self, context, name, namespace, data): # Get camera from user selection. camera = None - default_cameras = [ - "frontShape", "perspShape", "sideShape", "topShape" - ] - cameras = [ - x for x in pm.ls(type="camera") if x.name() not in default_cameras - ] + cameras = pm.ls(type="camera") camera_names = {x.getParent().name(): x for x in cameras} camera_names["Create new camera."] = "create_camera" window = CameraWindow(camera_names.keys()) window.exec_() camera = camera_names[window.camera] + is_static_image_plane = window.static_image_plane + is_in_all_views = window.show_in_all_views + if camera == "create_camera": camera = pm.createNode("camera") @@ -111,7 +120,7 @@ def load(self, context, name, namespace, data): # Create image plane image_plane_transform, image_plane_shape = pm.imagePlane( - camera=camera, showInAllViews=False + camera=camera, showInAllViews=is_in_all_views ) image_plane_shape.depth.set(image_plane_depth) @@ -119,6 +128,9 @@ def load(self, context, name, namespace, data): context["representation"]["data"]["path"] ) + if is_static_image_plane: + image_plane_shape.detach() + start_frame = pm.playbackOptions(q=True, min=True) end_frame = pm.playbackOptions(q=True, max=True) From 3d6bf6e8c5eb5e8774a231fa6ff77e1422cf26af Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Wed, 1 Dec 2021 18:56:38 +0100 Subject: [PATCH 2/4] change option by options --- openpype/hosts/maya/plugins/load/load_image_plane.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/load/load_image_plane.py b/openpype/hosts/maya/plugins/load/load_image_plane.py index f7a5a7ea18f..d7e61b9c642 100644 --- a/openpype/hosts/maya/plugins/load/load_image_plane.py +++ b/openpype/hosts/maya/plugins/load/load_image_plane.py @@ -82,7 +82,7 @@ class ImagePlaneLoader(api.Loader): icon = "image" color = "orange" - def load(self, context, name, namespace, data, option=None): + def load(self, context, name, namespace, data, options=None): import pymel.core as pm new_nodes = [] From 3c7b622b6e3bf56deb28b12138f980b73a4ef6d6 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Thu, 2 Dec 2021 11:53:32 +0100 Subject: [PATCH 3/4] fix rotation after detach --- .../maya/plugins/load/load_image_plane.py | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_image_plane.py b/openpype/hosts/maya/plugins/load/load_image_plane.py index d7e61b9c642..ecfa8d7bc0a 100644 --- a/openpype/hosts/maya/plugins/load/load_image_plane.py +++ b/openpype/hosts/maya/plugins/load/load_image_plane.py @@ -96,15 +96,23 @@ def load(self, context, name, namespace, data, options=None): # Get camera from user selection. camera = None - cameras = pm.ls(type="camera") - camera_names = {x.getParent().name(): x for x in cameras} - camera_names["Create new camera."] = "create_camera" - window = CameraWindow(camera_names.keys()) - window.exec_() - camera = camera_names[window.camera] - - is_static_image_plane = window.static_image_plane - is_in_all_views = window.show_in_all_views + is_static_image_plane = None + is_in_all_views = None + if data: + camera = pm.PyNode(data.get("camera")) + is_static_image_plane = data.get("static_image_plane") + is_in_all_views = data.get("in_all_views") + + if not camera: + cameras = pm.ls(type="camera") + camera_names = {x.getParent().name(): x for x in cameras} + camera_names["Create new camera."] = "create_camera" + window = CameraWindow(camera_names.keys()) + window.exec_() + camera = camera_names[window.camera] + + is_static_image_plane = window.static_image_plane + is_in_all_views = window.show_in_all_views if camera == "create_camera": camera = pm.createNode("camera") @@ -129,7 +137,9 @@ def load(self, context, name, namespace, data, options=None): ) if is_static_image_plane: + image_plane_shape.setMaintainRatio(True) image_plane_shape.detach() + image_plane_transform.setRotation(camera.getRotation()) start_frame = pm.playbackOptions(q=True, min=True) end_frame = pm.playbackOptions(q=True, max=True) From 931896519c05a423f4630001372bdb72d47da847 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Thu, 2 Dec 2021 12:34:34 +0100 Subject: [PATCH 4/4] add fileName in imagePlane cmd --- openpype/hosts/maya/plugins/load/load_image_plane.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_image_plane.py b/openpype/hosts/maya/plugins/load/load_image_plane.py index ecfa8d7bc0a..eea5844e8b1 100644 --- a/openpype/hosts/maya/plugins/load/load_image_plane.py +++ b/openpype/hosts/maya/plugins/load/load_image_plane.py @@ -128,16 +128,12 @@ def load(self, context, name, namespace, data, options=None): # Create image plane image_plane_transform, image_plane_shape = pm.imagePlane( + fileName=context["representation"]["data"]["path"], camera=camera, showInAllViews=is_in_all_views ) image_plane_shape.depth.set(image_plane_depth) - image_plane_shape.imageName.set( - context["representation"]["data"]["path"] - ) - if is_static_image_plane: - image_plane_shape.setMaintainRatio(True) image_plane_shape.detach() image_plane_transform.setRotation(camera.getRotation())