Houdini Engine 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages

The Curve Asset

Curves are often an important source of input in terms of user control. Many assets, especially those involved with environment creation (a road asset for example), expect curves as input. In this case we want curves that can be fed into the underlying Houdini asset to influence its computation, but which also appear in the host environment so they can be displayed and manipulated by the user.

Houdini Engine currently provides two alternative mechanisms for inputting curves from the host application: Curve Assets and Curve Marshalling.

A Curve Asset is an easy way to create a curve asset representing a single curve that can be manipulated and fed as an input for other Houdini Engine assets. See Asset Inputs for more on inputs.

You instantiate a curve asset with a call to HAPI_CreateCurve(). You get back a HAPI_AssetId that can be used like for any other asset. See Assets.

The way this asset is intended to be used is via its exposed parameters. The curve points (CVs) themselves are stored as a space-separated list string parameter named "coords". Other parameters exist to change properties on the curve such as primitive type, method, order and whether or not it is closed.

For a full source sample on using the curve asset, see the The Curve Asset source sample.

Curve Output

It is often necessary to access curve data, as curve data, that has been produced as a result of computation. Curves come as parts. You can tell if a part is a curve if HAPI_PartInfo::type is equal to HAPI_PARTTYPE_CURVE. A curves part can contain one or more curves as a curve mesh. Here are the general steps to get curve information:

  1. Having a curve part, fill a HAPI_CurveInfo struct using HAPI_GetCurveInfo(). Once you know the number of curves, the number of control vertices per curve can be retrieved using HAPI_GetCurveCounts().
  2. The control vertices (CVs) themselves can be extracted via per-point attributes "P" and "Pw". Please note that the function HAPI_GetCurveVertices() has been removed from the API as of version 1.9.
  3. Likewise, the order information for each curve can be retrieved with HAPI_GetCurveOrders().
  4. Finally, the knots themselves can be retrieved with HAPI_GetCurveKnots(). The number of knots applicable to each curve is the order of that curve plus the number of control vertices.

Note that you will get 1 part per type of curve. For example, the asset below contains a merge of 5 separate curves:


Two of them, nurbs_curve and nurbs_curve2, and represented as a single part because they are both open nurbs curves, while each of poly_curve, bezier_curve has their own part because they are curves of a different type. Finally, closed_nurbs_curve has its own part, even though it is a Nurbs curve, because it is closed, and thus different from nurbs_curve and nurbs_curve2:


Curve Marshalling

Curve Marshalling follows the same principles as Marshalling Geometry Into Houdini. Curves are just another primitive type that can be stored in a part of an Input Asset. Multiple curves can be stored per part in which case they represent a Curve Mesh. One possible use case for Curve Meshes is a hair system.

First, you need to have an Input Asset created with HAPI_CreateInputAsset(). Remember, an input asset can have only one geo and one part in that geo, so you have to pass 0 for geo and part indices in all subsequent setter calls.

Once you have an Input Asset, you have to set the parameters of the curve mesh part with a HAPI_SetPartInfo() call. For curves, HAPI_PartInfo::type has to be set to HAPI_PARTTYPE_CURVE. Just like with poly meshes, you have to set HAPI_PartInfo::vertexCount, HAPI_PartInfo::pointCount and HAPI_PartInfo::faceCount to the number of elements in attributes of the respective HAPI_AttributeOwner. The meaning of HAPI_PartInfo::faceCount for curves is per primitive, i.e. per curve.

You also have to set properties of the curve mesh with a call to HAPI_SetCurveInfo(), then HAPI_SetCurveCounts() to specify the number of CVs per curve and optionally HAPI_SetCurveOrders() and HAPI_SetCurveKnots(), depending on the type of the curve.

Next, you have to create and populate attributes of the curve mesh as described in Adding Attributes and Setting Attribute Values. Just like with poly meshes, you have to at least set the "P" (HAPI_ATTRIB_POSITION) per-point attribute, which represents the curves' control vertices.

Finally, you have to commit the curve mesh by calling HAPI_CommitGeo().

For a full source sample on curve marshalling, see the Curve Marshalling source sample.

For a full source sample on curve outputs, see the Curve Output source sample.