All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Creating Geometry

The simplest form of SOP is one that has no need for inputs. It creates its geometry based on its parameters. This is referred to as a generator node rather than a filter node.

One first subclasses SOP_Node. Then one creates the hook ref newSopOperator which creates an OP_Operator for your new SOP_Node class and adds it to the OP_OperatorTable. During this registration is when your PRM_TemplateList is referenced to tell Houdini what the interface of your SOP_Node will be. Finally, the actual code to do things lives in the SOP_Node::cookMySop method that you override.

During the SOP_Node::cookMySop you have a local member variable called gdp of type GU_Detail. This member variable should be updated to reflect what the geometry should look like post-cook. Note that SOP_Node::gdp is null outside of the cooking process, so do not expect external callers to be able to see this variable! This variable also will often store the previously cooked data allowing for some types of optimizations. This should not be relied upon, however, and one should validate that it is the same geometry by using the GA_Detail::getUniqueId.

Because this is a generator, you want to start your computation with a blank GU_Detail. You can do this with GU_Detail::clearAndDestroy. Calling GU_Detail::clearAndDestroy will delete all your geometry. This can be inefficient if you are likely going to be immediately recreating similar geometry. In these cases, the GEO_Detail::stashAll can be called to empty the GDP but store all the points and primitives in a special stash to speed up re-creation. When you are done building you should then invoke GEO_Detail::destroyStashed to clean up any unused stashed primitives or points.

When you have a blank GU_Detail you want to populate it with geometry. The two types of geometry, primitives and points, are created in different fashions. You can create new points using GU_Detail::appendPoint. You can create new primitives by invoking the static build method found in the relevant primitive, ie, GU_PrimPoly::build. The build methods often have an option to generate new points for the required vertices. Note that if you do not generate new points, the vertices will have null point references and will cause Houdini to crash if they are displayed.

An example of a generator is SOP/SOP_Star.C and SOP/SOP_Star.h.