Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
spectronaut

Point Wrangle inside foreach loop

I'll get right to it. I am running a foreach loop on a bunch of prims. 
For each prim I scatter a number of points. Still within the foreach loop, I run a point wrangle on those points. In the wrangle I run intersect on each of the points and if one hits I want to set an attribute on the prim (foreach loop peice) that the points were scattered on. In the end I don't need the scattered points, I just need the prims output with the attribute @keepage.
What I cant figure out is how to set up the forloop so that this works. 
 

Share this post


Link to post
Share on other sites

Obviously this loop will output points. The VEX for the wrangle "secondaryIntersect" seems valid, but I have no way of applying the attribute to the iteration pieces (primitives).

loopage.PNG

VEX for "secondaryIntersect" running over primitives.

vector p;
vector hitprimuvw;
vector srcpt;


i@ptrefprim = prim(2, "refprim", 0);
srcpt = v@P + (normalize(v@rdir)*2);
i@hitprim  = intersect(1, srcpt, v@rdir, p, hitprimuvw);

if(@hitprim<5){
setprimattrib(2, "keepage", 0, 1, "set");      
}

Share this post


Link to post
Share on other sites

Given what you currently have, you could make secondaryIntersect set a detail attribute on itself that marks whether or not an intersection happened. Then, disconnect the output of secondaryIntersect from the foreach_end. Drop an attribute create, linking foreach_begin -> secondaryIntersect -> foreach_end, and set the attribute create to look at the detail attribute that secondaryIntersect set, thus marking the current prim with whether or not the intersection happened.

Might not necessarily be the most computationally efficient way, but maybe the easiest thing to do given the current setup.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0