Jump to content

[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
Link to comment
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

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

  • cudarsjanis changed the title to [SOLVED]vector distance to surface for grooming hair

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...