Class MotionProperties

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

public class MotionProperties extends JoltPhysicsObject implements ConstMotionProperties
Additional state for a Body that moves.
  • Constructor Details

    • MotionProperties

      public MotionProperties()
      Instantiate default properties.
  • Method Details

    • moveKinematic

      public void moveKinematic(Vec3Arg offset, QuatArg rotation, float deltaTime)
      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

      public void setAngularVelocity(Vec3Arg omega)
      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

      public void setInverseInertia(Vec3Arg diagonal, QuatArg rotation)
      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

      public void setLinearVelocity(Vec3Arg velocity)
      Directly alter the linear velocity.
      Parameters:
      velocity - the desired velocity (meters per second in system coordinates, not null, unaffected, default=(0,0,0))
    • setMassProperties

      public void setMassProperties(int allowedDofs, ConstMassProperties massProperties)
      Alter the mass properties.
      Parameters:
      allowedDofs - logical OR of values defined in EAllowedDofs (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 the PhysicsSettings
    • 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 the PhysicsSettings
    • getAccumulatedForce

      public Vec3 getAccumulatedForce()
      Copy the net force acting on the body. The properties are unaffected.
      Specified by:
      getAccumulatedForce in interface ConstMotionProperties
      Returns:
      a new force vector (Newtons in system coordinates)
    • getAccumulatedTorque

      public Vec3 getAccumulatedTorque()
      Copy the net torque acting on the body. The properties are unaffected.
      Specified by:
      getAccumulatedTorque in interface ConstMotionProperties
      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 interface ConstMotionProperties
      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 interface ConstMotionProperties
      Returns:
      true if allowed, otherwise false
    • getAngularDamping

      public float getAngularDamping()
      Return the angular damping coefficient. The properties are unaffected.
      Specified by:
      getAngularDamping in interface ConstMotionProperties
      Returns:
      the coefficient value (in units of per second, ≥0, ≤1)
    • getAngularDofsMask

      public UVec4 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 interface ConstMotionProperties
      Returns:
      a new vector
    • getAngularVelocity

      public Vec3 getAngularVelocity()
      Copy the angular velocity. The properties are unaffected.
      Specified by:
      getAngularVelocity in interface ConstMotionProperties
      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 interface ConstMotionProperties
      Returns:
      the factor
    • getInertiaRotation

      public Quat getInertiaRotation()
      Copy the rotation that takes the inverse-inertia diagonal to local coordinates. The properties are unaffected.
      Specified by:
      getInertiaRotation in interface ConstMotionProperties
      Returns:
      a new object
    • getInverseInertiaDiagonal

      public Vec3 getInverseInertiaDiagonal()
      Copy the diagonal components of the inverse inertia matrix, assuming a dynamic body. The properties are unaffected.
      Specified by:
      getInverseInertiaDiagonal in interface ConstMotionProperties
      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 interface ConstMotionProperties
      Returns:
      the value (≥0)
    • getInverseMassUnchecked

      public float getInverseMassUnchecked()
      Return the body's inverse mass. The properties are unaffected.
      Specified by:
      getInverseMassUnchecked in interface ConstMotionProperties
      Returns:
      the value (≥0)
    • getLinearDamping

      public float getLinearDamping()
      Return the linear damping coefficient. The properties are unaffected.
      Specified by:
      getLinearDamping in interface ConstMotionProperties
      Returns:
      the coefficient value (in units of per second, ≥0, ≤1)
    • getLinearVelocity

      public Vec3 getLinearVelocity()
      Copy the linear velocity. The properties are unaffected.
      Specified by:
      getLinearVelocity in interface ConstMotionProperties
      Returns:
      a new velocity vector (meters per second in system coordinates)
    • getLocalSpaceInverseInertia

      public Mat44 getLocalSpaceInverseInertia()
      Copy the inverse-inertia matrix. The properties are unaffected.
      Specified by:
      getLocalSpaceInverseInertia in interface ConstMotionProperties
      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 interface ConstMotionProperties
      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 interface ConstMotionProperties
      Returns:
      the speed limit (in meters per second)
    • getMotionQuality

      public EMotionQuality getMotionQuality()
      Return the motion quality. The properties are unaffected.
      Specified by:
      getMotionQuality in interface ConstMotionProperties
      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 interface ConstMotionProperties
      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 interface ConstMotionProperties
      Returns:
      the count (>0) or 0 to use number specified in the PhysicsSettings