Jump to content

Fiddly vopsop/vex problem

Recommended Posts

I have some geometry with many points.

Each point has an $ATTRIBUTE_SCALAR.

I want to create another vector $ATTRIBUTE_VECTOR that points to the nearest $ATTRIBUTE_SCALAR with the same value.

For example:

-Point 12 has $ATTRIBUTE_SCALAR = 1

In it's neighbourhood we have

Point 11 with $ATTRIBUTE_SCALAR = 0.5

Point 35 with $ATTRIBUTE_SCALAR = 1

Point 785 with $ATTRIBUTE_SCALAR = 0.3

Then we would draw a vector from point 12 to point 35, and store it in $ATTRIBUTE_VECTOR because they have equal $ATTRIBUTE_SCALAR value.

Now, I thought this would be easy peasy with a point cloud and while loop but it turns out we cant write attributes inside such a loop. I get the error below.

It's likely there are multiple possible values for each point's $ATTRIBUTE_VECTOR, but I am not concerned about that for now (although even better if somebody finds a solution for that too!). I just need one vector (any of them). So we don't need to worry about that.

How can I do this?


Edited by Macha
Link to comment
Share on other sites

Hi, Macha, Here is the vex solution, I hate vops concerning point clouds.

#pragma label filename "Lover File"
#pragma label matchattrib "Lover Attribute"
#pragma label direction "Lover Direction"
#pragma label maxsearchlovers "Max Search Lovers"
#pragma label tolerance "Lover Tolerance"

nearest_lover(string filename="",matchattrib="",direction="";int maxsearchlovers = 30;float tolerance = 0.2)
    int maxlovers = min(Npt,maxsearchlovers);
    int handle = pcopen(filename,"P",P,1e+9,maxlovers);
    vector dir = 0;
        float me;
            float lover;
            if (abs(lover-me)<=tolerance)
                vector loverpos;
                dir = loverpos - P;

As for multiple possible values, how about pcfiltering the position of the matched lovers(you need to specify how many similar lovers are tolerated) based on your actual need ?


nearest lover.otl

Edited by ~nature~
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.

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