Position object along curve based on ramp position
5485 11 5- davidoreilly
- 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
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
- Enivob
- Member
- 2627 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.
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- lfranceschini
- Member
- 72 posts
- Joined: 4月 2016
- Offline
- CYTE
- Member
- 709 posts
- Joined: 2月 2017
- Offline
- lfranceschini
- 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.
- matthias_k
- Member
- 483 posts
- Joined: 12月 2006
- Offline
- matthias_k
- 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 :-)
- matthias_k
- 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 :-)
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
English is not my native language, sorry in advance for any misunderstanding :-)
- ziconic
- 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.
- matthias_k
- Member
- 483 posts
- Joined: 12月 2006
- Offline
- ziconic
- Member
- 73 posts
- Joined: 3月 2020
- Offline
- Herve
- Member
- 40 posts
- Joined: 8月 2018
- Offline
-
- Quick Links