Jump to content
Sign in to follow this  
cudarsjanis

[SOLVED]vector distance to surface for grooming hair

Recommended Posts

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

length.PNG

Vector_length.hip

Edited by cudarsjanis

Share this post


Link to post
Share on other sites
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

length3.PNG

Share this post


Link to post
Share on other sites

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 by jimeng20
  • Like 1

Share this post


Link to post
Share on other sites
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

  • Like 2

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  

×