Foreach sop again

   9116   12   3
User Avatar
Member
66 posts
Joined: 7月 2005
Offline
I'm digging information about foreach and seems i'm starting to understand how it works, but 2 things still unclear:
1. how to get object connected to foreach inputs? opinput() or something else?
And is it possible to refer to those input “sockets” from inside the foreach?
2. how to get coordinates of a point currently processed inside of foreach sop?
I've got a number of groups with single point in each, made with “partition”, im iterating over these groups, but how to get position of that single point that is currently being processed?

Update: fixed mistake, partition, not attribcreate. Attribcreate i tried for iterating over point attributes.
Edited by - 2012年3月24日 11:48:49
wbr, Mudvin
User Avatar
Member
112 posts
Joined: 2月 2010
Offline
If you are inside foreach sop and you want to access the node connected to any of the inputs of foreach sop use
opinputpath(“..”,0) - gives the path of the node connected to the 0th input of foreach. (Look at the output of font1 node in foreach sop )
Similarly instead of 0 if you write 1, you will get path of the node connected to the 1st input of foreach and so on.

All your groups will be processed on every frame by foreach sop so I dont think you can access current group being processed but I am not sure , I should say I dont know if it is possible.

But then you can make foreach operator to work on different group on different frame and so you know which group or point is processed and you can get its coordinates easily. I dont know if this is what you want.

File is created in H 11
I hope this helps you.

Attachments:
FOREACH.hipnc (72.4 KB)

User Avatar
Member
112 posts
Joined: 2月 2010
Offline
Hi Mudvin.
I think you can use stop condition in foreach sop in H 12 for what you want to do. Check this file. Press play.

Attachments:
H12_FOREACH_STOP_CONDITION.hipnc (69.0 KB)

User Avatar
Member
66 posts
Joined: 7月 2005
Offline
Examining your files at the moment, just want to explain: imagine a simple grid wired into foreach sop, what i want, is, say, to create sphere or box at each grid point location.
Just for some reason i cannot wire network to “each” inside, and have to get that point coords with expression.
wbr, Mudvin
User Avatar
Member
8839 posts
Joined: 7月 2007
Online
any reason not using Copy SOP?

whatever are your reasons, here is scene using ForEach to copy object to each point of another

Attachments:
foreach_copy.hip (56.1 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
66 posts
Joined: 7月 2005
Offline
It's not a simple copy, it's a dynamic asset that uses 2 input points, so i have to know position of each point im iterating in space.

in Maya i would do something like:

for($i=0; $i<$numPts; $i++)
{
float $a = `xform -q -a -ws -t pSphereShape1.vtx`;
line(0,0,0, $a, $a, $a);
}
wbr, Mudvin
User Avatar
Member
66 posts
Joined: 7月 2005
Offline
Actually….i just thought that i probably could stamp point coordinates in that asset, so seems copy is totally usable. Going to try it as well.
Thanks for input guys, i'm gonna post that thing i'm doing when everything will work
wbr, Mudvin
User Avatar
Member
8839 posts
Joined: 7月 2007
Online
so something like this? it's actually still the same

Attachments:
foreach_connect.hip (55.0 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
66 posts
Joined: 7月 2005
Offline
Exactly. By the way i didn't know “add” can also make lines.

Thanks for help!
wbr, Mudvin
User Avatar
Member
66 posts
Joined: 7月 2005
Offline
Here's the results, i was doing that just for training purposes, think the next one is gonna be easier to implement as a python sop.

Attachments:
lightning4_foreach.hipnc (80.3 KB)

wbr, Mudvin
User Avatar
Member
40 posts
Joined: 7月 2009
Offline
FYI that hip file has an otl which isnt embedded so cant read the file correctly.
User Avatar
Member
66 posts
Joined: 7月 2005
Offline
Aha, i wasn't sure if houdini embeds OTLs into hip files or not. Here's hda.

Basically it's a very simple procedural lightning with randomized seed based on destination point coord, so every lightning in a pack differs from others.
Probably nothing new for you guys, it was made to refresh my houdini knowledge. Probably i will make more advanced version with forking as a python sop soon, seems it's easier for to just write little lightning(src, dst) function than make all these node trees.

Attachments:
Joss1.otl (8.9 KB)

wbr, Mudvin
User Avatar
スタッフ
2540 posts
Joined: 7月 2005
Offline
ForEach SOP uses the same mechanism that Copy SOP stamping does. Stamping in Copy vs ForEach, use which is more comfortable for you. ForEach can be easier for others to understand (logic encapsulated in the subnet). You can still use the stamp function outside the ForEach SOP same as Stamping with Copy SOP using the stamp() function.
See the attached example file of the ForEach SOP set up to do a basic Copy Stamp operation with the stamp() function outside the ForEach SOP.
That should get the ideas flowing.

—-

Embedding OTLs inside the hip file is an option in the Operator Type Manager.
Windows > Operator Type Manager > Configuration Tab

—-

As for connecting particle systems to create either lines or surfaces, have a look at the Wispy Smoke tool in the FX Tool kit. You can download the FX Tools from any Shelf in Houdini. Press the “+” to the right of the tabs on a shelf and choose Download Shelf. Find the FX Tools and download them. Then have a look at the Wispy Smoke asset.

Attachments:
foreach_as_copy_stamping.hip (62.7 KB)

There's at least one school like the old school!
  • Quick Links