HDK
|
Most DOP nodes create and modify option data attached to SIM_Object and SIM_Data instances during the network pass of DOP processing. The DOP_Auto class can construct DOP node interfaces for these operators.
When defining custom Auto DOP nodes several steps must be performed.
An example of how to construct a simple custom Auto DOP can be seen at SIM/SIM_ElectricalProperties.C.
Guide geometry can be added to SIM_Data to provide visual feedback in the viewport. Perform the following to add guide geometry to a custom Auto DOP:
An example of how to construct an Auto DOP with custom guide geometry can be seen at SIM/SIM_ForceOrbit.C.
Force DOPs can be constructed as Auto DOP nodes. To create a force Auto DOP node, perform these steps:
An example of how to construct a simple custom force Auto DOP can be seen at SIM/SIM_ForceOrbit.C.
The Auto DOP nodes allow users to attach a new type of SIM_Data to SIM_Object. This data is not much use if you cannot access it outside of the Auto DOP.
There are two macros to make it easy to both fetch and cast the desired data from an object, SIM_DATA_GET and SIM_DATA_GETCONST. Whenever you want read only access, one should always use SIM_DATA_GETCONST. The SIM_DATA_GET will create a non-const reference that will unique the data across time, a possible waste of memory if the data isn't changing.
Most of the standard DOP data is generated with Auto DOP Nodes. Things such as RBD_State, SIM_Position, etc, can be accessed in the following fashion.
The next example shows how to write to the data. It will also create the data if it can't be found. If data exists of the wrong type, it will be deleted and replaced by the RBD_State data.
Finally, this example will again create a missing RBD_State. However, it sets the flags to SIM_DATA_RETURN_EXISTING so if it already exists, the current version is used. This is orred with SIM_DATA_ADOPT_EXISTING_ON_DELETE which will try to up-convert any base types into RBD_State. In this way, if SIM_Position is already on the object and is named "Position", it will be converted into an RBD_State and returned.
The Auto DOP Nodes by default do not accept any subdata. In the network editor they show up with a single grey input. If it is sensible to attache some types of subdata to them, you can list the types of subdata using the dopdatahint HScript command. The $HFS/houdini/scripts/dophints.cmd has examples of how to setup the valid subdata.
Note that when you add your own dophints.cmd to your HOUDINI_SCRIPT_PATH, only the first dophints.cmd is called. Thus you need to chain into the official dohints.cmd by assing as the final line:
Instead of adding to the dophints.cmd, you can also directly add hints in C++ in your initializeSIM hook.