Obj Instance not revealing attributes

   3114   3   2
User Avatar
Member
132 posts
Joined: July 2007
Offline
I'm using an Obj Instance node to scatter objects on a terrain.
I'm trying to:
1) Create a custom name for each instance.
2) Add “Extra Attributes” in maya that I can encode with useful meta data from Houdini for each instance.

I've tried adding point, vertex, and detail attributes in Houdini but never see any in Maya on transform or shape nodes.
Are either of these possible without using an nParticle solution?

Thanks.
-Len
User Avatar
Member
818 posts
Joined: Sept. 2013
Offline
I don't think you can output either with Object Instance node. Would you be able to use packed primitive? With packed primitives, the extra attributes would be outputted on the instancer node itself. I've attached a simple instancer example that outputs a string attribute.

Attachments:
test_packed_with_string.hda (18.7 KB)

Andrew / アンドリュー
User Avatar
Member
132 posts
Joined: July 2007
Offline
Thanks for the answer (and example!), Andrew. That works, though it introduces a problem.
I am exploiting the obj Instance node's creation of full transforms for each copy since I'm taking that data, along with the additional meta data, to export into a custom game engine format.
So, I suppose I could encode the necessary transform data into the meta data with each copy? Or something like that?
Still learning Houdini so it's not obvious to me.
Thanks.
User Avatar
Member
818 posts
Joined: Sept. 2013
Offline
The instancer doesn't have the transform of each instance explicitly available. However, it's still possible to query the transform of the instances. Unfortunately, the “instancer” MEL command seems to be broken. However, it's still possible to use Python to access the Maya API. The simple script below will query the “instancer1” object, and print out all the instance paths and matrices.

from maya import OpenMaya as om
from maya import OpenMayaFX as omfx

sel = om.MSelectionList()
sel.add("instancer1")
dag = om.MDagPath()
sel.getDagPath(0, dag)

fn = omfx.MFnInstancer(dag)
count = fn.particleCount()
for i in xrange(count):
paths = om.MDagPathArray()
matrix = om.MMatrix()
fn.instancesForParticle(i, paths, matrix)
print i
print [paths[j].fullPathName() for j in xrange(paths.length())]
print [matrix(j/4, j%4) for j in xrange(16)]
Andrew / アンドリュー
  • Quick Links