HairGuides Class Reference

#include <lib_hair.h>

Detailed Description

Helper class for guides/hair.

Note
Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Public Member Functions

Int32 GetCount ()
 
Int32 GetSegmentCount ()
 
Int32 GetPointCount ()
 
Int32 GetGuidePointCount ()
 
VectorGetPoints ()
 
HairGuideDynamicsGetDynamics ()
 
Matrix GetMg ()
 
void SetMg (const Matrix &mg)
 
HairRootData GetRoot (Int32 index)
 
void SetRoot (Int32 index, const HairRootData &root, Bool update)
 
HairObjectGetObject ()
 
Bool GetSelected (Int32 mode, BaseSelect *select)
 
Bool SetSelected (Int32 mode, BaseSelect *select)
 
Bool ConvertSelection (Int32 from_mode, Int32 to_mode, BaseSelect *from_select, BaseSelect *to_select)
 
Bool CopyFrom (const HairGuides *src)
 
Vector GetTangent (Int32 guide, Int32 segment, Float t)
 
SplineObjectCreateSpline ()
 
void ToLocal ()
 
void ToWorld ()
 
void ToInitial (Bool align)
 
void DisplaceRoots ()
 
void UndisplaceRoots ()
 
Bool GetRootAxis (Int32 index, Matrix &m, Bool bAlign=false, Bool bLocal=true, Bool bInitial=false, Bool bZAxis=false)
 
Vector GetRootUV (Int32 index)
 
Bool GetRootData (Int32 index, Vector *p=nullptr, Vector *n=nullptr, Int32 *ply_id=nullptr, Bool bLocal=true, Bool bDisplaced=true, Bool bInitial=false)
 
MatrixGetTransformMatrix ()
 
void SetTransformMatrix (Matrix *tm)
 
Bool Delete (BaseSelect *bs)
 
Bool AddRoot (Int32 ply_id, Float s, Float t, Float len)
 
Bool GetRootObject (RootObjectData *pData)
 
Bool LinkToObject (HairObject *pHair)
 
Int32 GetFlags ()
 
Int32 SetFlags (Int32 flags)
 

Static Public Member Functions

static HairGuidesAlloc (Int32 count, Int32 segments)
 
static void Free (HairGuides *&guides)
 

Private Member Functions

 HairGuides ()
 
 ~HairGuides ()
 

Constructor & Destructor Documentation

◆ HairGuides()

HairGuides ( )
private

◆ ~HairGuides()

~HairGuides ( )
private

Member Function Documentation

◆ Alloc()

static HairGuides* Alloc ( Int32  count,
Int32  segments 
)
static

Allocates a hair guides helper. Destroy the allocated hair guides helper with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in]countThe number of guides.
[in]segmentsThe number of segments per guide.
Returns
The allocated hair guides helper, or nullptr if the allocation failed.

◆ Free()

static void Free ( HairGuides *&  guides)
static

Destructs hair guides helpers allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]guidesThe hair guides helper to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ GetCount()

Int32 GetCount ( )

Gets the number of guides.

Returns
The guide count.

◆ GetSegmentCount()

Int32 GetSegmentCount ( )

Gets the number of segments per guide.

Note
The number of points is GetSegmentCount() + 1.
Returns
The segment count.

◆ GetPointCount()

Int32 GetPointCount ( void  )

Gets the total number of points for all guides.

Returns
The point count.

◆ GetGuidePointCount()

Int32 GetGuidePointCount ( )

Gets the number of points per segment i.e. GetSegmentCount() + 1.

Returns
The number of points per segment.

◆ GetPoints()

Vector* GetPoints ( )

Retrieves a pointer to the point vectors for the guides.

Returns
The points array.

◆ GetDynamics()

HairGuideDynamics* GetDynamics ( )

Gets the dynamics.

Returns
The dynamics. Can be nullptr.

◆ GetMg()

Matrix GetMg ( )

Gets the global matrix.

Returns
The global matrix.

◆ SetMg()

void SetMg ( const Matrix mg)

Sets the global matrix.

Parameters
[in]mgThe new global matrix.

◆ GetRoot()

HairRootData GetRoot ( Int32  index)

Gets the root data for the specified guide index.

Parameters
[in]indexThe guide index: 0 <= index < GetCount()
Returns
The root data.

◆ SetRoot()

void SetRoot ( Int32  index,
const HairRootData root,
Bool  update 
)

Sets the root data for the specified guide index.

Parameters
[in]indexThe guide index: 0 <= index < GetCount()
[in]rootThe new root data.
[in]updateIf true then an update is made.

◆ GetObject()

HairObject* GetObject ( )

Gets the corresponding hair object.

Returns
The hair object.

◆ GetSelected()

Bool GetSelected ( Int32  mode,
BaseSelect select 
)

Gets the selection state.

Parameters
[in]modeThe selection mode: HAIR_MODE
[out]selectAssigned the selection.
Returns
true if successful, otherwise false.

◆ SetSelected()

Bool SetSelected ( Int32  mode,
BaseSelect select 
)

Sets the selection state.

Parameters
[in]modeThe selection mode: HAIR_MODE
[out]selectThe new selection.
Returns
true if successful, otherwise false.

◆ ConvertSelection()

Bool ConvertSelection ( Int32  from_mode,
Int32  to_mode,
BaseSelect from_select,
BaseSelect to_select 
)

Converts selection state.

Parameters
[in]from_modeThe source selection mode: HAIR_MODE
[in]to_modeThe destination selection mode: HAIR_MODE
[in]from_selectThe source selection.
[out]to_selectThe destination selection.
Returns
true if successful, otherwise false.

◆ CopyFrom()

Bool CopyFrom ( const HairGuides src)

Copies the guide data from src.

Parameters
[in]srcThe source hair guides helper.
Returns
true if successful, otherwise false.

◆ GetTangent()

Vector GetTangent ( Int32  guide,
Int32  segment,
Float  t 
)

Gets the tangent of guide at segment and t.

Parameters
[in]guideThe guide index: 0 <= guide < GetCount()
[in]segmentThe segment index: 0 <= segment < GetSegmentCount()
[in]tThe T coordinate.
Returns
The tangent.

◆ CreateSpline()

SplineObject* CreateSpline ( )

Creates splines from the guides.

Returns
The created spline object.

◆ ToLocal()

void ToLocal ( )

Changes all the points for the guides into a local coordinate system.

◆ ToWorld()

void ToWorld ( )

Changes all the points for the guides into the world coordinate system.

◆ ToInitial()

void ToInitial ( Bool  align)

Changes the coordinate space and transforms the points back to their initial state.
This is useful when applying coordinate Dependant changes to the points, by moving them back to an initial state the changes are not affecting when the guide roots move due to animation.

Parameters
[in]alignIf true the guides are rotated from their root back to their initial orientation.

◆ DisplaceRoots()

void DisplaceRoots ( )

Used when HNs have affected the guide roots. Call DisplaceRoots() and it will ensure they are in the correct displaced state for HNs, UndisplaceRoots() will make sure they are not.
Generally not needed if using ToInitial(), as the initial state is undisplaced.

◆ UndisplaceRoots()

void UndisplaceRoots ( )
See also
DisplaceRoots()

◆ GetRootAxis()

Bool GetRootAxis ( Int32  index,
Matrix m,
Bool  bAlign = false,
Bool  bLocal = true,
Bool  bInitial = false,
Bool  bZAxis = false 
)

Gets the root axis of guide index.

Parameters
[in]indexThe guide index: 0 <= index < GetCount()
[out]mFilled with the root axis.
[in]bAlignAligned.
[in]bLocalLocal.
[in]bInitialInitial.
[in]bZAxisIf true then the alignment is done along the Z axis, otherwise it is Y.
Returns
true if successful, otherwise false.

◆ GetRootUV()

Vector GetRootUV ( Int32  index)

Gets the root UV for guide index.

Parameters
[in]indexThe guide index: 0 <= index < GetCount()
Returns
The root UV.

◆ GetRootData()

Bool GetRootData ( Int32  index,
Vector p = nullptr,
Vector n = nullptr,
Int32 ply_id = nullptr,
Bool  bLocal = true,
Bool  bDisplaced = true,
Bool  bInitial = false 
)

Gets the root data.

Parameters
[in]indexThe guide index: 0 <= index < GetCount()
[out]pAssigned the point.
[out]nAssigned the normal.
[out]ply_idAssigned the polygon ID..
[in]bLocalLocal.
[in]bDisplacedDisplaced.
[in]bInitialInitial.
Returns
true if successful, otherwise false.

◆ GetTransformMatrix()

Matrix* GetTransformMatrix ( )

Gets the transformation matrix array.

Returns
The transformation matrix array. Each matrix element is an axis at the root of each guide.
Needs to be freed with DeleteMem() afterwards.

◆ SetTransformMatrix()

void SetTransformMatrix ( Matrix tm)

Sets a new array of transformation matrices.

Parameters
[in]tmThe new transformation matrix array. Each matrix element is an axis at the root of each guide.

◆ Delete()

Bool Delete ( BaseSelect bs)

Deletes the guide selection.

Parameters
[out]bsThe selection to delete.
Returns
true if successful, otherwise false.

◆ AddRoot()

Bool AddRoot ( Int32  ply_id,
Float  s,
Float  t,
Float  len 
)

Adds a root.

Note
Invalidates any pointers or arrays returned before as the guides will have changed.
Parameters
[in]ply_idThe polygon ID.
[in]sThe S coordinate.
[in]tThe T coordinate.
[in]lenThe length.
Returns
true if successful, otherwise false.

◆ GetRootObject()

Bool GetRootObject ( RootObjectData pData)

Gets the root object data.

Parameters
[out]pDataFilled with the root object data.
Returns
true if successful, otherwise false.

◆ LinkToObject()

Bool LinkToObject ( HairObject pHair)

Links this to a specific HairObject.

Parameters
[in]pHairA hair object.
Returns
true if successful, otherwise false.

◆ GetFlags()

Int32 GetFlags ( )

Gets the flags.

Returns
The flags: HAIR_GUIDE_FLAGS

◆ SetFlags()

Int32 SetFlags ( Int32  flags)

Sets the flags.

Parameters
[in]flagsThe new flags: HAIR_GUIDE_FLAGS
Returns
The old flags.