cudarsjanis Posted December 4, 2019 Share Posted December 4, 2019 (edited) Hi, How could I measure vector distance to another surface like you see here. Not just closest point distance, but distance following the vector. I would like to use this as length point attribute in hairgen to control the shape of groom with geo. Cheers Janis Vector_length.hip Edited December 4, 2019 by cudarsjanis Quote Link to comment Share on other sites More sharing options...
cudarsjanis Posted December 4, 2019 Author Share Posted December 4, 2019 As you can see it doesn`t work with just measuring the distance, if I change the vector direction Vector_length2.hip Quote Link to comment Share on other sites More sharing options...
tamagochy Posted December 4, 2019 Share Posted December 4, 2019 use 'intersect' function to find point on surface along vector 1 Quote Link to comment Share on other sites More sharing options...
cudarsjanis Posted December 4, 2019 Author Share Posted December 4, 2019 3 hours ago, tamagochy said: use 'intersect' function to find point on surface along vector Hi Andrii, Thanks for the reply! So I`m getting somewhere with intersect, but missing still something.. What am I doing wrong here? As when I put addpoint it does creates the new points exactly where I need them, but when I measure distance attribute, something is still not matching. Thanks Janis Vector_length3.hip Quote Link to comment Share on other sites More sharing options...
jimeng20 Posted December 5, 2019 Share Posted December 5, 2019 (edited) Hi there, I would use the intersect vex function, so create a wrangle and wire the tube in second input, and you can write something like: vector pos; vector uvw; int prim = intersect(1, @P, @N, pos, uvw); f@length = distance(@P, pos); @P = lerp(pos, @P, chf("mix")); So the original position is first input, and intersect vex function will take that position and emit ray to your target tube, and of cause the ray direction is the normal, and it will create the hit position and hit uv. So the hit position, which is "pos" in the code is the target intersected P that based on your normal direction. So compute the distance of @P and pos is the length you want. Also you can mix the original P and intersect P to see the blending movement. Hope this would help. Edited December 5, 2019 by jimeng20 1 Quote Link to comment Share on other sites More sharing options...
Aizatulin Posted December 5, 2019 Share Posted December 5, 2019 Hi, normalizing @N in wrangle1 and setting length to 1 in hairgen give me better results. 1 Quote Link to comment Share on other sites More sharing options...
cudarsjanis Posted December 5, 2019 Author Share Posted December 5, 2019 13 hours ago, jimeng20 said: Hi there, I would use the intersect vex function, so create a wrangle and wire the tube in second input, and you can write something like: vector pos; vector uvw; int prim = intersect(1, @P, @N, pos, uvw); f@length = distance(@P, pos); @P = lerp(pos, @P, chf("mix")); So the original position is first input, and intersect vex function will take that position and emit ray to your target tube, and of cause the ray direction is the normal, and it will create the hit position and hit uv. So the hit position, which is "pos" in the code is the target intersected P that based on your normal direction. So compute the distance of @P and pos is the length you want. Also you can mix the original P and intersect P to see the blending movement. Hope this would help. Thanks Jie for explanation, it works!! 8 hours ago, Aizatulin said: Hi, normalizing @N in wrangle1 and setting length to 1 in hairgen give me better results. Spot on Aizatulin! That is what I was missing. So everything was correct in vops, just needed to normalize the N beforehand! Cheers I`ll add the hip here, if anyone needs it, grooming specific shape is so much more controllable than using guideadvect. Vector_length4.hip 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.