Position object along curve based on ramp position

   5479   11   5
User Avatar
Member
1 posts
Joined: 9月 2019
Offline
Hi All,

Bit of a noob question that im struggling with, any help greatly appreciated.

Im trying to position an object along a curve based on ramp position. Basically a visual marker to indicate where along the curve the ramp is selecting. Can be any object (sphere, perpendicular line, whatever). And for it to add more of these ‘markers’ for each ramp point that gets added, and of course updated if the point is moved.

Any ideas?

Many thanks
David
User Avatar
Member
2626 posts
Joined: 6月 2008
Offline
A ramp does not make sense, but a slider does. You can use the Carve node to shorten or extend a curve to its maximum length. The last point on the curve is point #0. If you delete all other points, you will have a single point moving along the curve. Copy an object to it to visualize where the slider will leave you along the curve.

Attachments:
point_on_line.gif (35.4 KB)
ap_point_on_line_021220.hiplc (159.6 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
72 posts
Joined: 4月 2016
Offline
Correct me if I'm wrong, but I think the goal was to have multiple points on the curve at once? Here is an example where each point on the curve corresponds to the x position of the ramp point.

Attachments:
ramp-to-curve.gif (937.5 KB)
ramp-to-curve.hip (91.1 KB)

User Avatar
Member
709 posts
Joined: 2月 2017
Offline
Hey lfranceschini,

this is a really nice technique! I would like to use it for custom digital assets.
Do you know how one also can get the “elevation” value of each ramp point?

Thank You
CYTE
Edited by CYTE - 2020年2月13日 04:11:11
User Avatar
Member
72 posts
Joined: 4月 2016
Offline
If you look at the python docs for a ramp python object [www.sidefx.com] you will see a values method which will return the values of the ramp points. Each value in the values tuple corresponds to a key in the key tuple.
User Avatar
Member
483 posts
Joined: 12月 2006
Offline
Same as lfranceschini's solution,
but as one wrangle.

Added “ramp_val” attribute… maybe you need it.

Eg.: Add a point wrangle after the “copy_ramp” with
@P.y = @P.y + @ramp_val;
Edited by matthias_k - 2020年2月13日 17:13:38

Attachments:
Copy_Wrangle.hip (82.7 KB)
Copy_Wrangle_Screen.jpg (633.2 KB)

English is not my native language, sorry in advance for any misunderstanding :-)
User Avatar
Member
483 posts
Joined: 12月 2006
Offline
Maybe better code, with all ramp infos as attributes
string rampname = "myramp";
// use next line to create a ramp, you can not use variable as name here
// float ramp = chramp("myramp",0);

// see below, we add 1 because of the ramp marker numbers
// they start at 1 not at 0, i've added it here and for loop starts with  i = 1
float count = ch(rampname) + 1;

for (int i = 1; i < count; i++) {
    // create prefix, a markers name is rampname + markernumber
    // eg. myramp1, myramp2, ...
    string ramp_pt = rampname + itoa(i);
    // then add the value to grab, hover the Position label to see the name
    // eg. myramp1pos
    float ramp_pt_pos = ch(ramp_pt + "pos");
    float ramp_pt_value = ch(ramp_pt + "value");
    float ramp_pt_interp = ch(ramp_pt + "interp");
    // set the primuv vector to grab
    vector uv = set(ramp_pt_pos,0,0);
    vector pos = primuv(1, "P", 0, uv);
    // create a new point
    int pt = addpoint(0,set(pos));
    // and add desired attributes or groups
    setpointattrib(0,"ramp_pos", pt, ramp_pt_pos);
    setpointattrib(0,"ramp_val", pt, ramp_pt_value);
    setpointattrib(0,"ramp_interp", pt, ramp_pt_interp);
    setpointgroup(0, "copy", pt , 1);
}
Edited by matthias_k - 2020年2月14日 01:30:52
English is not my native language, sorry in advance for any misunderstanding :-)
User Avatar
Member
483 posts
Joined: 12月 2006
Offline
As Enivob said, a slider makes more sense,
because you can then move “copy 3 before copy 2” on your path :-)

example how you can add arbitary attributes too via mutiparam add.
It's only a sketch :-)
Edited by matthias_k - 2020年2月15日 15:58:49

Attachments:
Copy_Wrangle_better_001.hip (98.9 KB)
Slider_solution.jpg (751.2 KB)

English is not my native language, sorry in advance for any misunderstanding :-)
User Avatar
Member
73 posts
Joined: 3月 2020
Offline
matthias_k[code
string ramp_pt = rampname + itoa(i);

float ramp_pt_pos = ch(ramp_pt + “pos”);
float ramp_pt_value = ch(ramp_pt + “value”);
float ramp_pt_interp = ch(ramp_pt + “interp”);

Do you happen to know where these “secret” ramp channel names (name+N+pos|value|interp) are documented? I can't find any references to them in the Houdini docs.
User Avatar
Member
483 posts
Joined: 12月 2006
Offline
I've simply hovered the “Param Label”

Attachments:
Label_Name.jpg (42.9 KB)

English is not my native language, sorry in advance for any misunderstanding :-)
User Avatar
Member
73 posts
Joined: 3月 2020
Offline
Thanks!! I submitted a documentation RFE for this to be added.
User Avatar
Member
40 posts
Joined: 8月 2018
Offline
oh, I add my thanks for this, matthias_k, as I was just struggling a bit with multiparams.
Edited by Herve - 2020年5月5日 09:15:11
  • Quick Links