-
Notifications
You must be signed in to change notification settings - Fork 128
Data exchange cameras for 3d Studio Max #4376
Data exchange cameras for 3d Studio Max #4376
Conversation
…and-shaders-export
…and-shaders-export
…nd-shaders-export Feature/op 4668 maya gltf textures and shaders export
Task linked: OP-4244 Data Exchange: cameras |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add simple settings for the extractors so by enabling/disabling them you would set what formats you want to use.
Also beware that it is pulling changes to settings not related to this PR - probably something leaked from the path validator.
for sel in selection_list: | ||
# to avoid Attribute Error from pymxs wrapper | ||
sel_tmp = str(sel) | ||
for cam in self.camera_type: | ||
if sel_tmp.startswith(cam): | ||
validation_msg.append("Camera Found") | ||
else: | ||
validation_msg.append("Camera Not Found") | ||
if "Camera Found" not in validation_msg: | ||
invalid.append(sel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would simplify this:
for sel in selection_list: | |
# to avoid Attribute Error from pymxs wrapper | |
sel_tmp = str(sel) | |
for cam in self.camera_type: | |
if sel_tmp.startswith(cam): | |
validation_msg.append("Camera Found") | |
else: | |
validation_msg.append("Camera Not Found") | |
if "Camera Found" not in validation_msg: | |
invalid.append(sel) | |
for sel in selection_list: | |
# to avoid Attribute Error from pymxs wrapper | |
sel_tmp = str(sel) | |
found = False | |
for cam in self.camera_type: | |
if sel_tmp.startswith(cam): | |
found = True | |
break | |
if not found: | |
self.log.error("Camera not found") | |
invalid.append(sel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think check code-wise is odd to read.
We seem to be comparing the object type to see if it's a camera.
I'd search on how to explicitly get the object type instead of assuming it's the start of the string for str(object)
of a 3ds max object so that we could turn the whole validation .py file into something along these lines:
# -*- coding: utf-8 -*-
import pyblish.api
from openpype.pipeline import PublishValidationError
from pymxs import runtime as rt
def is_valid_camera_node(node):
obj_type = node.type() # or whatever the valid method is for that
return obj_type in {"$Free_Camera", "$Target_Camera",
"$Physical_Camera", "$Target"}
class ValidateCameraContent(pyblish.api.InstancePlugin):
"""Validates Camera instance contents.
A Camera instance may only hold a SINGLE camera's transform
"""
order = pyblish.api.ValidatorOrder
families = ["camera"]
hosts = ["max"]
label = "Camera Contents"
def process(self, instance):
invalid = self.get_invalid(instance)
if invalid:
raise PublishValidationError("Camera instance must only include"
"camera (and camera target)")
def get_invalid(self, instance):
"""Get invalid nodes if the instance is not camera"""
container = rt.getNodeByName(instance.data["instance_node"])
invalid = list()
for child in list(container.Children):
if not is_valid_camera_node(child):
invalid.append(child)
return invalid
Potentially even:
invalid = [obj for obj in container.Children if not is_valid_camera_node(obj)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had another quick peek over the 3ds Max pymxs
docs. I think it should be something along these lines:
One of these:
rt.superClassOf(node)
rt.classOf(node)
And then check it against the actual rt
types:
def is_valid_camera_node(node):
obj_type = rt.classOf(node)
return obj_type in {rt.Free_Camera, rt.Target_Camera,
rt.Physical_Camera, rt.Target}
Having never used 3ds Max I'm not sure that's anywhere remotely valid - but it seemed like that should be roughly it. :) But do consider it pseudocode!
def list_children(self, node): | ||
children = [] | ||
for c in node.Children: | ||
children.append(c) | ||
return children |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't this be replaced with list(node.Children)
?
instance.data["representations"] = [] | ||
|
||
# add extra blacklash for saveNodes in MaxScript | ||
re_max_path = stagingdir + "\\\\" + filename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is done for double backslashes, maybe something like:
re_max_path = os.path.normpath(max_path).replace("\\", "\\\\")
to be sure that they are everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most apps also deal with it fine if you force forward slashes instead - it usually makes the output easier to read so if it works I'd recommend:
os.path.normpath(max_path).replace("\\", "/")
""" | ||
|
||
order = pyblish.api.ExtractorOrder - 0.1 | ||
label = "Extract Almebic Camera" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
label = "Extract Almebic Camera" | |
label = "Extract Alembic Camera" |
) | ||
|
||
|
||
class ExtractCameraFbx(publish.Extractor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it weird maybe that this is ExtractCameraFbx
but the other is ExtractAlembicCamera
? :)
Should they either both be:
ExtractCameraAlembic
ExtractCameraFbx
or:
ExtractFbxCamera
ExtractAlembicCamera
…b.com/moonyuet/OpenPype_fork into feature/OP-4244-Data-Exchange-Cameras
It won't be fixed with #4390 since it still assume the host implementation has its own OCIO settings, see code here. It should either allow the host implementation to NOT have that implemented (I'd prefer that actually!). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OCIO support has to be addressed, but in another PR |
Brief description
Add Camera Family into the 3d Studio Max
Description
Adding Camera Extractors(extract abc camera and extract fbx camera) and validators(for camera contents) into 3dMax
Also add the extractor for exporting 3d max raw scene (which is also related to 3dMax Scene Family) for camera family
Additional info
When assigning the instance to the selected objects, it will pop up the panel to ask you if you are okay for parenting the selected items into the container, you need to click yes.
Testing notes: