Jump to content

Getting Attributes out of a forEach


Recommended Posts

I know it has to be a really simple answer, but I am using a forEach loop to generate procedural data based on each primitive and storing them in their own attributes per prim, so I get as many attributes as there are prims in the geometry. This seems to be working fine, but I can't seem to get the attributes OUT of the forEach SOP. There has to be a really simple thing I just haven't learned yet.

Link to comment
Share on other sites

OK, figured out one piece of the puzzle. I had to change the for type to Each Primitave/Point which is almost working right, unfortunately it is not lining the attributes up. For each loop it is creating the next attribute at the end of the previous one. How do I get it to all line up?

I am attaching what I have so far.

volumePerPrim.hipnc

Edited by Adam Ferestad
Link to comment
Share on other sites

I don't know why you need new primitive attribute per-primitive rather than detail attribute per primitive, but I suppose you have good reasons

here is the way, you need to keep each SOP as first node inside foreach since it is passing you current primitive each iteration so no delete sop is required and you avoid duplications in the resulting mesh

you can also keep measure SOP outside foreach since it will calculate volumes for each prim

so use foreach just to split volumes to different attribs

but if you need custom center for each prim volume calculation then of course move measure SOP inside

volumePerPrim_fix.hipnc

Edited by anim
Link to comment
Share on other sites

The custom center point is actually the point. And I don't really have a purpose for it right now other than figuring out how to do it for when I do come up with one. I am sure that I could use the information to make a faked translucency effect, something that involves the volume between two faces through the mesh. This way each face can know the approximate volume between it and every other face in the mesh. For what I am looking into, the total volume is irrelevant, only the space between two faces. I am sure that I could get an approximation using distance calculations, but the more things I have in my bag of tricks, the better. I am sure I can find a use for it eventually. Your fix doesn't seem to give me what I am looking for. with this object, I am looking for a 24x24 matrix containing all of the volumes between all of the faces. The way my original file has it is giving me a 24x576 matrix with a lot of extra values that I am not needing. But in the 24x24 matrix, there should be a value (0 only if the faces are coplanar) for each of the arguments.

How I am imagining it is to have the view angle affect the transparency of the object based on the volume calculations along the view normal. Most of the numbers for each will be tossed out, but all are needed for calculating an animated scene. I am sure I am reinventing the wheel, but I am only doing it for some principal understanding and not really for any practical purpose right now.

Link to comment
Share on other sites

I'm not sure exactly what is doing it. I just had a sudden light bulb though. It is having to do with it processing the data and merging it after each loop. If I turn off the merge results I get just the information for the last primitive. So when it is merging, it is doing on each pass. I wish I could just merge all of the volume attributes without doing the geometry merge and copy them onto a parallel branch, if that makes any sense. I am sure there has to be a way. The are so many other uses of this, even if it is just to get the relative /comparative information between a primitive and its neighbors. Oh well, that is enough for tonight.

Link to comment
Share on other sites

Thank you so much Tomas, that is exactly what I was looking for. I had a feeling it had something to do with the way the forEach was processing, but I couldn't figure it out. I am sure I will find use for this information later down the road. Maybe I will find something in my Calc 3 class, since it will be dealing almost exclusively with 3 dimensional geometry and the associated math with it. I will be sure to post when I find something that uses this information.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...