Setting normal length

   1758   2   1
User Avatar
Member
12 posts
Joined: March 2017
Offline
Hey,

i have some normals of differing length that i would like to set to be either -1, 0 or 1. Could someone point me to the right function in a wrangle on how to do this?

I tried using a foreach to loop through each vector component, check if it was more or less than 0.0 and then use either the floor or ceil functions to get what i want - but i don't think using it correctly.

If someone could first show me how to use my code properly to loop through the vector array that would be great - then if anyone has a cleaner solution to show me (im sure there is plenty!) that would be amazing!

Any info / pointers much appreciated!

Thanks in advance,

C


foreach(float num; @N) {
    if(num < 0.0) {
        printf("%d", num);
        num = floor(num);
    }
}

Attachments:
normals.png (8.4 KB)

User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
sign(v@N);

http://www.sidefx.com/docs/houdini/vex/functions/sign.html [www.sidefx.com]
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
12 posts
Joined: March 2017
Offline
Amazing, thanks Konstantin!

If anybody is able to show me how to achieve this with a foreach loop as well that would be great (for future reference)
  • Quick Links