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

Another straightforward SOP_Node type is the filter. These take incoming geometry and manipulate it in some way. This can consist of creating, destroying, or modifying points and primitives.

A SOP_Node filter is built the same way as a generator. The difference is that instead of using GU_Detail::clearAndDestroy to wipe out your geometry at the start of a cook, you instead copy your input's geometry.

To access your inputs you must lock them. The first way is to lock each input at a time with OP_Node::lockInput. After they have been locked, the input's const GU_Detail * can be accessed with SOP_Node::inputGeo. This pointer is valid until you invoke OP_Node::unlockInput. It is very important that the lockInput calls are matched with unlockInput calls.

Alternatively, if you just want to lock all the node's inputs, you can invoke OP_Node::lockInputs and OP_Node::unlockInputs.

Both of these input locking techniques require you to specify an OP_Context. Usually this is the OP_Context passed to you in your SOP_Node::cookMySop, but if you wish to cook the inputs at a different time you should construct your own OP_Context with a different time.

It is very common to need to merely duplicate your input geometry. For this purpose the SOP_Node::duplicateSource simplifies things.

If all you are doing is changing points and not creating or destroying points or primitives, it is possible to accelerate the duplication by only resetting the point values. The SOP_Node::duplicatePointSource performs this optimization.

A very simple example of a point deformer is SOP/SOP_PointWave.C and SOP/SOP_PointWave.h.

Another simple example (using the C++ HOM API) can be found in HOM/SOP_HOMWave.C and HOM/SOP_HOMWave.h. Also see Houdini's inlinecpp Python module for a way to easily use C++ code to accelerate a Python SOP.

An example of using multiple inputs, including cooking them at different times, is SOP/SOP_TimeCompare.C and SOP/SOP_TimeCompare.h.