mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
new style vray proxy
This commit is contained in:
parent
68f81b8a3d
commit
36a98caeff
6 changed files with 17 additions and 88 deletions
|
|
@ -1135,7 +1135,6 @@ def get_id(node):
|
|||
if node is None:
|
||||
return
|
||||
|
||||
print("><?>< {}".format(node))
|
||||
sel = om.MSelectionList()
|
||||
sel.add(node)
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from openpype.api import get_project_settings
|
|||
|
||||
|
||||
class VRayProxyLoader(api.Loader):
|
||||
"""Load VRayMesh proxy."""
|
||||
"""Load VRay Proxy with Alembic or VrayMesh."""
|
||||
|
||||
families = ["vrayproxy"]
|
||||
representations = ["vrmesh"]
|
||||
|
|
@ -141,52 +141,16 @@ class VRayProxyLoader(api.Loader):
|
|||
nodes(list)
|
||||
|
||||
"""
|
||||
# Create nodes
|
||||
vray_mesh = cmds.createNode('VRayMesh', name="{}_VRMS".format(name))
|
||||
mesh_shape = cmds.createNode("mesh", name="{}_GEOShape".format(name))
|
||||
vray_mat = cmds.shadingNode("VRayMeshMaterial", asShader=True,
|
||||
name="{}_VRMM".format(name))
|
||||
vray_mat_sg = cmds.sets(name="{}_VRSG".format(name),
|
||||
empty=True,
|
||||
renderable=True,
|
||||
noSurfaceShader=True)
|
||||
|
||||
cmds.setAttr("{}.fileName".format(vray_mesh),
|
||||
filename,
|
||||
type="string")
|
||||
if name is None:
|
||||
name = os.path.splitext(os.path.basename(filename))[0]
|
||||
|
||||
# Create important connections
|
||||
cmds.connectAttr("time1.outTime",
|
||||
"{0}.currentFrame".format(vray_mesh))
|
||||
cmds.connectAttr("{}.fileName2".format(vray_mesh),
|
||||
"{}.fileName".format(vray_mat))
|
||||
cmds.connectAttr("{}.instancing".format(vray_mesh),
|
||||
"{}.instancing".format(vray_mat))
|
||||
cmds.connectAttr("{}.output".format(vray_mesh),
|
||||
"{}.inMesh".format(mesh_shape))
|
||||
cmds.connectAttr("{}.overrideFileName".format(vray_mesh),
|
||||
"{}.overrideFileName".format(vray_mat))
|
||||
cmds.connectAttr("{}.currentFrame".format(vray_mesh),
|
||||
"{}.currentFrame".format(vray_mat))
|
||||
parent = cmds.createNode("transform", name=name)
|
||||
proxy = cmds.createNode("VRayProxy", name=name + "Shape", parent=parent)
|
||||
cmds.setAttr(proxy + ".fileName", filename, type="string")
|
||||
cmds.connectAttr("time1.outTime", proxy + ".currentFrame")
|
||||
|
||||
# Set surface shader input
|
||||
cmds.connectAttr("{}.outColor".format(vray_mat),
|
||||
"{}.surfaceShader".format(vray_mat_sg))
|
||||
|
||||
# Connect mesh to shader
|
||||
cmds.sets([mesh_shape], addElement=vray_mat_sg)
|
||||
|
||||
group_node = cmds.group(empty=True, name="{}_GRP".format(name))
|
||||
mesh_transform = cmds.listRelatives(mesh_shape,
|
||||
parent=True, fullPath=True)
|
||||
cmds.parent(mesh_transform, group_node)
|
||||
nodes = [vray_mesh, mesh_shape, vray_mat, vray_mat_sg, group_node]
|
||||
|
||||
# Fix: Force refresh so the mesh shows correctly after creation
|
||||
cmds.refresh()
|
||||
cmds.setAttr("{}.geomType".format(vray_mesh), 2)
|
||||
|
||||
return nodes, group_node
|
||||
return [parent, proxy], parent
|
||||
|
||||
def _get_abc(self, version_id):
|
||||
# type: (str) -> str
|
||||
|
|
|
|||
|
|
@ -213,13 +213,9 @@ class App(QtWidgets.QWidget):
|
|||
subset_name,
|
||||
asset))
|
||||
|
||||
print(">>> get vray mesh nodes ...")
|
||||
vray_proxies = set(cmds.ls(type="VRayMesh"))
|
||||
print("-" * 40)
|
||||
print(item["nodes"])
|
||||
print(vray_proxies)
|
||||
self.echo("Getting vray proxy nodes ...")
|
||||
vray_proxies = set(cmds.ls(type="VRayProxy"))
|
||||
nodes = set(item["nodes"]).difference(vray_proxies)
|
||||
print(nodes)
|
||||
|
||||
# Assign look
|
||||
if nodes:
|
||||
|
|
|
|||
|
|
@ -68,9 +68,7 @@ def get_selected_nodes():
|
|||
|
||||
selection = cmds.ls(selection=True, long=True)
|
||||
hierarchy = list_descendents(selection)
|
||||
nodes = list(set(selection + hierarchy))
|
||||
|
||||
return nodes
|
||||
return list(set(selection + hierarchy))
|
||||
|
||||
|
||||
def get_all_asset_nodes():
|
||||
|
|
@ -136,11 +134,8 @@ def create_items_from_nodes(nodes):
|
|||
|
||||
id_hashes = create_asset_id_hash(nodes)
|
||||
|
||||
print("*" * 40)
|
||||
print(id_hashes)
|
||||
|
||||
# get ids from alembic
|
||||
vray_proxy_nodes = cmds.ls(nodes, type="VRayMesh")
|
||||
vray_proxy_nodes = cmds.ls(nodes, type="VRayProxy")
|
||||
for vp in vray_proxy_nodes:
|
||||
path = cmds.getAttr("{}.fileName".format(vp))
|
||||
ids = vray_proxies.get_alembic_ids_cache(path)
|
||||
|
|
@ -150,12 +145,9 @@ def create_items_from_nodes(nodes):
|
|||
if not parent_id.get(pid):
|
||||
parent_id.update({pid: [vp]})
|
||||
|
||||
print("adding ids from alembic {}".format(path))
|
||||
print("Adding ids from alembic {}".format(path))
|
||||
id_hashes.update(parent_id)
|
||||
|
||||
print("*" * 40)
|
||||
print(id_hashes)
|
||||
|
||||
if not id_hashes:
|
||||
return asset_view_items
|
||||
|
||||
|
|
@ -196,7 +188,7 @@ def remove_unused_looks():
|
|||
|
||||
host = api.registered_host()
|
||||
|
||||
unused = list()
|
||||
unused = []
|
||||
for container in host.ls():
|
||||
if container['loader'] == "LookLoader":
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ def assign_vrayproxy_shaders(vrayproxy, assignments):
|
|||
index = 0
|
||||
for material, paths in assignments.items():
|
||||
for path in paths:
|
||||
plug = "{}.shaders[{}]".format(proxy, index)
|
||||
plug = "{}.shaders[{}]".format(vrayproxy, index)
|
||||
cmds.setAttr(plug + ".shadersNames", path, type="string")
|
||||
cmds.connectAttr(material + ".outColor",
|
||||
plug + ".shadersConnections", force=True)
|
||||
|
|
@ -274,16 +274,7 @@ def vrayproxy_assign_look(vrayproxy, subset="lookDefault"):
|
|||
|
||||
# Get only the node ids and paths related to this asset
|
||||
# And get the shader edits the look supplies
|
||||
asset_nodes_by_id = {node_id: vrayproxy for node_id in node_ids}
|
||||
print("-" * 80)
|
||||
print(node_ids)
|
||||
print("+" * 80)
|
||||
print(relationships)
|
||||
print("+-" * 40)
|
||||
print(shadernodes)
|
||||
print("+-" * 40)
|
||||
print(asset_nodes_by_id)
|
||||
print("+" * 80)
|
||||
asset_nodes_by_id = {node_id: nodes_by_id[node_id] for node_id in node_ids}
|
||||
edits = list(lib.iter_shader_edits(relationships, shadernodes, asset_nodes_by_id))
|
||||
|
||||
# Create assignments
|
||||
|
|
@ -312,13 +303,3 @@ def vrayproxy_assign_look(vrayproxy, subset="lookDefault"):
|
|||
|
||||
assign_vrayproxy_shaders(vrayproxy, assignments)
|
||||
|
||||
|
||||
# Example usage
|
||||
if __name__ == "__main__":
|
||||
|
||||
# Ensure V-Ray is loaded
|
||||
cmds.loadPlugin("vrayformaya", quiet=True)
|
||||
|
||||
# Assign lookDefault to all V-Ray Proxies
|
||||
for proxy in cmds.ls(sl=True, dag=True, type="VRayProxy"):
|
||||
vrayproxy_assign_look(proxy, subset="lookDefault")
|
||||
|
|
@ -93,9 +93,6 @@ class AssetOutliner(QtWidgets.QWidget):
|
|||
with lib.preserve_selection(self.view):
|
||||
self.clear()
|
||||
nodes = commands.get_all_asset_nodes()
|
||||
print("_" * 40)
|
||||
print(nodes)
|
||||
print("_" * 40)
|
||||
items = commands.create_items_from_nodes(nodes)
|
||||
self.add_items(items)
|
||||
|
||||
|
|
@ -125,7 +122,7 @@ class AssetOutliner(QtWidgets.QWidget):
|
|||
|
||||
# Collect the asset item entries per asset
|
||||
# and collect the namespaces we'd like to apply
|
||||
assets = dict()
|
||||
assets = {}
|
||||
asset_namespaces = defaultdict(set)
|
||||
for item in items:
|
||||
asset_id = str(item["asset"]["_id"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue