Jump to content

How to calculate edge normal like PolyExtrude


bastian

Recommended Posts

Hello there!

How would you calculate the vector depicted as the red arrows in the image.

PolyExtrude node uses it when given an unshared edge group.

I've tried a polyframe's tangentu and tangent crossed in vex with the Normal. Without luck.

It doesn't seem to be just a continuation of each points inner edges (the not unshared ones.... :/ ). But can't wrap my head around where to go with it.

Thanks

mausvgvcpdia1.png

Edited by bastian
Link to comment
Share on other sites

Add a pt. wrangle, you will need to compute 2 vectors:

First vector is a cross between v@N and a vector {0,1,0}.
Second vector is a cross between first vector and v@N.
The second vector should be the one you are looking for.

Cheers

  • Like 1
Link to comment
Share on other sites

@bastian
Prim wrangle (tangent)
 

int vtc[];
vtc = primvertices(0, @primnum);

int n = len(vtc);
int jm1, j, jp1;
int pm1, p, pp1;
vector A,B;
for (int i = 0; i < n; i++)
{
    jm1 = i - 1;
    j = i;
    jp1 = i + 1;
    if (chi('mode') == 0)
    {
        jm1 %= (n-1);
        jp1 %= (n-1);
    } else
    {
        jm1 = max(0, jm1);
        jp1 = min(n-1, jp1);
    }
    pm1 = vertexpoint(0, vtc[jm1]);
    p = vertexpoint(0, vtc[j]);
    pp1 = vertexpoint(0, vtc[jp1]);
    
    A = point(0, 'P', p) - point(0, 'P', pm1);
    B = point(0, 'P', pp1) - point(0, 'P', p);
    setpointattrib(0, 'tangentu', p, normalize(lerp(A, B, 0.5))); 
}

Point wrang-set normal by tangent
 

vector up = chv('up');

v@N = normalize(cross(v@tangentu, up));

if (chi('reverse'))
{
    v@N *= -1;
}

 

  • Like 1
Link to comment
Share on other sites

Damn, had a hunch Odforce was the place to ask this question.

I'm afk but just gotten done testing @islamooss suggestion on a graphing calculator app I found.

@Librarianserve this up! It's a little more than I have patience testing on the app but I'll test it first thing in the morning!

Thank you!

Screenshot_20230215-215820.png

Link to comment
Share on other sites

So I tried your suggestions and both don't work on corners and place where two edges meet, or on edges "facing upwards".
The picture in the post doesn't quite show how inconsistent the mesh is. My mistake.

I've done another pretty "hacky" way of just doing a extra PolyExtrude, wrangle a vector to the extruded edge.
But can imagine it breaking easily with a denser mesh.

I can definitely work with the results here, but would love a consistent method as it isn't the first time I've come across this problem.
Thanks again!

2023-02-16_11-36.png

2023-02-16_11-37.png

2023-02-16_11-39.png

Edited by bastian
comprehension
Link to comment
Share on other sites

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...