C# Class TressFXLib.Hair

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

Méthodes publiques

Méthode 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

Méthode 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 méthode

Implicitly initializes the bounding sphere. Calculates the bounding sphere automatically
public CreateBoundingSphere ( ) : void
Résultat void

CreateIndices() public méthode

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

CreateUVs() public méthode

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
Résultat void

Export() public méthode

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

Export() public méthode

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

GenerateFollowHairs() public méthode

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
Résultat void

Import() public static méthode

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
Résultat Hair

InitializeBoundingSphere() public méthode

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
Résultat void

InitializeIndices() public méthode

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
Résultat void

InitializeSimulationData() public méthode

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

NormalizeStrands() public méthode

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
Résultat void

PrepareSimulationParamatersAssetConverter() public méthode

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
Résultat Hair

PrepareSimulationParameters() public méthode

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
Résultat void

SetHairMesh() public méthode

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
Résultat void

SimulationPrecheck() public méthode

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
Résultat bool