Jump to content

Of statements not responding


Blacklisted_Guy

Recommended Posts

Hello everyone,

I'm fairly new to vex and am currently working on adding normals to certain points.
For this I'm using this script in a point wrangle node.

int count = neighbourcount(0, @ptnum);
float xpos = @P.x;

if (count == 1){
    setpointgroup(geoself(), "borderGroup", @ptnum, 1, "set");
    if (xpos > 0){
        addattrib(geoself(), "point", "N", {-1,0,0});
    }
    if (xpos < 0){
        addattrib(geoself(), "point", "N", {1,0,0});
    }
    
}

But, for some reason unless the X value is 10 or -10 it always chooses the  xn = 1.
Not sure why. (The "xpos < 0" used to be an "else" but I changed it to check it it would work).

A big thank you in advance!

Link to comment
Share on other sites

There is no X or xn variables in your snippet, so, I hope I understand you correctly. addattrib function acts like Attribute Create SOP, it creates attribute on geometry, and value argument specifies default value, which cannot vary across different entities of same geo (if you merge with some other geo, that what new points will get as initial values). You place it once at the beginning of the code and use settattrib when setting values for certain entities. Since you setting everything on @ptnum (on current entity), just use normal wrangle syntax for everyting. Manual adding/setting used for point attributes when run in Detail, for example. The code may look like this:

if (neighbourcount(0, @ptnum) == 1)
{
    @group_border = true;
    if (@P.x > 0)
    {
        @N = {-1,0,0};
    }
    else
    {
        @N = {1,0,0};
    }
}

@N will be added automatically with default value of {0,0,0} for every point with neighbourcount other than one. xpos < 0 not behave same as else there, same will be for xpos <= 0.

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