Set limit between points when drawing a curve using VEX

   2051   1   2
User Avatar
Member
1 posts
Joined: April 2018
Offline
Hello,

I'm new to Houdini, so please forgive my basic questions.

I have two questions:

1)) I'm using shelf curve tool, to create a curve, I want to set an standard on distance using vex, let's say, every time user clicks to make a point it will automatically will find the direction of the normal and adjust the distance to the previous point. I'm using a wrangle node to do that. It almost works, the only problem is if the previous point has been changed in position, in the for loop it will use the old position not the updated one. Here I attached the code and a screen capture of the scene.

int pnts[] = primpoints(geoself(), 0);

vector pos, pos_prev, up, normal, val;

for (int i = 1; i < 3; i++){
    pos = point(geoself(), 'P', i);
    pos_prev = point(geoself(), 'P', i-1);
    up = set(geoself(), 1, 0);
    setpointattrib(geoself(), 'up', i, up, "set");
    normal = normalize(pos - pos_prev);
    setpointattrib(geoself(), 'N', i, normal, "set");
    float dis = distance(pos, pos_prev);
    
    int had_growth = 0;
    if (dis < 1.0){
        val = pos;
        while (dis < 1.0){
            setpointattrib(geoself(), 'P', i, val, "set");
            pos = point(geoself(), 'P', i);
            val += normal*0.01;
            dis = distance(val, pos_prev);
        }
        had_growth = 1;
        setpointattrib(geoself(), 'dist', i, dis, "set");
    }
}

2) How can I enable curve drawing mode, after I have pressed enter and stooped drawing?

Thanks,
Ehsan

Attachments:
curve_set_limit.jpg (464.6 KB)

User Avatar
Member
205 posts
Joined: Jan. 2014
Offline
Hi, didn't really understand what you want but you got mistakes in your vex code. You want to change the positions of the points so it keeps the certain length? Try to use For loop SOP, not the for loop in vex.
1.
up = set(geoself(), 1, 0);
it's the same as
up = set(0, 1, 0);
the wiki for how to use “set”
https://www.sidefx.com/docs/houdini/vex/functions/set.html [www.sidefx.com]

why do you use “” and '' at the same time?)
setpointattrib(geoself(), 'up', i, up, "set");

2.
shift+LMB
Edited by anon_user_09389530 - Jan. 23, 2020 17:44:46
I contribute to the beauty of this world
https://houdininotes.ivanlarinin.com/ [houdininotes.ivanlarinin.com]
  • Quick Links