HDK
|
Each OP_Node can have local variables which are defined over the scope of its cook (i.e. active when the cook method has been called). These variables are defined in the OP_Operator constructor (which defines the operator). Currently variables can be floating point or string valued.
The OP_Operator constructor takes an array of CH_LocalVariable's. This class simply contains a string (representing the variable name) and a unique integer (used for evaluation). So, for example, to define 4 local variables for an operator, we might have the following code:
During evaluation of the parameters of the OP_Node, these variables become "active". If the variable is found in an expression, the subclassed version of OP_Parameters::evalVariableValue() will be invoked. It is your responsibility to return a value for the variable in question. For local string variables, override the string version of OP_Parameters::evalVariableValue().
Continuing from the above example, we have:
The code for cooking might look something like:
The reason for setting myCurrPoint
to GA_INVALID_INDEX outside of the loop is that occasionally, it is possible for your evalVariableValue method to be called out of context. The reason for this is complicated, but it has to do with displaying the values of the parameters in the dialog boxes (i.e. the parameters need to be evaluated, but the OP_Node isn't being cooked).