Jump to content

Using Variables In A Vex Pop


lisux

Recommended Posts

Hi all.

I have just created a new custom POP using VEX, in the VEX Builder, created new POP Type, etc ...

My problem is that I can't use the normal POP variables like $LIFE, $VX, etc ... in my VEX POP operator.

There is any way to enable this variables without using and Attribute POP previously to my VEX POP to make the variable global?

So I want to create local variables in my VEX POP.

Thanks.

Link to comment
Share on other sites

Hi all.

I have just created a new custom POP using VEX, in the VEX Builder, created new POP Type, etc ...

My problem is that I can't use the normal POP variables like $LIFE, $VX, etc ... in my VEX POP operator.

There is any way to enable this variables without using and Attribute POP previously to my VEX POP to make the variable global?

So I want to create local variables in my VEX POP.

Thanks.

The parameters to the VEX POP are evaluated at the beginning of the cook, and not on a per-particle basis.

There are global variables in the POP context for a lot of the common variables:

  1. v = velocity (vector)
  2. age (float)
  3. life (float)
  4. id (int)
  5. pstate (Particle state -- see $HFS/houdini/vex/include/pop.h for the values)
  6. accel (vector)
  7. etc.

See the global variable VOP in the POP context, or type "vcc -X pop" in the shell.

It's also possible to pick up attributes by specifying a parameter that has the same name and type as the attribute you want to evaluate.

Link to comment
Share on other sites

It's also possible to pick up attributes by specifying a parameter that has the same name and type as the attribute you want to evaluate.

In my experience this is the only way to get an attribute to override a parameter on a vex POP.

Luca

Link to comment
Share on other sites

The parameters to the VEX POP are evaluated at the beginning of the cook, and not on a per-particle basis.

There are global variables in the POP context for a lot of the common variables:

  1. v = velocity (vector)
  2. age (float)
  3. life (float)
  4. id (int)
  5. pstate (Particle state -- see $HFS/houdini/vex/include/pop.h for the values)
  6. accel (vector)
  7. etc.

See the global variable VOP in the POP context, or type "vcc -X pop" in the shell.

It's also possible to pick up attributes by specifying a parameter that has the same name and type as the attribute you want to evaluate.

Thanks.

I am not refering to the VEX parameters, I am refering to use global variables like $LIFE or $VX in any of the parameters of my new operator.

When I try to use any global variable to set a value for any parameter of my new POP operator, now in POP context, I get an error, it seems that VEX POP operators can acces to these variables.

I am not trying to use these attributes in the VEX context into the code of my operator, I am trying to use these variables to assing values to any parameter of my new POP operator using expressions.

All the variables that you specify in POP context are local variables, made available by the POP operator itself, the only way to create global variables is using the Attribute POP, is like the Attribute Create SOP but for SOP context.

Link to comment
Share on other sites

Try using the "add attribute" vop, and set it up with the attribute and local variable mapping you want to use, I'm not sure if this will make it available to use in the parameter of the same pop but it might. It may just mean the variable is mapped to a local variable name for use further down the chain, i guess it depends how these relations are set up. Its not something I've ever tried. In sops I've always used the method already suggested, add an attribute with the same name as a parameter and build the expression in there using whatever local variables you need to.

Link to comment
Share on other sites

Thanks.

I am not refering to the VEX parameters, I am refering to use global variables like $LIFE or $VX in any of the parameters of my new operator.

Understood, using variables like $LIFE or $ID or any other variable that you've created will not work in the parameters of the

VEX pop you've created. Say you have a parameter called "myScale" on your vex pop and you want to control this with an expression like rand($ID)+1. Start by putting down an attribute POP before your vex pop and name the attribute "myScale"

and set the value to the afore mentioned expression. because you now have an attribute on your points called "myScale" this will override the parameter on your vex pop called "myScale" on a per point basis.

Hope that helps

Luca

Link to comment
Share on other sites

Ok, thanks for your answers.

I will try the attribute VOP sibarrick.

But IF for example I want to create one attribute, use it in my operator and after it delete this, how I can do this, this is a doubt I have always had.

Some SOP operators like Deform SOP can delete atributes after using them, or the Capture SOP that can assing a color to the CD attribute to previsualize the capture regions but after it this values are not propagated down the chain.

It is possible to do these with only VOPs or VEX, or I have to go to HDK.

I know a little of VOPs but I haven't used the HDK so I don't know if it can do the job.

Thanks.

Link to comment
Share on other sites

I don't think the addattrib vop will work for what you want in this case.

And unfortunately you can't create a local variable use it and then delete it in vops. Even in the hdk there would be no point in doing this generally since you can just stored what you need in a array. In the example of the deform sop the attributes are created in the capture sop and then just used and deleted in the deform sop.

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