HDK
|
The following steps are necessary to create a custom VOP node:
Each of these steps is discussed in more detail below. Alternatively, a full example can be found in VOP/VOP_Switch.C and VOP/VOP_Switch.h.
The first step in created a custom VOP node is to inherit from the main VOP node class, VOP_Node
The parameters on a VOP node are defined in much the same way they are defined on other custom nodes. First, the labels and optionally default value objects are created for all parameters, and then a single static parameter template table is populated with corresponding templates:
To be able to use the newly created VOP node type in Houdini, it must be added to the VOP types table first. This is done in the newDriverOperator() method which has the table passed to it as an argument:
This method is called by Houdini after loading the library file with the custom VOP node. Note that we create a VOP_Operator instead of the base OP_Operator. The VOP_Operator provides more latitude to specialize our new type. In particular, we can restrict it to be available only in certain VOPNET contexts as well as to provide more than one output.
Each VOP node must override several methods related to its inputs and outputs which provide information regarding the number of its fixed and variable inputs, their labels, types, etc. These are:
Whenever a VOP node cooks, its VOP_Node::getCode(UT_String &codestr) function is called. The callee expects to find the code generated by each node in the codestr (note that it should be overwritten with code, not appended to).
To reference existing inputs, outputs, and parameters in the generated code, you should prefix them with $ symbol. For example, an input named "Cd" becomes "$Cd", a parameter named "parm1" becomes "$parm1", etc. An extremely simple example can be seen below. It simply sets the output of a node to its input value:
An example of a custom VOP node can be found in VOP/VOP_Switch.C and VOP/VOP_Switch.h.
For a more advanced example of creating a custom VOP context that is completely user-defined, please see VOP/VOP_CustomContext.C and VOP/VOP_CustomContext.h.