MaxScript Hair Interface 

This interface is used to operate on core hair structure used by Ornatrix. This hair flows through Ornatrix pipeline and is manipulated by its various components. You would typically retrieve this interface from either a Baked Guides Object, Baked Hair Object, Hair from Mesh Strips Object, or any other component which directly stores hair instead of generating it procedurally. Use the GetHair() function on these objects to gain access to this interface:

myHair = $.GetHair()

When using a guide interface you can use guides.AsHair() to obtain this hair interface to a guide object. You need to take care when using some of these functions because they provide low level access and can cause unexpected behaviour used as designed.

Hair interface to any Ornatrix hair object is obtained through bakedHair.GetHair() command on any baked hair object or any other object derived from HairObject. Once you have the hair interface you may use any of the following methods to access and modify it:

/* Gets total number of roots
returns: Total number of roots
*/
rootCount = myHair.NumRoots()

/* Set number of roots and all associated data (specified in flags)
count Number of roots
keep If true previous roots will not be cleared
*/
myHair.SetNumRoots count keep

/* Gets whether this hair use root topology data
returns: true if this hair uses root topology data
*/
flag = myHair.UsesStrandTopology()

/* Get starting index into vertex array of specified root
returns: Starting index into vertex array of specified root
*/
guideIndex = myHair.GetRootGID rootIndex

/* Get number of vertices associated with specified root
returns: Number of vertices associated with specified root
*/
verteCount = myHair.GetRootGNum rootIndex

/* Set starting index into vertex array of specified root
rootIndex Root index
vertexIndex Vertex index
*/
myHair.SetRootGID rootIndex vertexIndex

/* Set number of vertices associated with specified root
rootIndex Root index
pointCount Point count
*/
myHair.SetRootGNum rootIndex pointCount

/* Gets whether this hair use root transform data
returns: true if this hair uses root transform data
*/
flag = myHair.HasRootTM()

/* Gets strand matrix associated with root
rootIndex Root index
returns: Matrix associated with root
*/
transform = myHair.GetRootTM rootIndex

/* Set a new matrix associated with root
rootIndex Root index
transform Matrix associated with root
*/
myHair.SetRootTM rootIndex transform

/* Gets whether this hair use surface dependance data
returns: true if this hair uses surface dependance data
*/
flag = myHair.HasSurfDep()

/* Gets the distribution mesh face index on which specified root is planted
rootIndex Root index
returns: Face index
*/
faceIndex = myHair.GetSurfDepFace rootIndex

/* Gets the barycentric coordinate on the distribution mesh face on which specified root is planted
rootIndex Root index
returns: Barycentric coordinate
*/
barycentricCoordinate = myHair.GetSurfDepBary rootIndex

/* Sets the distribution mesh face index on which specified root is to be located
rootIndex Root index
faceIndex Face index
*/
myHair.SetSurfDepFace rootIndex faceIndex

/* Sets the barycentric coordinate on the distribution mesh face on which specified root is to be located
rootIndex Root index
barycentricCoordinate Barycentric coordinate
*/
myHair.SetSurfDepBary rootIndex barycentricCoordinate

/* Gets whether this hair use guide dependance data
returns: true if this hair uses guide dependance data
*/
flag = myHair.HasGuideDep()

/* Gets the index of the n'th closest guide to specified root, if current hair is generated from guides
rootIndex Root index
closestGuideIndex The index of the closest guide
returns: Guide index
*/
guideIndex = myHair.GetGuideDepCSR rootIndex closestGuideIndex

/* Gets the distance from the n'th closest guide to specified root, if current hair is generated from guides
rootIndex Root index
closestGuideIndex The index of the closest guide
returns: Distance to guide
*/
distance = myHair.GetGuideDepDSR rootIndex closestGuideIndex

/* Sets the index of the n'th closest guide to specified root, if current hair is generated from guides
rootIndex Root index
closestGuideIndex The index of the closest guide
guideIndex Guide index
*/
myHair.SetGuideDepCSR rootIndex closestGuideIndex guideIndex

/* Sets the distance from the n'th closest guide to specified root, if current hair is generated from guides
rootIndex Root index
closestGuideIndex The index of the closest guide
distance Distance to guide
*/
myHair.SetGuideDepDSR rootIndex closestGuideIndex distance

/* Computes root transform matrix for specified strand
rootIndex Root index
returns: Strand to object transform
*/
transform = myHair.ComputeRootTM rootIndex

/* Updates root transforms using surface dependency and distribution mesh normals
startingRootIndex Index of the first root
count Number of roots for which to compute transforms
*/
myHair.UpdateRootTM startingRootIndex count

/* Gets vertex index for the first point in specified root
rootIndex Root index
returns: Vertex index
*/
vertexIndex = myHair.VertId rootIndex

/* Gets the number of points in specified strand
rootIndex Root index
returns: Point count
*/
count = myHair.NumPts rootIndex

/* Gets the global number of points per strand
returns: Point count per strand
*/
count = myHair.GetGlobSegNum()

/* Sets the global number of points per strand
count Point count per strand
*/
myHair.SetGlobSegNum count

/* Gets the total number of hair vertices
returns: Vertex count
*/
count = myHair.NumVerts()

/* Sets the number of vertices and resizes all connected data
count Vertex count
keep If true previous vertices will be kept as much as possible
*/
myHair.SetNumVerts count keep

/* Append a vertex array to the end of vertex list and update lookup tables
vertices Vertex positions
count Number of vertices
*/
myHair.AppendVerts vertices count

/* Gets vertex in local strand space
vertexIndex Vertex index
returns: Vertex position
*/
position = myHair.GetVert vertexIndex

/* Gets vertex in object space
vertexIndex Vertex index
returns: Vertex position
*/
position = myHair.GetVertT vertexIndex

/* Sets vertex in local strand space
vertexIndex Vertex index
position Vertex position
*/
myHair.SetVert vertexIndex position

/* Sets vertex in object space
vertexIndex Vertex index
position Vertex position
*/
myHair.SetVertT vertexIndex position

/* Gets strand point in local strand space
rootIndex Strand index
pointIndex Point index on strand
returns: Point position
*/
position = myHair.GetPoint rootIndex pointIndex

/* Gets strand point in object space
rootIndex Strand index
pointIndex Point index on strand
returns: Point position
*/
position = myHair.GetPointT rootIndex pointIndex

/* Sets strand point in local strand space
rootIndex Strand index
pointIndex Point index on strand
position Point position
*/
myHair.SetPoint rootIndex pointIndex position

/* Sets strand point in object space
rootIndex Strand index
pointIndex Point index on strand
position Point position
*/
myHair.SetPointT rootIndex pointIndex position

/* Gets whether class uses vertex lookup tables
returns: true if class uses vertex lookup tables
*/
flag = myHair.HasVertInd()

/* Gets root index associated with specified vertex index
vertexIndex Vertex index
returns: Root index
*/
rootIndex = myHair.GetVertInd vertexIndex

/* Sets root index associated with specified vertex index
vertexIndex Vertex index
rootIndex Root index
*/
myHair.SetVertInd vertexIndex rootIndex

/* Updates vertex lookup tables based on available data
*/
myHair.RemapVertInd()

/* Gets the texture coordinate of specified point on specified strand
strandIndex Index of the strand
pointIndex Index of a vertex on the strand
returns: Texture coordinate at specified position and strand
*/
uvw = myHair.GetPointUVW strandIndex pointIndex

/* Gets the texture coordinate at the root of the specified strand
strandIndex Strand index
returns: Texture coordinate
*/
uvw = myHair.GetVertUVW strandIndex

/* Validates the bounding box of this object
*/
myHair.UpdateBoundingBox()

/* Gets the minimum coordinate of the hair's bounding box
returns: Minimum corner coordinate
*/
position = myHair.GetBoundingBoxMin()

/* Gets the maximum coordinate of the hair's bounding box
returns: Maximum corner coordinate
*/
position = myHair.GetBoundingBoxMax()

/* Saves this hair into an .oxh file
filePath File path
*/
myHair.Save filePath

/* Loads this hair from an .oxh file
filePath File path
*/
myHair.Load filePath

/* If this hair structure indirectly depends on guides, this will return an interface to those guides. You can see which guide each hair depends on by reading the guide dependence data.
returns: Guides interface
*/
myGuides = myHair.GetGuides()

/* If you would like your hair automatically deform with a mesh, you can assign a mesh here and then call UpdateRootTM() function to have all root transforms 'glued' to the surface.
You also need to aset up surface dependence data for this to work. Mesh has to be valid when roots are updates, so take good care not to garbage-collect or delete the provided object by accident.
obj Distribution mesh object
*/
myHair.SetDistrObj obj
Missing Something? Let us know if this page needs more information about the topic.