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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCopy the net force acting on the body.Copy the net torque acting on the body.int
Return the allowed degrees of freedom.boolean
Test whether the body is allowed to fall asleep.float
Return 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.float
Return 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.float
Return the body's inverse mass.float
Return the body's inverse mass.float
Return the linear damping coefficient.Copy the linear velocity.Copy the inverse-inertia matrix.float
Return the maximum angular speed that the body can achieve.float
Return the maximum linear speed that the body can achieve.Return the motion quality.int
Return the number of position iterations used in the solver.int
Return the number of velocity iterations used in the solver.void
moveKinematic
(Vec3Arg offset, QuatArg rotation, float deltaTime) Reposition the body, assuming it's kinematic.void
Zero out the accumulated force.void
Zero out the accumulated torque.void
setAngularDamping
(float damping) Alter the angular damping.void
setAngularVelocity
(Vec3Arg omega) Directly alter the angular velocity.void
setGravityFactor
(float factor) Alter the gravity factor.void
setInverseInertia
(Vec3Arg diagonal, QuatArg rotation) Alter the diagonal components of the inverse inertia matrix of the body.void
setInverseMass
(float inverseMass) Alter the inverse mass.void
setLinearDamping
(float damping) Alter the linear damping.void
setLinearVelocity
(Vec3Arg velocity) Directly alter the linear velocity.void
setMassProperties
(int allowedDofs, ConstMassProperties massProperties) Alter the mass properties.void
setMaxAngularVelocity
(float maxSpeed) Return the maximum angular speed that the body can achieve.void
setMaxLinearVelocity
(float maxSpeed) Return the maximum linear speed that the body can achieve.void
setNumPositionStepsOverride
(int numIterations) Alter the number of position iterations to use in the solvervoid
setNumVelocityStepsOverride
(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, 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
-
MotionProperties
public MotionProperties()Instantiate default properties.
-
-
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:
getAccumulatedForce
in 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:
getAccumulatedTorque
in 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:
getAllowedDofs
in 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:
getAllowSleeping
in interfaceConstMotionProperties
- Returns:
true
if allowed, otherwisefalse
-
getAngularDamping
public float getAngularDamping()Return the angular damping coefficient. The properties are unaffected.- Specified by:
getAngularDamping
in 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:
getAngularDofsMask
in interfaceConstMotionProperties
- Returns:
- a new vector
-
getAngularVelocity
Copy the angular velocity. The properties are unaffected.- Specified by:
getAngularVelocity
in 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:
getGravityFactor
in interfaceConstMotionProperties
- Returns:
- the factor
-
getInertiaRotation
Copy the rotation that takes the inverse-inertia diagonal to local coordinates. The properties are unaffected.- Specified by:
getInertiaRotation
in 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:
getInverseInertiaDiagonal
in interfaceConstMotionProperties
- Returns:
- a new vector (all components ≥0)
-
getInverseMass
public float getInverseMass()Return the body's inverse mass. The properties are unaffected.- Specified by:
getInverseMass
in interfaceConstMotionProperties
- Returns:
- the value (≥0)
-
getInverseMassUnchecked
public float getInverseMassUnchecked()Return the body's inverse mass. The properties are unaffected.- Specified by:
getInverseMassUnchecked
in interfaceConstMotionProperties
- Returns:
- the value (≥0)
-
getLinearDamping
public float getLinearDamping()Return the linear damping coefficient. The properties are unaffected.- Specified by:
getLinearDamping
in interfaceConstMotionProperties
- Returns:
- the coefficient value (in units of per second, ≥0, ≤1)
-
getLinearVelocity
Copy the linear velocity. The properties are unaffected.- Specified by:
getLinearVelocity
in interfaceConstMotionProperties
- Returns:
- a new velocity vector (meters per second in system coordinates)
-
getLocalSpaceInverseInertia
Copy the inverse-inertia matrix. The properties are unaffected.- Specified by:
getLocalSpaceInverseInertia
in 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:
getMaxAngularVelocity
in 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:
getMaxLinearVelocity
in interfaceConstMotionProperties
- Returns:
- the speed limit (in meters per second)
-
getMotionQuality
Return the motion quality. The properties are unaffected.- Specified by:
getMotionQuality
in 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:
getNumPositionStepsOverride
in 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:
getNumVelocityStepsOverride
in interfaceConstMotionProperties
- Returns:
- the count (>0) or 0 to use number specified in the
PhysicsSettings
-