» Back to Documentation

Guides interface

Guides in Ornatrix are same as hair objects with an extra ability to attach information to each strand. Because there are typically much fewer guides than hairs holding extra information per-guide is cheap in terms of memory and this information can be later procedurally interpolated by hairs just like the positional information is derived from guides.

Accessing IGuides from scene

In addition to IHair interface Ornatrix has an IGuides interface (available in IGuides.h) which allows you to access and modify this information. You can access the IGuides interface from any hair object or modifier, similar to how IHair is accessed by using IGuidesInterfaceID. For example, if you have a scene node representing your guides you can get IGuides interface by:

IGuides* guides = static_cast<IGuides*>( myNode->EvalWorldState( time ).obj->GetInterface( IGuidesInterfaceID ) );

Always check the result for NULL because dense hair objects will not return this interface. Instead, if you want to get guides which generated a certain hair object first get the IHair interface and then use:

IGuides* guides = hair.Guides();

This will return the guides used to generate the hair object, or NULL if hair didn't use guides (for example, if it was generated directly). If you have an IHair object that is also a guides object (guides are derived from hair) you can use:

IGuides* guides = hair.AsGuides();

The result will be NULL if the hair is not a guides object (if it is dense/render hair). This also works the other way around. If you have an IGuides interface and you want to retrieve it's hair interface you can use:

IHair& hair = guides.AsHair();

Note that here we receive a reference. This happens because a guides object is also always a hair object (guides derive from hair).

Creating a new guides object

To create a new guides object in the scene use:

::Object* guidesObject = GetCOREInterface()->CreateInstance( GEOMOBJECT_CLASS_ID, ORNABGUIDES_CLASS_ID )

Guide data

The information held by each guide falls into two categories: per-root data and per-vertex data. Per-root data takes less memory to store but, as the name implies, this data cannot vary along the strand length. Per-vertex data can vary along the strand length but it takes more space to store.

All per-vertex and per-root data is represented as floating point numbers. This data can contain things like weights, coordinates, color, and anything else.