Jump to content

compare attributes in VEX


charly

Recommended Posts

Hi,

I'm a newbie in Houdini and vex, with basic knoledge of programming.

I want to create vertex between points from 2 different objects, using vex.

The look will be the Plexus style with the difference that I don't want the points to connect from each other when they are from the same geometry.

I followed a tutorial from Entagma to help me.

 

The question is : How do I get and compare an attribute from 2 points ?

I tried to use pointattrib() to compare an attribute "myobj" that I created before but I don't have enought kwnolege yet to use it well.

 

//__ List of the closest points
int pnt_near[] = nearpoints(0, @P,dist, maxpoints);

foreach(int pnt; pnt_near){
    //__ condition if pnt and @ptnum do not share the same value of the attribute myobj
    if(pointattrib(0, myobj, pnt, 0) != pointattrib(0, myobj, @ptnum, 0) {
        int myprim = addprim(0,"polyline");
        addvertex(0, myprim, pnt);
        addvertex(0, myprim, @ptnum);
    }
}

I don't know if it's the best way, so I'll be happy to hear any solution from you.

Thanks,

Charles

 

plexus_attribute.hip

Link to comment
Share on other sites

Hi Charles,

one straightforward way would be to hook up one geo to the first input slot of your attribwrangle/pointwrangle, the other geo to the second one. Then perform a closest point search on the geo coming in through the second input only. After that you'd have to "copy" the found points into the first geo and use them to create the polylines:

float searchradius = 0.15;
int maxpoints = 5;
int points[];

points = pcfind(1, "P", @P, 2*searchradius, maxpoints);

foreach(int ptj; points)
{
    int prim = addprim(geoself(), "polyline");
    vector newpos = point(1, "P", ptj);
    int newpt = addpoint(geoself(), newpos);
    addvertex(geoself(), prim, @ptnum);
    addvertex(geoself(), prim, newpt);
}

Hope that helps, :)

Cheers,

Moritz

  • Like 3
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...