検索 - User list
Full Version: Orienting Point Normals
Root » Houdini Indie and Apprentice » Orienting Point Normals
iamrheonmaro24

Good day! I would like to know how I could orient my point normals to face straight? Currently my normals are slightly tilted from what they are looking at, and I would love to know how I could snap it into grid direction (see green for supposedly correct normal direction)

Any simple approach? I tried rounding it off but it clearly did not work at all (due to most directions rounding off to 0)

Any help would be appreciated, thank you!
animatrix_
Hi,

You can use Orientation Along Curve SOP, where X Axis will give you what you want. Make sure to choose the right Tangent Type for your use case.

mmwizard
Hi Iam,

Getting the correct normals for polylines can be tricky.
It all depends on the point order. So ensure that you're point order is correct. see image

in this case each primitive has 2 points in clockwise order. if you flip point number 2 and 3, the normal will be in opposite direction.
so using this script, in a primitive wrangle, you will get the correct normals.
/*
    calculate outer Normal direction in primitive context
    asuming 
        that each primitive has 2 points
        and all primitive points are in clockwise order
*/

//get the points of each primitive (should be 2 points)
int pts[] = primpoints(0, @primnum);

//get the position of each primitive point
vector p0 = point(0, "P", pts[0]);
vector p1 = point(0, "P", pts[1]);

//calculate direction by subtracting and make them a length of 1 by normalizing
vector tu = normalize(p1 - p0);//to flip the normal: use  p0 - p1

//the up direction
vector up = {0,1,0};

//calculate N with the cross product
vector n = cross(up, tu);

//set the Normal attribute
setpointattrib(0, "N", pts[0], n, "set");
setpointattrib(0, "N", pts[1], n, "set");
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB