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

Exposing Inputs

As the diagram showed in Overall Architecture, assets can have inputs. Not only that, but they can have inputs of different types. This is a little different than within Houdini itself, where assets can have only inputs of a single type, depending on the type of the asset. For example, in Houdini, if an asset is an object type asset, then it has transform inputs. Connecting transform inputs in Houdini is the equivalent of parenting. If it is a SOP level asset (geometry only asset), on the other hand, then it can have 0 or more geometry inputs.

However, an object level asset in Houdini may bring in geometry from other parts of the network that are outside the asset, by using object merge nodes from within the asset:

HAPI_AssetInputs_ExposingInputs_Nodes.png

More generally, any OP Path parameter can be used to point to some other part of the network, and hence act as an input to the asset:

HAPI_AssetInputs_OpPathAsInput.png

HAPI will recognize exposed OP Path parameters as inputs. So, for example, an OP Path parameter with the SOP filter will be recognized as a geometry input. For the case of object merge nodes mentioned above, you can expose them as an input by exposing the OP Path parameter normally used to point to other nodes:

HAPI_AssetInputs_ObjectMergeOpPath.png

Once the geometry inputs are recognized by Houdini Engine, you may then connect the geometry outputs of other assets to this input or marshal geometry from the host environment into this geometry input. Note that the above description regarding exposed object merge nodes are for non-SOP type assets only. SOP type assets are natively designed to process geometry, and their inputs are already clearly defined, so there is no need to hook up exposed object merge nodes when defining SOP assets.

Marshalling Geometry Into Houdini

Geometry from the host can be marshalled into geometry inputs, either exposed by object merge nodes as described in Exposing Inputs, or instantiating a SOP type asset (a geometry asset).

The process is as follows:

  1. Call HAPI_CreateInputAsset(). This will create a special asset that can receive geometry input but otherwise behaves like any other asset. The input asset only has a single object and geo so all set function calls can assume object and geo ids to be ZERO.
  2. Optionally set the input asset transform with a call to HAPI_SetAssetTransform().
  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().

For a full source sample on marshalling geometry into Houdini, see the Marshalling Geometry Into Houdini source sample.

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;
ENSURE_SUCCESS( HAPI_AddAttribute( geoCreatorId, 0, 0, "strData", &pointInfo ) );
HAPI_AttributeInfo attributeInfo;
attributeInfo.exists = true;
attributeInfo.owner = HAPI_ATTROWNER_DETAIL;
attributeInfo.count = 1;
attributeInfo.tupleSize = 3;
geoCreatorId, 0, 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.

For a full source sample on marshalling point clouds into Houdini, see the Marshalling Point Clouds source sample.

Connecting Assets

One of the most powerful aspects of Houdini Engine is that not only can individual assets be brought in and used on their own, but that multiple assets may be brought in to the host environment and made to work together. For example, I could have a curve asset that connects to a terrain to form roads on the terrain. The road asset could then feed to a city block layout, which defines basic shapes of buildings. Finally, a detailer asset could be connected to the city block layout to detail it with windows, doors etc. The end result is a procedurally generated city, with only a few simple inputs, such as curves, to drive the entire process.

Connecting assets with Houdini Engine is simple. Once we know the number of inputs of each type, we could connect assets together using the following functions:

For a full source sample on connecting assets, see the Connecting Assets source sample.