Jump to content

Copy-stamp in ForEach SOP, or Control individual points of copied grou


Biohazard9012

Recommended Posts

Hey guys,

 

I'm trying to find a way to create a tool to allow the user to dynamically create or delete parallel lines through the parameter interface, while allowing them to control the points through a Ramp Control, which I have successfully done. The problem I'm running into is in using a Copy node to create multiple lines, and then being able to still manipulate each line's points individually through it. I tried using a ForEach node, but when I try to copy-stamp from an above level Copy node, it always returns the default value of the stamp function, which has lead me to believe you can't do that. So I'm back to trying to figure out how to use a Copy node and manipulating each group that outputs from it.

It's easier to explain by posting the .hip file than taking photos. And it is a very large scene, just fyi. Using the "Add Curves" parameters creates/deletes copies.

Thanks

 

H14

User-Controllable Copied Lines.hipnc

Link to comment
Share on other sites

I don't think that the `Copy` node is the right approach in this case. You could instead iterate over the multi parameter and then define the corresponding curve within each iteration.

 

I've modified your scene to do just that.

 

Note that the way it's set up works well if you use linear interpolation within your ramps, but if you'd like to use another type of interpolation, then you would have to sample your ramps.

 

User-Controllable Copied Lines-Edit1.hipnc

Link to comment
Share on other sites

I don't think that the `Copy` node is the right approach in this case. You could instead iterate over the multi parameter and then define the corresponding curve within each iteration.

 

I've modified your scene to do just that.

 

Note that the way it's set up works well if you use linear interpolation within your ramps, but if you'd like to use another type of interpolation, then you would have to sample your ramps.

 

Hey Christopher,

 

I appreciate the help and was just able to take a look at the file. Do you think you could help explain what you did so I can understand the VEX you used better?

Link to comment
Share on other sites

Sure, here's a breakdown:

- I kept the multiparm that you've made, which is nice to define a variable number of curves with their corresponding parameters.

- the `ForEach` node iterates over the number of curves defined in the multiparm.

- within each iteration of the `ForEach` node, a new curve is defined. The VEX code might look scary but is actually very simple—most of the lines of code are there to retrieve the values from the multiparm, the job is done only in the 2 last lines. The variables `pos` and `value` are defined in the range [0, 1], as per the ramp, so we need to scale them according to the length and min/max values. `(pos - 0.5) * length` is a factorization of `length * pos - length * 0.5`, that is to make your curve match the `length` parameter while being centered, and `fit(value, 0, 1, min, max)` should be obvious enough for you since you tried to do something similar.

 

Keep in mind that the `Point Wrangle` node runs the code once per input point, that is the number of points defined in `line1`, and thus matching the number of points from the profile curve ramp, which makes it possible to make an association between the point number (@ptnum) and the ramp point index.
Link to comment
Share on other sites

 

Sure, here's a breakdown:
- I kept the multiparm that you've made, which is nice to define a variable number of curves with their corresponding parameters.
- the `ForEach` node iterates over the number of curves defined in the multiparm.
- within each iteration of the `ForEach` node, a new curve is defined. The VEX code might look scary but is actually very simple—most of the lines of code are there to retrieve the values from the multiparm, the job is done only in the 2 last lines. The variables `pos` and `value` are defined in the range [0, 1], as per the ramp, so we need to scale them according to the length and min/max values. `(pos - 0.5) * length` is a factorization of `length * pos - length * 0.5`, that is to make your curve match the `length` parameter while being centered, and `fit(value, 0, 1, min, max)` should be obvious enough for you since you tried to do something similar.
 
Keep in mind that the `Point Wrangle` node runs the code once per input point, that is the number of points defined in `line1`, and thus matching the number of points from the profile curve ramp, which makes it possible to make an association between the point number (@ptnum) and the ramp point index.

 

Alright I was able to understand the VEX pretty well, I have a basic knowledge of C++ which helps, I was just a bit confused on to how you applied it. Going through this method I've been having trouble figuring out how to translate each copy of the line over, because every time I try to translate it it moves the entire object over together and not individually.

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