Package com.github.stephengold.joltjni
Class MotionProperties
java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.MotionProperties
- All Implemented Interfaces:
ConstJoltPhysicsObject,AutoCloseable,Comparable<ConstJoltPhysicsObject>
Additional state for a
Body that moves.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn the net force acting on the body.Return 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.Returns a vector in which the disabled angular components are set to zero and enabled ones are set to -1.Return the angular velocity.floatReturn the gravity factor.Return the rotation that takes the inverse-inertia diagonal to local coordinates.Return 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.Return the linear velocity.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, or 0 to use number specified in thePhysicsSettings.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, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, startCleaner, toString, va
-
Constructor Details
-
MotionProperties
public MotionProperties()Instantiate default properties.
-
-
Method Details
-
getAccumulatedForce
Return the net force acting on the body.- Returns:
- a new force vector (Newtons in system coordinates)
-
getAccumulatedTorque
Return the net torque acting on the body.- Returns:
- a new torque vector (Newton.meters in system coordinates)
-
getAllowedDofs
public int getAllowedDofs()Return the allowed degrees of freedom.- Returns:
- logical OR of values defined in
EAllowedDofs
-
getAllowSleeping
public boolean getAllowSleeping()Test whether the body is allowed to fall asleep.- Returns:
- true if allowed, otherwise false
-
getAngularDamping
public float getAngularDamping()Return the angular damping coefficient.- Returns:
- the coefficient value (in units of 1/second, ≥0, ≤1)
-
getAngularDofsMask
Returns a vector in which the disabled angular components are set to zero and enabled ones are set to -1.- Returns:
- a new vector
-
getAngularVelocity
Return the angular velocity.- Returns:
- a new velocity vector (radians per second in system coordinates)
-
getGravityFactor
public float getGravityFactor()Return the gravity factor.- Returns:
- the factor
-
getInertiaRotation
Return the rotation that takes the inverse-inertia diagonal to local coordinates.- Returns:
- a new instance
-
getInverseInertiaDiagonal
Return the diagonal components of the inverse inertia matrix, assuming a dynamic body.- Returns:
- a new vector (all components ≥0)
-
getInverseMass
public float getInverseMass()Return the body's inverse mass.- Returns:
- the value (≥0)
-
getInverseMassUnchecked
public float getInverseMassUnchecked()Return the body's inverse mass.- Returns:
- the value (≥0)
-
getLinearDamping
public float getLinearDamping()Return the linear damping coefficient.- Returns:
- the coefficient value (in units of 1/second, ≥0, ≤1)
-
getLinearVelocity
Return the linear velocity.- Returns:
- a new velocity vector (meters per second in system coordinates)
-
getMaxAngularVelocity
public float getMaxAngularVelocity()Return the maximum angular speed that the body can achieve.- Returns:
- the speed limit (in radians per second)
-
getMaxLinearVelocity
public float getMaxLinearVelocity()Return the maximum linear speed that the body can achieve.- Returns:
- the speed limit (in meters per second)
-
getMotionQuality
Return the motion quality.- Returns:
- an enum value (not null)
-
getNumPositionStepsOverride
public int getNumPositionStepsOverride()Return the number of position iterations used in the solver.- 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, or 0 to use number specified in thePhysicsSettings.- Returns:
- the count (>0) or 0 to use number specified in the
PhysicsSettings
-
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 1/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 1/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
-