Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Add static and allView option in imagePlaneLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementHector committed Dec 1, 2021
1 parent 4eaea20 commit 64c4e5f
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions openpype/hosts/maya/plugins/load/load_image_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"])
Expand All @@ -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"])

Expand All @@ -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()

Expand All @@ -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']
Expand All @@ -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")

Expand All @@ -111,14 +120,17 @@ 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)

image_plane_shape.imageName.set(
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)

Expand Down

0 comments on commit 64c4e5f

Please sign in to comment.