java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.MotionProperties
- All Implemented Interfaces:
ConstJoltPhysicsObject,ConstMotionProperties,AutoCloseable,Comparable<JoltPhysicsObject>
- Direct Known Subclasses:
SoftBodyMotionProperties
Additional state for a
Body that moves.-
Constructor Summary
ConstructorsConstructorDescriptionInstantiate default properties.MotionProperties(ConstMotionProperties original) Instantiate a copy of the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionCopy the net force acting on the body.Copy the net torque acting on the body.intReturn the allowed degrees of freedom.booleanTest whether the body is allowed to fall asleep.floatReturn the angular damping coefficient.Generate a vector in which the disabled angular components are set to zero and enabled ones are set to -1.Copy the angular velocity.floatReturn the gravity factor.Copy the rotation that takes the inverse-inertia diagonal to local coordinates.Copy the diagonal components of the inverse inertia matrix, assuming a dynamic body.floatReturn the body's inverse mass.floatReturn the body's inverse mass.floatReturn the linear damping coefficient.Copy the linear velocity.Copy the inverse-inertia matrix.floatReturn the maximum angular speed that the body can achieve.floatReturn the maximum linear speed that the body can achieve.Return the motion quality.intReturn the number of position iterations used in the solver.intReturn the number of velocity iterations used in the solver.voidmoveKinematic(Vec3Arg offset, QuatArg rotation, float deltaTime) Reposition the body, assuming it's kinematic.voidZero out the accumulated force.voidZero out the accumulated torque.voidsetAngularDamping(float damping) Alter the angular damping.voidsetAngularVelocity(Vec3Arg omega) Directly alter the angular velocity.voidsetGravityFactor(float factor) Alter the gravity factor.voidsetInverseInertia(Vec3Arg diagonal, QuatArg rotation) Alter the diagonal components of the inverse inertia matrix of the body.voidsetInverseMass(float inverseMass) Alter the inverse mass.voidsetLinearDamping(float damping) Alter the linear damping.voidsetLinearVelocity(Vec3Arg velocity) Directly alter the linear velocity.voidsetMassProperties(int allowedDofs, ConstMassProperties massProperties) Alter the mass properties.voidsetMaxAngularVelocity(float maxSpeed) Return the maximum angular speed that the body can achieve.voidsetMaxLinearVelocity(float maxSpeed) Return the maximum linear speed that the body can achieve.voidsetNumPositionStepsOverride(int numIterations) Alter the number of position iterations to use in the solvervoidsetNumVelocityStepsOverride(int numIterations) Alter the number of velocity iterations to use in the solverMethods 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
-
MotionProperties
public MotionProperties()Instantiate default properties. -
MotionProperties
Instantiate a copy of the specified properties.- Parameters:
original- the settings to copy (notnull, unaffected)
-
-
Method Details
-
moveKinematic
Reposition the body, assuming it's kinematic.- Parameters:
offset- the desired offset (from the current location, not null, unaffected)rotation- the desired rotation (relative to the current orientation, not null, unaffected)deltaTime- time until the desired position is reached (in seconds, >0)
-
resetForce
public void resetForce()Zero out the accumulated force. -
resetTorque
public void resetTorque()Zero out the accumulated torque. -
setAngularDamping
public void setAngularDamping(float damping) Alter the angular damping.- Parameters:
damping- the desired coefficient value (in units of per second, ≥0, ≤1, default=0)
-
setAngularVelocity
Directly alter the angular velocity.- Parameters:
omega- the desired velocity (meters per second in system coordinates, not null, unaffected, default=(0,0,0))
-
setGravityFactor
public void setGravityFactor(float factor) Alter the gravity factor.- Parameters:
factor- the desired factor (default=0)
-
setInverseInertia
Alter the diagonal components of the inverse inertia matrix of the body. If inertia changes, mass should probably change as well.- Parameters:
diagonal- the desired diagonal elements (not null, unaffected)rotation- the desired orientation of the principal axes (not null, unaffected)
-
setInverseMass
public void setInverseMass(float inverseMass) Alter the inverse mass. If mass changes, inertia should probably change as well.- Parameters:
inverseMass- the desired value (in units of 1/mass)
-
setLinearDamping
public void setLinearDamping(float damping) Alter the linear damping.- Parameters:
damping- the desired value (in units of per second, ≥0, ≤1, default=0)
-
setLinearVelocity
Directly alter the linear velocity.- Parameters:
velocity- the desired velocity (meters per second in system coordinates, not null, unaffected, default=(0,0,0))
-
setMassProperties
Alter the mass properties.- Parameters:
allowedDofs- logical OR of values defined inEAllowedDofs(default=All)massProperties- the desired mass properties (not null, unaffected)
-
setMaxAngularVelocity
public void setMaxAngularVelocity(float maxSpeed) Return the maximum angular speed that the body can achieve.- Parameters:
maxSpeed- the speed limit (in radians per second, default=0)
-
setMaxLinearVelocity
public void setMaxLinearVelocity(float maxSpeed) Return the maximum linear speed that the body can achieve.- Parameters:
maxSpeed- the speed limit (in meters per second, default=0)
-
setNumPositionStepsOverride
public void setNumPositionStepsOverride(int numIterations) Alter the number of position iterations to use in the solver- Parameters:
numIterations- the desired count (>0) or 0 to use the number specified in thePhysicsSettings
-
setNumVelocityStepsOverride
public void setNumVelocityStepsOverride(int numIterations) Alter the number of velocity iterations to use in the solver- Parameters:
numIterations- the desired count (>0) or 0 to use the number specified in thePhysicsSettings
-
getAccumulatedForce
Copy the net force acting on the body. The properties are unaffected.- Specified by:
getAccumulatedForcein interfaceConstMotionProperties- Returns:
- a new force vector (Newtons in system coordinates)
-
getAccumulatedTorque
Copy the net torque acting on the body. The properties are unaffected.- Specified by:
getAccumulatedTorquein interfaceConstMotionProperties- Returns:
- a new torque vector (Newton.meters in system coordinates)
-
getAllowedDofs
public int getAllowedDofs()Return the allowed degrees of freedom. The properties are unaffected.- Specified by:
getAllowedDofsin interfaceConstMotionProperties- Returns:
- logical OR of values defined in
EAllowedDofs
-
getAllowSleeping
public boolean getAllowSleeping()Test whether the body is allowed to fall asleep. The properties are unaffected.- Specified by:
getAllowSleepingin interfaceConstMotionProperties- Returns:
trueif allowed, otherwisefalse
-
getAngularDamping
public float getAngularDamping()Return the angular damping coefficient. The properties are unaffected.- Specified by:
getAngularDampingin interfaceConstMotionProperties- Returns:
- the coefficient value (in units of per second, ≥0, ≤1)
-
getAngularDofsMask
Generate a vector in which the disabled angular components are set to zero and enabled ones are set to -1. The properties are unaffected.- Specified by:
getAngularDofsMaskin interfaceConstMotionProperties- Returns:
- a new vector
-
getAngularVelocity
Copy the angular velocity. The properties are unaffected.- Specified by:
getAngularVelocityin interfaceConstMotionProperties- Returns:
- a new velocity vector (radians per second in system coordinates)
-
getGravityFactor
public float getGravityFactor()Return the gravity factor. The properties are unaffected.- Specified by:
getGravityFactorin interfaceConstMotionProperties- Returns:
- the factor
-
getInertiaRotation
Copy the rotation that takes the inverse-inertia diagonal to local coordinates. The properties are unaffected.- Specified by:
getInertiaRotationin interfaceConstMotionProperties- Returns:
- a new object
-
getInverseInertiaDiagonal
Copy the diagonal components of the inverse inertia matrix, assuming a dynamic body. The properties are unaffected.- Specified by:
getInverseInertiaDiagonalin interfaceConstMotionProperties- Returns:
- a new vector (all components ≥0)
-
getInverseMass
public float getInverseMass()Return the body's inverse mass. The properties are unaffected.- Specified by:
getInverseMassin interfaceConstMotionProperties- Returns:
- the value (≥0)
-
getInverseMassUnchecked
public float getInverseMassUnchecked()Return the body's inverse mass. The properties are unaffected.- Specified by:
getInverseMassUncheckedin interfaceConstMotionProperties- Returns:
- the value (≥0)
-
getLinearDamping
public float getLinearDamping()Return the linear damping coefficient. The properties are unaffected.- Specified by:
getLinearDampingin interfaceConstMotionProperties- Returns:
- the coefficient value (in units of per second, ≥0, ≤1)
-
getLinearVelocity
Copy the linear velocity. The properties are unaffected.- Specified by:
getLinearVelocityin interfaceConstMotionProperties- Returns:
- a new velocity vector (meters per second in system coordinates)
-
getLocalSpaceInverseInertia
Copy the inverse-inertia matrix. The properties are unaffected.- Specified by:
getLocalSpaceInverseInertiain interfaceConstMotionProperties- Returns:
- a new object
-
getMaxAngularVelocity
public float getMaxAngularVelocity()Return the maximum angular speed that the body can achieve. The properties are unaffected.- Specified by:
getMaxAngularVelocityin interfaceConstMotionProperties- Returns:
- the speed limit (in radians per second)
-
getMaxLinearVelocity
public float getMaxLinearVelocity()Return the maximum linear speed that the body can achieve. The properties are unaffected.- Specified by:
getMaxLinearVelocityin interfaceConstMotionProperties- Returns:
- the speed limit (in meters per second)
-
getMotionQuality
Return the motion quality. The properties are unaffected.- Specified by:
getMotionQualityin interfaceConstMotionProperties- Returns:
- an enum value (not null)
-
getNumPositionStepsOverride
public int getNumPositionStepsOverride()Return the number of position iterations used in the solver. The properties are unaffected.- Specified by:
getNumPositionStepsOverridein interfaceConstMotionProperties- Returns:
- the count (>0) or 0 to use number specified in the
PhysicsSettings
-
getNumVelocityStepsOverride
public int getNumVelocityStepsOverride()Return the number of velocity iterations used in the solver. The properties are unaffected.- Specified by:
getNumVelocityStepsOverridein interfaceConstMotionProperties- Returns:
- the count (>0) or 0 to use number specified in the
PhysicsSettings
-