C# Class TressFXLib.Hair

This is the main class for handling tressfx hair info.
Mostrar archivo Open project: kennux/TressFXUnity Class Usage Examples

Public Methods

Method Description
CreateBoundingSphere ( ) : void

Implicitly initializes the bounding sphere. Calculates the bounding sphere automatically

CreateIndices ( ) : void

Implicitly initializes the indices of this hair. This calculates the indices automatically

CreateUVs ( ) : void

UV-Maps the hair. The uv-coordinates will look like this: { STRAND_INDEX / STRAND_COUNT, VERTEX_INDEX / VERTEX_COUNT_IN_STRAND, 0, 0 }

Export ( HairFormat format, string path ) : void

Exports this hair to the given file format output.

Export ( IHairFormat format, string path ) : void

Exports this hair to the given file format class instance.

GenerateFollowHairs ( int followHairsPerGuidanceHair, float maxRadiusAroundGuideHair ) : void

Performs follow hair generation. If a hair file gets imported from a "not-tressfx" format like ase every hair will be set to be a guidance hair. With this functions its possible to generate hairs which will not get simulated, but moved along their guidance hair. This can get used to make hair more dense without simulation overhead.

Import ( HairFormat format, string path, TressFXLib.HairImportSettings importSettings = null ) : Hair

Loads / imports hair from the given file with given format.

InitializeBoundingSphere ( System.Vector3 center, float radius ) : void

Explicitly initializes the bounding sphere. Only used if the bounding sphere is loaded on import, for example in tfxb.

InitializeIndices ( int lineIndices, int triangleIndices ) : void

Explicitly initialized the indices of this hair. This function is only used if the indices are imported with the hair data, for example in tfxb. Only initialize them manually if you know what you are doing. They will get generated automatically in the getter functions.

InitializeSimulationData ( TressFXLib.HairSimulationData hairSimulationData ) : void

Explicitly initializes the simulation data. This is used in for example the tressfx binary importer.

NormalizeStrands ( int normalizedVertexCount ) : void

This function is used to make sure that every hair strand has the same vertex position. It uses linear interpolation in order to do so. After calling this, the simulation data must get reprepared, because the hair vertices will get reset.

PrepareSimulationParamatersAssetConverter ( int followHairs, float maxRadiusAround, string assetConverterExePath ) : Hair

TEMPORARY FUNCTION! THIS WILL GET REMOVED IN THE NEAR FUTURE! Prepares the simulation parameters by using a binary executable of the assetconverter from amd. Will return a new hair instance!

PrepareSimulationParameters ( ) : void

This function will get used by importers for example if there were only strand vertex positions available. It will calculate everything inside of the HairStrand and HairStrandVertex based off the vertex positions. It also calculates the bounding sphere parameters.

SetHairMesh ( int index, HairMesh mesh ) : void

Sets the given hairmesh into the given index. NOTE: TressFX only supports indices 0-3 (so max. 4 meshes).

SimulationPrecheck ( ) : bool

Returns true if the hair strands are all having a vertex count of 16. Developer Note: This will may get extended later on in order to do more advanced checks if simulation will run correctly.

Private Methods

Method Description
BranchingAvoidance ( uint threadGroupSize = 64 ) : void

This is called in PrepareSimulationParameters(). It may deletes some hairs in order to avoid branching in the compute shader.

CreateHairSimulationData ( ) : TressFXLib.HairSimulationData

Creates a new HairSimulationData object and fills it with data from this hair's hair meshes. It can get used to "easy-export" tressfx-ready data-arrays from hair objects.

Method Details

CreateBoundingSphere() public method

Implicitly initializes the bounding sphere. Calculates the bounding sphere automatically
public CreateBoundingSphere ( ) : void
return void

CreateIndices() public method

Implicitly initializes the indices of this hair. This calculates the indices automatically
public CreateIndices ( ) : void
return void

CreateUVs() public method

UV-Maps the hair. The uv-coordinates will look like this: { STRAND_INDEX / STRAND_COUNT, VERTEX_INDEX / VERTEX_COUNT_IN_STRAND, 0, 0 }
public CreateUVs ( ) : void
return void

Export() public method

Exports this hair to the given file format output.
public Export ( HairFormat format, string path ) : void
format HairFormat
path string
return void

Export() public method

Exports this hair to the given file format class instance.
public Export ( IHairFormat format, string path ) : void
format IHairFormat
path string
return void

GenerateFollowHairs() public method

Performs follow hair generation. If a hair file gets imported from a "not-tressfx" format like ase every hair will be set to be a guidance hair. With this functions its possible to generate hairs which will not get simulated, but moved along their guidance hair. This can get used to make hair more dense without simulation overhead.
public GenerateFollowHairs ( int followHairsPerGuidanceHair, float maxRadiusAroundGuideHair ) : void
followHairsPerGuidanceHair int
maxRadiusAroundGuideHair float
return void

Import() public static method

Loads / imports hair from the given file with given format.
public static Import ( HairFormat format, string path, TressFXLib.HairImportSettings importSettings = null ) : Hair
format HairFormat
path string
importSettings TressFXLib.HairImportSettings
return Hair

InitializeBoundingSphere() public method

Explicitly initializes the bounding sphere. Only used if the bounding sphere is loaded on import, for example in tfxb.
public InitializeBoundingSphere ( System.Vector3 center, float radius ) : void
center System.Vector3
radius float
return void

InitializeIndices() public method

Explicitly initialized the indices of this hair. This function is only used if the indices are imported with the hair data, for example in tfxb. Only initialize them manually if you know what you are doing. They will get generated automatically in the getter functions.
public InitializeIndices ( int lineIndices, int triangleIndices ) : void
lineIndices int
triangleIndices int
return void

InitializeSimulationData() public method

Explicitly initializes the simulation data. This is used in for example the tressfx binary importer.
public InitializeSimulationData ( TressFXLib.HairSimulationData hairSimulationData ) : void
hairSimulationData TressFXLib.HairSimulationData
return void

NormalizeStrands() public method

This function is used to make sure that every hair strand has the same vertex position. It uses linear interpolation in order to do so. After calling this, the simulation data must get reprepared, because the hair vertices will get reset.
public NormalizeStrands ( int normalizedVertexCount ) : void
normalizedVertexCount int
return void

PrepareSimulationParamatersAssetConverter() public method

TEMPORARY FUNCTION! THIS WILL GET REMOVED IN THE NEAR FUTURE! Prepares the simulation parameters by using a binary executable of the assetconverter from amd. Will return a new hair instance!
public PrepareSimulationParamatersAssetConverter ( int followHairs, float maxRadiusAround, string assetConverterExePath ) : Hair
followHairs int
maxRadiusAround float
assetConverterExePath string
return Hair

PrepareSimulationParameters() public method

This function will get used by importers for example if there were only strand vertex positions available. It will calculate everything inside of the HairStrand and HairStrandVertex based off the vertex positions. It also calculates the bounding sphere parameters.
public PrepareSimulationParameters ( ) : void
return void

SetHairMesh() public method

Sets the given hairmesh into the given index. NOTE: TressFX only supports indices 0-3 (so max. 4 meshes).
public SetHairMesh ( int index, HairMesh mesh ) : void
index int
mesh HairMesh
return void

SimulationPrecheck() public method

Returns true if the hair strands are all having a vertex count of 16. Developer Note: This will may get extended later on in order to do more advanced checks if simulation will run correctly.
public SimulationPrecheck ( ) : bool
return bool