Jump to content
Sign in to follow this  
anicg

Vex: for loop on point attributes and promote groups

Recommended Posts

I'm trying to turn this into a for loop in Vex, for each point attribute:

Step 1: to take all the points that have >0 and group them, name of the group is the name of the point attribute.

if(@pointattribute1 > 0) @group_pointattribute1 = 1;

if(@pointattribute2 > 0) @group_pointattribute2 = 1;

if(@pointattribute3 > 0) @group_pointattribute3 = 1;

...

Step 2: Promote each of these created point groups to primitive groups

 

Share this post


Link to post
Share on other sites
string ptattribs[] = detailintrinsic(0, "pointattributes");
foreach (string ptattrib; ptattribs){
    int size = pointattribsize(0, ptattrib);
    int type = pointattribtype(0, ptattrib);
    if (size == 1 && type < 2){
        float value = point(0, ptattrib, @ptnum);
        if (value > 0){
            setpointgroup(0, ptattrib, @ptnum, 1);
        }
    }
}

or if you want to be able to specify which attributes  :

string attribmask = chs("attribmask"); 
string ptattribs[] = detailintrinsic(0, "pointattributes");
foreach (string ptattrib; ptattribs){
    if (match(attribmask, ptattrib) ){
        int size = pointattribsize(0, ptattrib);
        int type = pointattribtype(0, ptattrib);
        if (size == 1 && type < 2){
            float value = point(0, ptattrib, @ptnum);
            if (value > 0){
                setpointgroup(0, ptattrib, @ptnum, 1);
            }
        }
    }
}

 

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
Sign in to follow this  

×