java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.HairSettings
All Implemented Interfaces:
ConstHairSettings, ConstJoltPhysicsObject, RefTarget, AutoCloseable, Comparable<JoltPhysicsObject>

public final class HairSettings extends JoltPhysicsObject implements ConstHairSettings, RefTarget
Settings used to construct a hair simulation.
  • Field Details

    • cDefaultIterationsPerSecond

      public static final int cDefaultIterationsPerSecond
      default simulation rate for hair (in iterations per second)
      See Also:
  • Constructor Details

    • HairSettings

      public HairSettings()
      Instantiate default settings.
    • HairSettings

      public HairSettings(ConstHairSettings original)
      Instantiate a copy of the specified settings.
      Parameters:
      original - the settings to copy (not null, unaffected)
  • Method Details

    • addMaterial

      public void addMaterial(ConstHairMaterial material)
      Append the specified material. (native member: mMaterial)
      Parameters:
      material - the material to add (not null)
    • getMaterials

      public HairMaterial[] getMaterials()
      Access the materials. (native member: mMaterial)
      Returns:
      a new array containing new JVM objects with the pre-existing native objects assigned
    • getRenderStrands

      public RStrand[] getRenderStrands()
      Access the render strands. (native member: mRenderStrands)
      Returns:
      a new array containing new JVM objects with the pre-existing native objects assigned
    • getScalpTriangles

      public IndexedTriangleNoMaterial[] getScalpTriangles()
      Access the vertex indices of the triangles in the scalp mesh. (native member: mScalpTriangles)
      Returns:
      a new array containing new JVM objects with the pre-existing native objects assigned
    • init

      public void init(float[] maxDistSqHairToScalp)
      Calculate simulation bounds and vertex properties.
      Parameters:
      maxDistSqHairToScalp - storage for the maximum squared distance of a root vertex from the scalp (not null, length>0)
    • initCompute

      public void initCompute(ComputeSystem system)
      Further initialization to set up compute buffers. Invoke after init().
      Parameters:
      system - the compute system to use (not null)
    • initRenderAndSimulationStrands

      public void initRenderAndSimulationStrands(SVertexList vertices, SStrandList strands)
      Split the supplied strands into render and simulation strands and calculate connections between them.
      Parameters:
      vertices - the vertices to be used in strands (not null)
      strands - the strands to use (not null)
    • restoreBinaryState

      public void restoreBinaryState(StreamIn streamIn)
      Read the state of this object from the specified stream, excluding the shape and group filter.
      Parameters:
      streamIn - where to read objects from (not null)
    • setInitialGravity

      public HairSettings setInitialGravity(Vec3Arg gravity)
      Alter the initial gravity vector. (native member: mInitialGravity)
      Parameters:
      gravity - the desired acceleration vector (meters per second squared in system coordinates, not null, unaffected, default=(0,-9.81,0))
      Returns:
      the modified settings, for chaining
    • setNumIterationsPerSecond

      public HairSettings setNumIterationsPerSecond(int numIterations)
      Alter the iteration rate. (native member: mNumIterationsPerSecond)
      Parameters:
      numIterations - the desired number of iterations (≥1, default=360)
      Returns:
      the modified settings, for chaining
    • setScalpInverseBindPose

      public HairSettings setScalpInverseBindPose(Mat44Arg... pose)
      Alter the scalp mesh-vertex locations in bind pose. (native member: mScalpInverseBindPose)
      Parameters:
      pose - the desired pose (not null, unaffected)
      Returns:
      the modified settings, for chaining
    • setScalpNumSkinWeightsPerVertex

      public HairSettings setScalpNumSkinWeightsPerVertex(int numWeights)
      Alter the number of skinning weights per vertex. (native member: mScalpNumSkinWeightsPerVertex)
      Parameters:
      numWeights - the desired number of weights (≥0, default=0)
      Returns:
      the modified settings, for chaining
    • setScalpSkinWeights

      public HairSettings setScalpSkinWeights(HairSkinWeight... weights)
      Alter the scalp skinning weights. (native member: mScalpSkinWeights)
      Parameters:
      weights - the desired weights of the scalp mesh (not null, mScalpNumSkinWeightsPerVertex elements per vertex, unaffected)
      Returns:
      the modified settings, for chaining
    • setScalpTriangles

      public HairSettings setScalpTriangles(ConstIndexedTriangleNoMaterial... triangles)
      Alter the scalp mesh-triangle indices. (native member: mScalpTriangles)
      Parameters:
      triangles - the desired vertex indices (not null, unaffected)
      Returns:
      the modified settings, for chaining
    • setScalpVertices

      public HairSettings setScalpVertices(ConstFloat3... vertices)
      Alter the scalp mesh-vertex locations. (native member: mScalpVertices)
      Parameters:
      vertices - the desired locations (not null, unaffected)
      Returns:
      the modified settings, for chaining
    • setSimulationBoundsPadding

      public HairSettings setSimulationBoundsPadding(Vec3Arg padding)
      Alter how much padding to add on all sides of the neutral pose when determining the bounds of the simulation grid. (native member: mSimulationBoundsPadding)
      Parameters:
      padding - the desired amount of padding along each axis (in meters, not null)
      Returns:
      the modified settings, for chaining
    • sResample

      public static void sResample(SVertexList vertices, SStrandList strands, int numVerticesPerStrand)
      Resample the hairs to the specified number of vertices per strand. Invoke before init().
      Parameters:
      vertices - the vertex list to use (not null)
      strands - the strands to use (not null)
      numVerticesPerStrand - the desired number of vertices per strand
    • countMaterials

      public int countMaterials()
      Return the number of materials. The settings are unaffected. (native member: mMaterial)
      Specified by:
      countMaterials in interface ConstHairSettings
      Returns:
      the count (≥0)
    • countRenderStrands

      public int countRenderStrands()
      Return the number of render strands. The settings are unaffected. (native member: mRenderStrands)
      Specified by:
      countRenderStrands in interface ConstHairSettings
      Returns:
      the count (≥0)
    • countRenderVertices

      public int countRenderVertices()
      Return the number of render vertices. The settings are unaffected. (native member: mRenderVertices)
      Specified by:
      countRenderVertices in interface ConstHairSettings
      Returns:
      the count (≥0)
    • countScalpTriangles

      public int countScalpTriangles()
      Return the number of triangles in the scalp mesh. The settings are unaffected. (native member: mScalpTriangles)
      Specified by:
      countScalpTriangles in interface ConstHairSettings
      Returns:
      the count (≥0)
    • countScalpVertices

      public int countScalpVertices()
      Return the number of vertices in the scalp mesh. The settings are unaffected. (native member: mScalpVertices)
      Specified by:
      countScalpVertices in interface ConstHairSettings
      Returns:
      the count (≥0)
    • countSimStrands

      public int countSimStrands()
      Return the number of simulation strands. The settings are unaffected. (native member: mSimStrands)
      Specified by:
      countSimStrands in interface ConstHairSettings
      Returns:
      the count (≥0)
    • getInitialGravity

      public Vec3 getInitialGravity()
      Copy the initial gravity vector. The settings are unaffected. (native member: mInitialGravity)
      Specified by:
      getInitialGravity in interface ConstHairSettings
      Returns:
      a new vector (in meters per second squared)
    • getMaterial

      public HairMaterial getMaterial(int index)
      Access the specified material. (native member: mMaterial)
      Specified by:
      getMaterial in interface ConstHairSettings
      Parameters:
      index - the index of the material to access (≥0)
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getNumIterationsPerSecond

      public int getNumIterationsPerSecond()
      Return the iteration rate. The settings are unaffected. (native member: mNumIterationsPerSecond)
      Specified by:
      getNumIterationsPerSecond in interface ConstHairSettings
      Returns:
      the number of iterations per second (≥1)
    • getRenderStrand

      public RStrand getRenderStrand(int index)
      Access the specified render strand. (native member: mRenderStrands)
      Specified by:
      getRenderStrand in interface ConstHairSettings
      Parameters:
      index - the index of the strand to access (≥0)
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getScalpNumSkinWeightsPerVertex

      public int getScalpNumSkinWeightsPerVertex()
      Alter the number of skinning weights per vertex. The settings are unaffected. (native member: mScalpNumSkinWeightsPerVertex)
      Specified by:
      getScalpNumSkinWeightsPerVertex in interface ConstHairSettings
      Returns:
      the number of weights per vertex
    • getScalpTriangle

      public IndexedTriangleNoMaterial getScalpTriangle(int triangleIndex)
      Access the vertex indices of the specified triangle in the scalp mesh. (native member: mScalpTriangles)
      Specified by:
      getScalpTriangle in interface ConstHairSettings
      Parameters:
      triangleIndex - the index of the triangle to access (≥0)
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getScalpVertex

      public Float3 getScalpVertex(int vertexIndex)
      Copy the specified vertex in the scalp mesh. The settings are unaffected. (native member: mScalpVertices)
      Specified by:
      getScalpVertex in interface ConstHairSettings
      Parameters:
      vertexIndex - the index of the vertex to access (≥0)
      Returns:
      a new vector
    • getSimStrand

      public SStrand getSimStrand(int strandIndex)
      Access the specified simulation strand. (native member: mSimStrands)
      Specified by:
      getSimStrand in interface ConstHairSettings
      Parameters:
      strandIndex - the index of the strand to access (≥0)
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getSimulationBounds

      public AaBox getSimulationBounds()
      Access the simulation bounds. (native member: mSimulationBounds)
      Specified by:
      getSimulationBounds in interface ConstHairSettings
      Returns:
      a new JVM object with the pre-existing native object assigned
    • saveBinaryState

      public void saveBinaryState(StreamOut streamOut)
      Write the state of this object to the specified stream, excluding the compute buffers. The settings are unaffected.
      Specified by:
      saveBinaryState in interface ConstHairSettings
      Parameters:
      streamOut - where to write objects (not null)
    • getRefCount

      public int getRefCount()
      Count the active references to the native HairSettings. The scene is unaffected.
      Specified by:
      getRefCount in interface RefTarget
      Returns:
      the count (≥0)
    • setEmbedded

      public void setEmbedded()
      Mark the native HairSettings as embedded.
      Specified by:
      setEmbedded in interface RefTarget
    • toRef

      public HairSettingsRef toRef()
      Create a counted reference to the native HairSettings.
      Specified by:
      toRef in interface RefTarget
      Returns:
      a new JVM object with a new native object assigned