- 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.float
Return the spring's damping.float
Return the spring's frequency.getMode()
Return how the spring is specified.float
Return the spring's stiffness.boolean
Test for valid frequency/stiffness.void
restoreBinaryState
(StreamIn stream) Load settings from the specified binary stream.void
saveBinaryState
(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, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, va
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods 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
c
in the spring equation:F = -k * x - c * v
for a linear spring orT = -k * theta - c * w
for 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
k
in the spring equation:F = -k * x - c * v
for a linear spring orT = -k * theta - c * w
for 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:
getConstraint
in interfaceConstSpringSettings
- Returns:
- the pre-existing instance, or
null
if none
-
getConstraintSettings
Access the underlyingConstraintSettings
, if any.- Specified by:
getConstraintSettings
in interfaceConstSpringSettings
- Returns:
- the pre-existing instance, or
null
if 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
c
in the spring equation:F = -k * x - c * v
for a linear spring orT = -k * theta - c * w
for an angular spring.- Specified by:
getDamping
in 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:
getFrequency
in interfaceConstSpringSettings
- Returns:
- the frequency value
-
getMode
Return how the spring is specified. The settings are unaffected. (native attribute: mMode)- Specified by:
getMode
in 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
k
in the spring equation:F = -k * x - c * v
for a linear spring orT = -k * theta - c * w
for an angular spring.If negative, the constraint will have hard limits.
- Specified by:
getStiffness
in interfaceConstSpringSettings
- Returns:
- the stiffness value
-
hasStiffness
public boolean hasStiffness()Test for valid frequency/stiffness. The settings are unaffected.- Specified by:
hasStiffness
in interfaceConstSpringSettings
- Returns:
true
if 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:
saveBinaryState
in interfaceConstSpringSettings
- Parameters:
stream
- the stream to write to (not null)
-