Implement Alembic Camera extraction in Houdini - the right way

This commit is contained in:
Roy Nieterau 2018-12-21 23:25:15 +01:00
parent c33e1274f3
commit 3e2b506cf3
5 changed files with 67 additions and 10 deletions

View file

@ -21,11 +21,25 @@ class CreateAlembicCamera(houdini.Creator):
def process(self):
instance = super(CreateAlembicCamera, self).process()
parms = {"use_sop_path": True,
"filename": "$HIP/pyblish/%s.abc" % self.name}
parms = {
"filename": "$HIP/pyblish/%s.abc" % self.name,
"use_sop_path": False
}
if self.nodes:
node = self.nodes[0]
parms.update({"sop_path": node.path()})
path = node.path()
# Split the node path into the first root and the remainder
# So we can set the root and objects parameters correctly
_, root, remainder = path.split("/", 2)
parms.update({
"root": "/" + root,
"objects": remainder
})
instance.setParms(parms)
# Lock the Use Sop Path setting so the
# user doesn't accidentally enable it.
instance.parm("use_sop_path").lock(True)

View file

@ -5,7 +5,8 @@ class CollectOutputSOPPath(pyblish.api.InstancePlugin):
"""Collect the out node's SOP Path value."""
order = pyblish.api.CollectorOrder
families = ["*"]
families = ["colorbleed.pointcache",
"colorbleed.vdbcache"]
hosts = ["houdini"]
label = "Collect Output SOP Path"

View file

@ -0,0 +1,41 @@
import pyblish.api
import colorbleed.api
class ValidateIntermediateDirectoriesChecked(pyblish.api.InstancePlugin):
"""Validate Camera ROP settings."""
order = colorbleed.api.ValidateContentsOrder
families = ['colorbleed.camera']
hosts = ['houdini']
label = 'Camera ROP'
def process(self, instance):
import hou
node = instance[0]
if node.parm("use_sop_path").eval():
raise RuntimeError("Alembic ROP for Camera export should not be "
"set to 'Use Sop Path'. Please disable.")
# Get the root and objects parameter of the Alembic ROP node
root = node.parm("root").eval()
objects = node.parm("objects").eval()
assert root, "Root parameter must be set on Alembic ROP"
assert root.startswith("/"), "Root parameter must start with slash /"
assert objects, "Objects parameter must be set on Alembic ROP"
assert len(objects.split(" ")) == 1, "Must have only a single object."
# Check if the object exists and is a camera
path = root + "/" + objects
camera = hou.node(path)
if not camera:
raise ValueError("Camera path does not exist: %s" % path)
if not camera.type().name() == "cam":
raise ValueError("Object set in Alembic ROP is not a camera: "
"%s (type: %s)" % (camera, camera.type().name()))

View file

@ -6,7 +6,8 @@ class ValidateIntermediateDirectoriesChecked(pyblish.api.InstancePlugin):
"""Validate Create Intermediate Directories is enabled on ROP node."""
order = colorbleed.api.ValidateContentsOrder
families = ['colorbleed.pointcache']
families = ['colorbleed.pointcache',
'colorbleed.camera']
hosts = ['houdini']
label = 'Create Intermediate Directories Checked'

View file

@ -13,7 +13,8 @@ class ValidateOutputNode(pyblish.api.InstancePlugin):
"""
order = pyblish.api.ValidatorOrder
families = ["*"]
families = ["colorbleed.pointcache",
"colorbleed.vdbcache"]
hosts = ["houdini"]
label = "Validate Output Node"
@ -39,10 +40,9 @@ class ValidateOutputNode(pyblish.api.InstancePlugin):
# Check if type is correct
type_name = output_node.type().name()
if type_name not in ["output", "cam"]:
cls.log.error("Output node `%s` is not an accepted type."
"Expected types: `output` or `camera`" %
output_node.path())
if type_name != "output":
cls.log.error("Output node `%s` is not an `output` type node."
% output_node.path())
return [output_node.path()]
# Check if output node has incoming connections