- All Implemented Interfaces:
ConstJoltPhysicsObject,ConstSpringSettings,AutoCloseable,Comparable<JoltPhysicsObject>
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiate default settings.SpringSettings(ConstSpringSettings original) Instantiate a copy of the specified settings. -
Method Summary
Modifier and TypeMethodDescriptionAccess the underlyingConstraint, if any.Access the underlyingConstraintSettings, if any.floatReturn the spring's damping.floatReturn the spring's frequency.getMode()Return how the spring is specified.floatReturn the spring's stiffness.booleanTest for valid frequency/stiffness.voidrestoreBinaryState(StreamIn stream) Load settings from the specified binary stream.voidsaveBinaryState(StreamOut stream) Save the settings to the specified binary stream.setDamping(float damping) Alter the spring's damping.setFrequency(float frequency) Alter the spring's frequency.setMode(ESpringMode mode) Alter how the spring is specified.setStiffness(float stiffness) Alter the stiffness of the spring.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, 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
-
Constructor Details
-
SpringSettings
public SpringSettings()Instantiate default settings. -
SpringSettings
Instantiate a copy of the specified settings.- Parameters:
original- the settings to copy (notnull, unaffected)
-
-
Method Details
-
restoreBinaryState
Load settings from the specified binary stream.- Parameters:
stream- the stream to read from (not null)
-
setDamping
Alter the spring's damping. (native attribute: mDamping)When the mode is FrequencyAndDamping, this is the damping ratio (0 = no damping, 1 = critical damping). When the mode is StiffnessAndDamping, this is the damping coefficient
cin the spring equation:F = -k * x - c * vfor a linear spring orT = -k * theta - c * wfor an angular spring.- Parameters:
damping- the desired damping (default=0)- Returns:
- the modified settings, for chaining
-
setFrequency
Alter the spring's frequency. (native attribute: mFrequency)Effective only when the mode is FrequencyAndDamping. If positive, the constraint will have soft limits, and mFrequency specifies the oscillation frequency in Hz. Otherwise, the constraint will have hard limits.
- Parameters:
frequency- the desired frequency (default=0)- Returns:
- the modified settings, for chaining
-
setMode
Alter how the spring is specified. (native attribute: mMode)- Parameters:
mode- the desired mode (not null, default=FrequencyAndDamping)- Returns:
- the modified settings, for chaining
-
setStiffness
Alter the stiffness of the spring. (native attribute: mStiffness)Effective only when the mode is StiffnessAndDamping. If positive, the constraint will have soft limits, and mStiffness specifies the stiffness
kin the spring equation:F = -k * x - c * vfor a linear spring orT = -k * theta - c * wfor an angular spring.If negative, the constraint will have hard limits.
- Parameters:
stiffness- (default=0)- Returns:
- the modified settings, for chaining
-
getConstraint
Access the underlyingConstraint, if any.- Specified by:
getConstraintin interfaceConstSpringSettings- Returns:
- the pre-existing instance, or
nullif none
-
getConstraintSettings
Access the underlyingConstraintSettings, if any.- Specified by:
getConstraintSettingsin interfaceConstSpringSettings- Returns:
- the pre-existing instance, or
nullif none
-
getDamping
public float getDamping()Return the spring's damping. The settings are unaffected. (native attribute: mDamping)When the mode is FrequencyAndDamping, this is the damping ratio (0 = no damping, 1 = critical damping). When the mode is StiffnessAndDamping, this is the damping coefficient
cin the spring equation:F = -k * x - c * vfor a linear spring orT = -k * theta - c * wfor an angular spring.- Specified by:
getDampingin interfaceConstSpringSettings- Returns:
- the damping value
-
getFrequency
public float getFrequency()Return the spring's frequency. The settings are unaffected. (native attribute: mFrequency)Effective only when the mode is FrequencyAndDamping. If positive, the constraint will have soft limits, and mFrequency specifies the oscillation frequency in Hz. If negative, the constraint will have hard limits.
- Specified by:
getFrequencyin interfaceConstSpringSettings- Returns:
- the frequency value
-
getMode
Return how the spring is specified. The settings are unaffected. (native attribute: mMode)- Specified by:
getModein interfaceConstSpringSettings- Returns:
- an enum value (not null)
-
getStiffness
public float getStiffness()Return the spring's stiffness. The settings are unaffected. (native attribute: mStiffness)Effective only when the mode is StiffnessAndDamping. If positive, the constraint will have soft limits, and mStiffness specifies the stiffness
kin the spring equation:F = -k * x - c * vfor a linear spring orT = -k * theta - c * wfor an angular spring.If negative, the constraint will have hard limits.
- Specified by:
getStiffnessin interfaceConstSpringSettings- Returns:
- the stiffness value
-
hasStiffness
public boolean hasStiffness()Test for valid frequency/stiffness. The settings are unaffected.- Specified by:
hasStiffnessin interfaceConstSpringSettings- Returns:
trueif valid (the constraint will have soft limits), otherwisefalse(hard limits)
-
saveBinaryState
Save the settings to the specified binary stream. The settings are unaffected.- Specified by:
saveBinaryStatein interfaceConstSpringSettings- Parameters:
stream- the stream to write to (not null)
-