Package com.github.stephengold.joltjni
Class HeightFieldShapeSettings
java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.SerializableObject
com.github.stephengold.joltjni.ShapeSettings
com.github.stephengold.joltjni.HeightFieldShapeSettings
- All Implemented Interfaces:
ConstHeightFieldShapeSettings,ConstJoltPhysicsObject,ConstSerializableObject,ConstShapeSettings,RefTarget,AutoCloseable,Comparable<JoltPhysicsObject>
public class HeightFieldShapeSettings
extends ShapeSettings
implements ConstHeightFieldShapeSettings
Settings used to construct a
HeightFieldShape.-
Constructor Summary
ConstructorsConstructorDescriptionInstantiate the default settings.HeightFieldShapeSettings(float[] samples, float offsetX, float offsetY, float offsetZ, float scaleX, float scaleY, float scaleZ, int sampleCount, byte[] materialIndices, PhysicsMaterialList materialList) Instantiate settings for the specified samples.HeightFieldShapeSettings(float[] samples, Vec3Arg offset, Vec3Arg scale, int sampleCount) Instantiate settings for the specified samples.HeightFieldShapeSettings(float[] samples, Vec3Arg offset, Vec3Arg scale, int sampleCount, byte[] materialIndices) Instantiate settings for the specified samples.HeightFieldShapeSettings(float[] samples, Vec3Arg offset, Vec3Arg scale, int sampleCount, byte[] materialIndices, PhysicsMaterialList materialList) Instantiate settings for the specified samples.Instantiate a copy of the specified settings.HeightFieldShapeSettings(FloatBuffer samples, float offsetX, float offsetY, float offsetZ, float scaleX, float scaleY, float scaleZ, int sampleCount) Instantiate settings for the specified samples.HeightFieldShapeSettings(FloatBuffer samples, float offsetX, float offsetY, float offsetZ, float scaleX, float scaleY, float scaleZ, int sampleCount, byte[] materialIndices, PhysicsMaterialList materialList) Instantiate settings for the specified samples.HeightFieldShapeSettings(FloatBuffer samples, Vec3Arg offset, Vec3Arg scale, int sampleCount) Instantiate settings for the specified samples.HeightFieldShapeSettings(FloatBuffer samples, Vec3Arg offset, Vec3Arg scale, int sampleCount, byte[] materialIndices) Instantiate settings for the specified samples.HeightFieldShapeSettings(FloatBuffer samples, Vec3Arg offset, Vec3Arg scale, int sampleCount, byte[] materialIndices, PhysicsMaterialList materialList) Instantiate settings for the specified samples. -
Method Summary
Modifier and TypeMethodDescriptionintcalculateBitsPerSampleForError(float maxError) Calculate the minimum bits per sample that will provide the specified error tolerance.intCount the height samples, includingcNoCollisionValue.intCount the references in the material list, including null refs.intCount the squares.voiddetermineMinAndMaxSample(float[] storeMin, float[] storeMax, float[] storeQuantScale) Calculate 3 quantization parameters of the current settings.floatReturn the cosine of the active-edge threshold angle.intReturn the number of bits per sample to use during compression.intReturn the block size.floatgetHeightSample(int sampleIndex) Return the height of the specified sample.floatgetHeightSample(int x, int y) Return the height of the specified sample.intgetMaterialIndex(int squareIndex) Return the material index for the specified square.intgetMaterialIndex(int x, int y) Return the material index for the specified square.getMaterialRef(int materialIndex) Return a reference to the material for the specified material index.getMaterialRef(int x, int y) Return a reference to the material for the specified square.getMaterialRefForSquare(int squareIndex) Return a reference to the material for the specified square.Access the material list.intReturn the artificial minimum capacity for the created shape's material list.floatReturn the artificial maximum height.floatReturn the artificial minimum height.Copy the offset of the first sample.intCount the samples along each edge.getScale()Copy the scale factors.voidset(ConstHeightFieldShapeSettings source) Copy the argument to the current settings.voidsetActiveEdgeCosThresholdAngle(float cosine) Alter the active-edge threshold angle.voidsetBitsPerSample(int numBits) Alter the number of bits per sample to use during compression.voidsetBlockSize(int numRows) Alter the block size.voidsetHeightSample(int sampleIndex, float height) Alter the height of the specified sample.voidsetHeightSample(int x, int y, float height) Alter the height of the specified sample.voidsetMaterial(int materialIndex, PhysicsMaterialRef reference) Alter the material reference for the specified list index.voidsetMaterialIndex(int squareIndex, int materialIndex) Alter the material index of the specified square.voidsetMaterialIndex(int x, int y, int materialIndex) Alter the material index for the specified square.voidReplace the existing material list with a copy of the specified list.voidsetMaterialsCapacity(int numRefs) Alter the artificial minimum capacity for the created shape's material list.voidsetMaxHeightValue(float maxHeight) Alter the artificial maximum height.voidsetMinHeightValue(float minHeight) Alter the artificial minimum height.voidAlter the offset of the first sample.voidsetSampleCount(int sampleCount) Alter the number of samples along each dimension.voidAlter the scale factors.Methods inherited from class com.github.stephengold.joltjni.ShapeSettings
clearCachedResult, cloneShapeSettings, create, getRefCount, setEmbedded, setVirtualAddressAsCoOwner, toRef, toRefCMethods inherited from class com.github.stephengold.joltjni.SerializableObject
getRttiMethods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, targetVaOrZero, toString, vaMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa, targetVaOrZeroMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstSerializableObject
getRttiMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstShapeSettings
create, getRefCount, toRefC
-
Constructor Details
-
HeightFieldShapeSettings
public HeightFieldShapeSettings()Instantiate the default settings. -
HeightFieldShapeSettings
public HeightFieldShapeSettings(float[] samples, float offsetX, float offsetY, float offsetZ, float scaleX, float scaleY, float scaleZ, int sampleCount, byte[] materialIndices, PhysicsMaterialList materialList) Instantiate settings for the specified samples.- Parameters:
samples- array of height values (notnull, length≥4, unaffected)offsetX- the desired X offsetoffsetY- the desired Y offsetoffsetZ- the desired Z offsetscaleX- the desired scale factor on the local X axisscaleY- the desired scale factor on the local Y axisscaleZ- the desired scale factor on the local Z axissampleCount- the number of height values along each edge (≥2*blockSize)materialIndices- a material index for each sample (default=null)materialList- the list of materials
-
HeightFieldShapeSettings
Instantiate settings for the specified samples.- Parameters:
samples- array of height values (notnull, length≥4, unaffected)offset- (notnull, unaffected)scale- (notnull, unaffected)sampleCount- the number of height values along each edge (≥2*blockSize)
-
HeightFieldShapeSettings
public HeightFieldShapeSettings(float[] samples, Vec3Arg offset, Vec3Arg scale, int sampleCount, byte[] materialIndices) Instantiate settings for the specified samples.- Parameters:
samples- array of height values (notnull, length≥4, unaffected)offset- (notnull, unaffected)scale- (notnull, unaffected)sampleCount- the number of height values along each edge (≥2*blockSize)materialIndices- a material index for each sample (default=null)
-
HeightFieldShapeSettings
public HeightFieldShapeSettings(float[] samples, Vec3Arg offset, Vec3Arg scale, int sampleCount, byte[] materialIndices, PhysicsMaterialList materialList) Instantiate settings for the specified samples.- Parameters:
samples- array of height values (notnull, length≥4, unaffected)offset- (notnull, unaffected)scale- (notnull, unaffected)sampleCount- the number of height values along each edge (≥2*blockSize)materialIndices- a material index for each sample (default=null)materialList- the list of materials
-
HeightFieldShapeSettings
public HeightFieldShapeSettings(FloatBuffer samples, float offsetX, float offsetY, float offsetZ, float scaleX, float scaleY, float scaleZ, int sampleCount) Instantiate settings for the specified samples.- Parameters:
samples- array of height values (notnull, capacity≥4, unaffected)offsetX- the desired X offsetoffsetY- the desired Y offsetoffsetZ- the desired Z offsetscaleX- the desired scale factor on the local X axisscaleY- the desired scale factor on the local Y axisscaleZ- the desired scale factor on the local Z axissampleCount- the number of height values along each edge (≥2*blockSize)
-
HeightFieldShapeSettings
public HeightFieldShapeSettings(FloatBuffer samples, float offsetX, float offsetY, float offsetZ, float scaleX, float scaleY, float scaleZ, int sampleCount, byte[] materialIndices, PhysicsMaterialList materialList) Instantiate settings for the specified samples.- Parameters:
samples- array of height values (notnull, capacity≥4, unaffected)offsetX- the desired X offsetoffsetY- the desired Y offsetoffsetZ- the desired Z offsetscaleX- the desired scale factor on the local X axisscaleY- the desired scale factor on the local Y axisscaleZ- the desired scale factor on the local Z axissampleCount- the number of height values along each edge (≥2*blockSize)materialIndices- a material index for each sample (default=null)materialList- the list of materials
-
HeightFieldShapeSettings
public HeightFieldShapeSettings(FloatBuffer samples, Vec3Arg offset, Vec3Arg scale, int sampleCount) Instantiate settings for the specified samples.- Parameters:
samples- array of height values (notnull, capacity≥4, unaffected)offset- (notnull, unaffected)scale- (notnull, unaffected)sampleCount- the number of height values along each edge (≥2*blockSize)
-
HeightFieldShapeSettings
public HeightFieldShapeSettings(FloatBuffer samples, Vec3Arg offset, Vec3Arg scale, int sampleCount, byte[] materialIndices) Instantiate settings for the specified samples.- Parameters:
samples- array of height values (notnull, capacity≥4, unaffected)offset- (notnull, unaffected)scale- (notnull, unaffected)sampleCount- the number of height values along each edge (≥2*blockSize)materialIndices- a material index for each sample (default=null)
-
HeightFieldShapeSettings
public HeightFieldShapeSettings(FloatBuffer samples, Vec3Arg offset, Vec3Arg scale, int sampleCount, byte[] materialIndices, PhysicsMaterialList materialList) Instantiate settings for the specified samples.- Parameters:
samples- array of height values (notnull, capacity≥4, unaffected)offset- (notnull, unaffected)scale- (notnull, unaffected)sampleCount- the number of height values along each edge (≥2*blockSize)materialIndices- a material index for each sample (default=null)materialList- the list of materials
-
HeightFieldShapeSettings
Instantiate a copy of the specified settings.- Parameters:
original- the settings to copy (notnull, unaffected)
-
-
Method Details
-
getMaterials
Access the material list. (native attribute: mMaterials)- Returns:
- a new JVM object with the pre-existing native object assigned
-
set
Copy the argument to the current settings.- Parameters:
source- the settings to copy (notnull, unaffected)
-
setActiveEdgeCosThresholdAngle
public void setActiveEdgeCosThresholdAngle(float cosine) Alter the active-edge threshold angle. (native attribute: mActiveEdgeCosThresholdAngle)- Parameters:
cosine- the cosine of the desired angle (default=0.996195)
-
setBitsPerSample
public void setBitsPerSample(int numBits) Alter the number of bits per sample to use during compression. (native attribute: mBitsPerSample)- Parameters:
numBits- the number of bits (≥1, ≤16, default=8)
-
setBlockSize
public void setBlockSize(int numRows) Alter the block size. (native attribute: mBlockSize)For culling purposes, the height field is organized in blocks of
2 * mBlockSize * mBlockSizetriangles.Sensible values range from 2 to 8.
- Parameters:
numRows- the desired block size (in rows, default=2)
-
setHeightSample
public void setHeightSample(int sampleIndex, float height) Alter the height of the specified sample.- Parameters:
sampleIndex- the array index (≥0, <sampleCount^2)height- the desired height, orcNoCollisionValuefor no collision
-
setHeightSample
public void setHeightSample(int x, int y, float height) Alter the height of the specified sample.- Parameters:
x- the X index of the sample (≥0, <sampleCount)y- the Y index of the sample (≥0, <sampleCount)height- the desired height, orcNoCollisionValuefor no collision
-
setMaterial
Alter the material reference for the specified list index.- Parameters:
materialIndex- the list index at which to put the reference (≥0)reference- the reference to store (notnull)
-
setMaterialIndex
public void setMaterialIndex(int squareIndex, int materialIndex) Alter the material index of the specified square.- Parameters:
squareIndex- the index of the square (≥0, <(sampleCount-1)^2)materialIndex- the desired material index
-
setMaterialIndex
public void setMaterialIndex(int x, int y, int materialIndex) Alter the material index for the specified square.- Parameters:
x- the X index of the square (≥0, <sampleCount-1)y- the Y index of the square (≥0, <sampleCount-1)materialIndex- the desired index into the material list (≥0)
-
setMaterials
Replace the existing material list with a copy of the specified list. (native attribute: mMaterials)- Parameters:
list- the desired material for each material index
-
setMaterialsCapacity
public void setMaterialsCapacity(int numRefs) Alter the artificial minimum capacity for the created shape's material list. (native attribute: mMaterialsCapacity)- Parameters:
numRefs- the desired minimum capacity (in refs, default=0)
-
setMaxHeightValue
public void setMaxHeightValue(float maxHeight) Alter the artificial maximum height. (native attribute: mMaxHeightValue)- Parameters:
maxHeight- the desired height value (default=-1e15)
-
setMinHeightValue
public void setMinHeightValue(float minHeight) Alter the artificial minimum height. (native attribute: mMinHeightValue)- Parameters:
minHeight- the desired height value (default=1e15)
-
setOffset
Alter the offset of the first sample. (native attribute: mOffset)- Parameters:
offset- the desired offset vector (notnull, unaffected, default=(0,0,0))
-
setSampleCount
public void setSampleCount(int sampleCount) Alter the number of samples along each dimension. (native attribute: mSampleCount)- Parameters:
sampleCount- the desired number of samples (≥0, default=0)
-
setScale
Alter the scale factors. (native attribute: mScale)- Parameters:
scale- the desired scale factors (notnull, unaffected, default=(1,1,1))
-
calculateBitsPerSampleForError
public int calculateBitsPerSampleForError(float maxError) Calculate the minimum bits per sample that will provide the specified error tolerance. The settings are unaffected.- Specified by:
calculateBitsPerSampleForErrorin interfaceConstHeightFieldShapeSettings- Parameters:
maxError- the allowable tolerance- Returns:
- the (hypothetical) bits per sample
-
countHeights
public int countHeights()Count the height samples, includingcNoCollisionValue. The settings are unaffected.- Specified by:
countHeightsin interfaceConstHeightFieldShapeSettings- Returns:
- the actual number of samples in the array (≥0)
-
countMaterials
public int countMaterials()Count the references in the material list, including null refs. The settings are unaffected.- Specified by:
countMaterialsin interfaceConstHeightFieldShapeSettings- Returns:
- the actual number of references in the list (≥0)
-
countSquares
public int countSquares()Count the squares. The settings are unaffected.- Specified by:
countSquaresin interfaceConstHeightFieldShapeSettings- Returns:
- the actual number of material indices in the array (≥0)
-
determineMinAndMaxSample
public void determineMinAndMaxSample(float[] storeMin, float[] storeMax, float[] storeQuantScale) Calculate 3 quantization parameters of the current settings. The settings are unaffected.- Specified by:
determineMinAndMaxSamplein interfaceConstHeightFieldShapeSettings- Parameters:
storeMin- storage for the minimum height (ignoringcNoCollisionValue) orMIN_VALUEif no samples have collisionstoreMax- storage for the maximum height (ignoringcNoCollisionValue) orMAX_VALUEif no samples have collisionstoreQuantScale- storage for the quantization scale factor
-
getActiveEdgeCosThresholdAngle
public float getActiveEdgeCosThresholdAngle()Return the cosine of the active-edge threshold angle. The settings are unaffected. (native attribute: mActiveEdgeCosThresholdAngle)- Specified by:
getActiveEdgeCosThresholdAnglein interfaceConstHeightFieldShapeSettings- Returns:
- the cosine
-
getBitsPerSample
public int getBitsPerSample()Return the number of bits per sample to use during compression. The settings are unaffected. (native attribute: mBitsPerSample)- Specified by:
getBitsPerSamplein interfaceConstHeightFieldShapeSettings- Returns:
- the number of bits (≥1, ≤16)
-
getBlockSize
public int getBlockSize()Return the block size. The settings are unaffected. (native attribute: mBlockSize)For culling purposes, the height field is organized in blocks of
2 * mBlockSize * mBlockSizetriangles.Sensible values range from 2 to 8.
- Specified by:
getBlockSizein interfaceConstHeightFieldShapeSettings- Returns:
- the block size (in rows)
-
getHeightSample
public float getHeightSample(int sampleIndex) Return the height of the specified sample. The settings are unaffected.- Specified by:
getHeightSamplein interfaceConstHeightFieldShapeSettings- Parameters:
sampleIndex- the array index (≥0, <sampleCount^2)- Returns:
- the sample height or
cNoCollisionValue
-
getHeightSample
public float getHeightSample(int x, int y) Return the height of the specified sample. The settings are unaffected.- Specified by:
getHeightSamplein interfaceConstHeightFieldShapeSettings- Parameters:
x- the X index of the sample (≥0, <sampleCount)y- the Y index of the sample (≥0, <sampleCount)- Returns:
- the sample height or
cNoCollisionValue
-
getMaterialIndex
public int getMaterialIndex(int squareIndex) Return the material index for the specified square. The settings are unaffected.- Specified by:
getMaterialIndexin interfaceConstHeightFieldShapeSettings- Parameters:
squareIndex- the index of the square (≥0, <(sampleCount-1)^2)- Returns:
- an index into the material list (≥0)
-
getMaterialIndex
public int getMaterialIndex(int x, int y) Return the material index for the specified square. The settings are unaffected.- Specified by:
getMaterialIndexin interfaceConstHeightFieldShapeSettings- Parameters:
x- the X index of the square (≥0, <sampleCount-1)y- the Y index of the square (≥0, <sampleCount-1)- Returns:
- an index into the material list (≥0)
-
getMaterialRef
Return a reference to the material for the specified material index.- Specified by:
getMaterialRefin interfaceConstHeightFieldShapeSettings- Parameters:
materialIndex- the index in the local table (≥0)- Returns:
- a new counted reference to the existing material
-
getMaterialRef
Return a reference to the material for the specified square.- Specified by:
getMaterialRefin interfaceConstHeightFieldShapeSettings- Parameters:
x- the X index of the square (≥0, <sampleCount-1)y- the Y index of the square (≥0, <sampleCount-1)- Returns:
- a new counted reference to the existing material
-
getMaterialRefForSquare
Return a reference to the material for the specified square.- Specified by:
getMaterialRefForSquarein interfaceConstHeightFieldShapeSettings- Parameters:
squareIndex- the index of the square (≥0, <(sampleCount-1)^2)- Returns:
- a new counted reference to the existing material
-
getMaterialsCapacity
public int getMaterialsCapacity()Return the artificial minimum capacity for the created shape's material list. The settings are unaffected. (native attribute: mMaterialsCapacity)- Specified by:
getMaterialsCapacityin interfaceConstHeightFieldShapeSettings- Returns:
- the capacity (in refs)
-
getMaxHeightValue
public float getMaxHeightValue()Return the artificial maximum height. The settings are unaffected. (native attribute: mMaxHeightValue)- Specified by:
getMaxHeightValuein interfaceConstHeightFieldShapeSettings- Returns:
- the height value
-
getMinHeightValue
public float getMinHeightValue()Return the artificial minimum height. The settings are unaffected. (native attribute: mMinHeightValue)- Specified by:
getMinHeightValuein interfaceConstHeightFieldShapeSettings- Returns:
- the height value
-
getOffset
Copy the offset of the first sample. The settings are unaffected. (native attribute: mOffset)- Specified by:
getOffsetin interfaceConstHeightFieldShapeSettings- Returns:
- a new offset vector
-
getSampleCount
public int getSampleCount()Count the samples along each edge. The settings are unaffected. (native attribute: mSampleCount)- Specified by:
getSampleCountin interfaceConstHeightFieldShapeSettings- Returns:
- the number of samples (≥0)
-
getScale
Copy the scale factors. The settings are unaffected. (native attribute: mScale)- Specified by:
getScalein interfaceConstHeightFieldShapeSettings- Returns:
- a new scaling vector
-