Jump to content

Plus button for dynamically adding parameters

konstantin magnus

Recommended Posts

I am currently creating a little HDRI studio inside COP land. The user should be enabled to freely add "light sources" (aka spots and rectangles on the image canvas).


How can I integrate a plus button in my parameter field? How can I duplicate parameters with it? Here is a mockup:



Instead of adding more and more nodes, I would like to fill up arrays holding all spot positions, light intensities etc.


Link to comment
Share on other sites

you can do it comfortably in vex since you can get parameter values using ch*("path/to/parm")

however COP VEX context is older and I don't see a way to define Evaluation node path like in Attrib VOP so you'll probably have to use absolute paths and for that you can use opfullpath('.')

the code will look something like this (careful, I added print just to test, don't use print on large images):

string op = opfullpath(".");
int lights = chi(op + "/lights");
for(int i=0; i<lights; i++){
    string si = itoa(i);
    vector spot_pos = chv(op + "/spot_pos" + si);
    float spot_size = chf(op + "/spot_size" + si);
    float spot_int = chf(op + "/spot_int" + si);
    vector spot_color = chv(op + "/spot_color" + si);
    printf("\nLight%d: pos: %g | size: %f | int: %f | color: %g ", i, spot_pos, spot_size, spot_int, spot_color);



  • Like 1
Link to comment
Share on other sites

  • 2 years later...

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