Vex interset function not working like i was hoping. why?

   1637   5   0
User Avatar
Member
97 posts
Joined: May 2015
Offline
For the first point 0 its not getting -1 idk why its getting 20 since @N * 10 should be x = 0.0 y = 0.0 z = 10.0. And 1 and 2 are good since the direction of the Normal * 10 gets prim 20 and point 2 gets prim 0. idk why its not work i ahve it on points tried detail doesnt work cause i need for each point to look for a intersect. And when i change it to for instead of foreach it works but when point 2 is wrong and needs to be prim 0 not 20.
Edited by Shadowjonny - May 13, 2019 09:34:54

Attachments:
Screenshot (335)_LI.jpg (1.3 MB)
Screenshot (336).png (805.9 KB)

User Avatar
Member
86 posts
Joined: Jan. 2009
Offline
can you post a hip file?
User Avatar
Member
97 posts
Joined: May 2015
Offline
tony_a
can you post a hip file?

Attachments:
Bunker_Hallway_03-2.hipnc (2.4 MB)

User Avatar
Member
86 posts
Joined: Jan. 2009
Offline
Try changing the line:
i@inter = intersect(0,pos,@N*10,p,uvw);
to:
i@inter = intersect(0,@P,@N*10,p,uvw);

in /obj/Hallway1/X_Positive4
User Avatar
Member
97 posts
Joined: May 2015
Offline
tony_a
Try changing the line:
i@inter = intersect(0,pos,@N*10,p,uvw);
to:
i@inter = intersect(0,@P,@N*10,p,uvw);

in /obj/Hallway1/X_Positive4

WOW lol that worked. Thank you, why tho? isnt @P a vector getting the position of the run off, like points or prim? shouldnt the first one work also?
User Avatar
Member
2041 posts
Joined: Sept. 2015
Offline
It is because you have a foreach loop within a point wrangle running over points.

So that means you are (in this case as defined by your coding) looping 3 times for every point.

And in each case the final value of the attribute you are applying the results to (i@inter) is looking from point number 2.(it's the last index number of the loop, so your results are always looking from point number 2 - ‘pos’).

However, while your doing that loop you are using @N for direction to look, which belongs to the current ‘@ptnum’ being run over for the foreach loop, and not ‘pos’.

So changing it to @P means even though your are still looping 3 times and outputting from the last iteration of that loop,

your still only using @P for the current @ptnum value and the current @N value belonging to that point.

As you could surmise then, if these are the results your looking for, you can do away with the loop altogether and just use your line:

i@inter = intersect(0,@P,@N*10,p,uvw);

In all these cases when using the intersect function as you have it set up, your assigning an existing point in the scene/wrangle to look from.

And since the intersect finds the first intersection only, it will find in most cases(depending on the look direction) the actual points' primitive it belongs to, the one(point) used as looking from.

This can create problems depending on the direction.

In your original unchanged version, look at the current normal of the point being run over. And look at the results(prim found) of your i@inter attribute(which is always for point number 2).

You will see it finds point number 2s' prim(20) when the normal(direction to look) is perpendicular to the current point prim but not when it is parallel and looking away from the primitive.

This should give insight into how the algorithm of the function does its' search, and to be careful in how one sets up their code when using intersect.

Sometimes it is better to use the wrangle in detail mode or also even intersect_all function(using an index to the returned array to get the specific results).
Edited by BabaJ - May 14, 2019 10:02:21
  • Quick Links