🎨 simple bgeo publishing in houdini

This commit is contained in:
Ondrej Samohel 2023-03-07 17:24:58 +01:00
parent ce9bbe777a
commit fbf1b9e659
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
4 changed files with 121 additions and 4 deletions

View file

@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
"""Creator plugin for creating pointcache bgeo files."""
from openpype.hosts.houdini.api import plugin
from openpype.pipeline import CreatedInstance
from openpype.lib import EnumDef
class CreateBGEO(plugin.HoudiniCreator):
"""BGEO pointcache creator."""
identifier = "io.openpype.creators.houdini.bgeo"
label = "BGEO PointCache"
family = "bgeo"
icon = "gears"
def create(self, subset_name, instance_data, pre_create_data):
import hou
instance_data.pop("active", None)
instance_data.update({"node_type": "geometry"})
instance_data["bgeo_type"] = pre_create_data.get("bgeo_type")
instance = super(CreateBGEO, self).create(
subset_name,
instance_data,
pre_create_data) # type: CreatedInstance
instance_node = hou.node(instance.get("instance_node"))
file_path = "{}{}".format(
hou.text.expandString("$HIP/pyblish/"),
"{}.$F4.{}".format(
subset_name,
pre_create_data.get("bgeo_type") or "bgeo.sc")
)
parms = {
"sopoutput": file_path
}
if self.selected_nodes:
parms["soppath"] = self.selected_nodes[0].path()
# try to find output node
for child in self.selected_nodes[0].children():
if child.type().name() == "output":
parms["soppath"] = child.path()
break
instance_node.setParms(parms)
instance_node.parm("trange").set(1)
def get_pre_create_attr_defs(self):
attrs = super().get_pre_create_attr_defs()
bgeo_enum = [
{"option": "bgeo", "value": "bgeo", "label": "uncompressed bgeo (.bgeo)"},
{"option": "bgeosc", "value": "bgeosc", "label": "BLOSC compressed bgeo (.bgeosc)"},
{"option": "bgeo.sc", "value": "bgeo.sc", "label": "BLOSC compressed bgeo (.bgeo.sc)"},
{"option": "bgeo.gz", "value": "bgeo.gz", "label": "GZ compressed bgeo (.bgeo.gz)"},
{"option": "bgeo.lzma", "value": "bgeo.lzma", "label": "LZMA compressed bgeo (.bgeo.lzma)"},
{"option": "bgeo.bz2", "value": "bgeo.bz2", "label": "BZip2 compressed bgeo (.bgeo.bz2)"}
]
return attrs + [
EnumDef("bgeo_type", bgeo_enum, label="BGEO Options"),
]

View file

@ -8,13 +8,12 @@ import pyblish.api
from openpype.hosts.houdini.api import lib
class CollectFrames(pyblish.api.InstancePlugin):
"""Collect all frames which would be saved from the ROP nodes"""
order = pyblish.api.CollectorOrder
label = "Collect Frames"
families = ["vdbcache", "imagesequence", "ass", "redshiftproxy"]
families = ["vdbcache", "imagesequence", "ass", "redshiftproxy", "bgeo"]
def process(self, instance):
@ -35,7 +34,9 @@ class CollectFrames(pyblish.api.InstancePlugin):
output = output_parm.eval()
_, ext = lib.splitext(output,
allowed_multidot_extensions=[".ass.gz"])
allowed_multidot_extensions=[
".ass.gz", ".bgeo.sc", ".bgeo.gz",
".bgeo.lzma", ".bgeo.bz2"])
file_name = os.path.basename(output)
result = file_name

View file

@ -0,0 +1,50 @@
import os
import pyblish.api
from openpype.pipeline import publish
from openpype.hosts.houdini.api.lib import render_rop
import hou
class ExtractBGEO(publish.Extractor):
order = pyblish.api.ExtractorOrder
label = "Extract BGEO"
hosts = ["houdini"]
families = ["bgeo"]
def process(self, instance):
ropnode = hou.node(instance.data["instance_node"])
# Get the filename from the filename parameter
output = ropnode.evalParm("sopoutput")
staging_dir = os.path.dirname(output)
instance.data["stagingDir"] = staging_dir
file_name = os.path.basename(output)
# We run the render
self.log.info("Writing bgeo files '%s' to '%s'" % (file_name,
staging_dir))
# write files
ropnode.parm("execute").pressButton()
output = instance.data["frames"]
self.log.debug(f"output: {output}")
if "representations" not in instance.data:
instance.data["representations"] = []
representation = {
'name': 'bgeo',
'ext': instance.data["bgeo_type"],
'files': output,
"stagingDir": staging_dir,
"frameStart": instance.data["frameStart"],
"frameEnd": instance.data["frameEnd"]
}
instance.data["representations"].append(representation)

View file

@ -132,7 +132,8 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
"mvUsdOverride",
"simpleUnrealTexture",
"online",
"uasset"
"uasset",
"bgeo"
]
default_template_name = "publish"