Houdini Engine 7.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Asset Inputs

Exposing Inputs

In Houdini, nodes have direct inputs that only accept nodes of the same type (usually). For example, OBJ nodes accept only other OBJ nodes as direct (node -> line -> node) connections. With OBJ nodes, these connections are essentially transform parentings. A SOP geometry node can as well only accept SOP connections. However, you can have a node accept a different type of node via an exposed Operator Path parameter.

For example, an OBJ node can reference a SOP node and use its geometry by using Object Merge SOP nodes:

HAPI_AssetInputs_ExposingInputs_Nodes.png

This is the parameter on the bject Merge SOP node the should be exposed:

HAPI_AssetInputs_ObjectMergeOpPath.png

More generally, any Operator Path parameter can be used to point to any other node:

HAPI_AssetInputs_OpPathAsInput.png

Once you do this on your asset node, you can simply get or set the node being referenced by the Operator Path parameter using HAPI_GetParmNodeValue() and HAPI_SetParmNodeValue().

Marshalling Geometry Into Houdini

Geometry from the host can be marshalled into Houdini as a node to be connected as input to other existing nodes.

The process is as follows:

  1. Call HAPI_CreateInputNode(). This will create a node that can receive geometry input but otherwise behaves like any other node. The input node is an OBJ node with a single display SOP that is a Null SOP. It is therefore easy to get the display SOP HAPI_NodeId using HAPI_GetDisplayGeoInfo() on the created node itself.
  2. Optionally set the input node transform with a call to HAPI_SetObjectTransform().
  3. Call HAPI_SetPartInfo() to set basic parameters of the mesh.
  4. Create any attributes you wish. See Adding Attributes. You must at least create the position "P" (HAPI_ATTRIB_POSITION) attribute.
  5. Set your attribute data. See Setting Attribute Values.
  6. Push the geometry into Houdini Engine with a number of set functions that mirror those we used to extract the geometry. The order of the calls doesn't matter but you must call at least these functions before continuing:
  7. Optionally you can also create groups on the input mesh. See Adding Groups.
  8. Commit the geometry by calling HAPI_CommitGeo().

Marshalling Detail Attributes

Detail attributes are different than point, vertex, or primitive attributes in the sense that there is only 1 detail for each geometry. Whereas one can have many points, vertices, and primitives, there is only 1 detail - so when marshalling detail attributes, the HAPI_AttributeInfo::count in the HAPI_AttributeInfo struct must always be set to 1. If one wants to attach multiple entries on the detail, one must make use of the HAPI_AttributeInfo::tupleSize field instead. The snippet below shows the marshalling of 3 strings onto the detail attribute:

char ** strs = new char *[ 3 ];
strs[ 0 ] = _strdup( "str1" );
strs[ 1 ] = _strdup( "str2" );
strs[ 2 ] = _strdup( "str3" );
pointInfo.count = 1; // Must be 1 for detail attribute.
pointInfo.tupleSize = 3;
pointInfo.exists = true;
pointInfo.owner = HAPI_ATTROWNER_DETAIL;
pointInfo.storage = HAPI_STORAGETYPE_STRING;
HAPI_AddAttribute( nullptr, display_geo_node_id, 0, "strData", &pointInfo );
HAPI_AttributeInfo attributeInfo;
attributeInfo.exists = true;
attributeInfo.owner = HAPI_ATTROWNER_DETAIL;
attributeInfo.count = 1;
attributeInfo.tupleSize = 3;
nullptr, display_geo_node_id, 0, "strData",
&attributeInfo, (const char **) strs, 0, 1 );

Marshalling Point Clouds

With a slight variation of the above, point clouds can now be marshalled in. Simply set the HAPI_PartInfo::vertexCount and HAPI_PartInfo::faceCount fields to 0.

Connecting Assets

Remember that assets are just nodes. To connect assets to other assets or nodes directly, that is, not via a parameter but via a node connection, just use HAPI_ConnectNodeInput() and HAPI_DisconnectNodeInput(). See Connecting Nodes.