HDK
|
Several steps are required to create a custom ROP node:
Each of these steps is discussed in more detail below. Alternatively, a full example can be found in ROP/ROP_Dumper.C and ROP/ROP_Dumper.h.
The first step in creating a custom ROP operator is to inherit from ROP_Node. ROP_Node itself does most of the background work required, and only delegates a few tasks, such as initializing, rendering, and cleaning up afterwards.
Note that the constructors for ROPs are protected, and so a ROP node cannot be allocated explicitly. Instead, the task is performed by a static factory method ROP_Dumper::myConstructor(). It takes the parent network, node name, and operator type as parameters. Static getTemplatePair() and getVariablePair() provide access to this node's parameter templates and variables, correspondingly.
The next step is to define any parameters you may need on the node. Each ROP node has a base set of pre-defined parameters which are valid for every ROP node, as well as any other parameters specific to each particular node type. Base parameters including first and last render frame, whether to render an animation or a single frame, and more.
Custom parameters are generally defined as global variables in the ROP's C file. The overall parameter interface is generally defined as a parameter template static variable in the getTemplates() function. The example below adds a custom file output parameter, as well as five standard ROP parameters, to the node. The standard parameters represent "Render" and "Render Control Dialog" buttons, as well as the "Valid Frame Range", "Start/End/Inc" and "Render With Take" ROP parameters.
To be able to use the newly added ROP node type in Houdini, it must be added to the ROP 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 ROP node.
To perform the actual output, ROP_Node calls three methods which a custom ROP should override to perform its own tasks. ROP_Node::startRender() is called before the rendering begins to do any initialization that may be needed. If it returns false, the rendering process is aborted; otherwise, ROP_Node::renderFrame() is called for each frame to be rendered, as specified by the corresponding ROP parameters. This function should return one of three return codes, which tell Houdini whether to stop rendering, continue, or retry the frame (ROP_ABORT_RENDER, ROP_CONTINUE_RENDER, ROP_RETRY_RENDER in ROP_Node.h).
After the rendering of all frames is done, Houdini calls ROP_Node::endRender(), which returns one of the three codes above to indicate the result of its operations.
An example of a custom ROP node can be found in ROP/ROP_Dumper.C and ROP/ROP_Dumper.h.