Jump to content
phinnonymous

Delete points with opposite normals

Recommended Posts

Posted (edited)

Hi, I am a beginner in Houdini trying to make a house generator in Houdini Apprentice. Everything is working fine, but for the roof I need outer Corners and inner corners. The outer corners work fine, but on the inner corners I have issues with getting the points with the correct normals. 
After getting all the inner points I first tried a fuse, but the normals I got out of that were completely wrong (Maybe I just don`t know how to work with this fuse node properly). As you can see it`s always 3 points at the same position with different normals while 2 of them are exactly opposite, so I tried something different. I created an attribute wrangle and put in this vex code. 

float xPos = @P.x;  
float zPos = @P.z;
float xNorm = @N.x;
float zNorm = @N.z;
float comxPos;
float comzPos;
float comxNorm;
float comzNorm;
    for(int i=0; i < @numpt; i++){
        comxPos = vector(point(0,"P",i)).x; 
        comzPos = vector(point(0,"P",i)).z; 
        comxNorm = vector(point(0,"N",i)).x;
        comzNorm = vector(point(0,"N",i)).z;
        if(xPos == comxPos && zPos == comzPos){        
            if(xNorm + comxNorm ==0 && zNorm + comzNorm == 0){  
                setpointgroup(0,"OppositeNormals",@ptnum,1,"set");
            }
        }
    }


Then I use a blast to delete all points with opposite normals. 
As you can see in the pictures, the code works for a few points, but not all and I don't know why. I would really appreciate if someone could help me. :)

Screenshot (2).png

Screenshot (4).png

Edited by phinnonymous

Share this post


Link to post
Share on other sites

What might be going wrong is because normals and positions work with floats.
Which is a lot harder to compare to each other.

What you could do instead, is actually multiplying your vectors by 1000 or so and then use trunc() to remove the decimals.
This way the check will be a bit more stable. As floats can have many decimals.

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

×