I would like to extend the attribute of the point labeled 1 on the image in one direction by using normal or something.
Is there any good way to do this in vex?
Would it be possible to expand attribute in one direction?
945 3 1- Ha-ya
- Member
- 5 posts
- Joined: May 2018
- Offline
- animatrix_
- Member
- 4495 posts
- Joined: Feb. 2012
- Offline
Hi,
You can get point neighbours using:
Create a vector from the current point to either point and see if it's in the same direction as your desired direction using the dot product, and only accept that point in your neighbours array and keep repeating it.
You can get point neighbours using:
neighbours ( 0, @ptnum );
Create a vector from the current point to either point and see if it's in the same direction as your desired direction using the dot product, and only accept that point in your neighbours array and keep repeating it.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
- Ha-ya
- Member
- 5 posts
- Joined: May 2018
- Offline
- olivierth
- Member
- 1004 posts
- Joined: April 2017
- Offline
I havent tested it but it would be something like this:
You can either repeat it with a for loop in this same wrangle or a for-each loop (sops) if you are lazier.
This method will cause problem if your curve turns too much or if both neighbour points are in the right direction. You can simply go by point number and set your attrib to 1 if its neighbour point value is lower than @ptnum.
int nbrs[] = neighbours(0, @ptnum); vector direction = set(-1,0,0); foreach(int pt; nbrs) //find what neighbour is in the right direction { vector nbrpos = point(0, "P", pt); vector nbrN = normalize(nbrpos - @P) float angleToDirection = degrees(acos(dot(direction, nbrN))); if(angleToDirection < 90) { setpointattrib(0, "myAttrib", pt, 1, "set"); break; } }
You can either repeat it with a for loop in this same wrangle or a for-each loop (sops) if you are lazier.
This method will cause problem if your curve turns too much or if both neighbour points are in the right direction. You can simply go by point number and set your attrib to 1 if its neighbour point value is lower than @ptnum.
Edited by olivierth - Feb. 3, 2023 17:52:30
-
- Quick Links