Class VehicleConstraint

All Implemented Interfaces:
ConstConstraint, ConstJoltPhysicsObject, ConstVehicleConstraint, RefTarget, AutoCloseable, Comparable<JoltPhysicsObject>

public class VehicleConstraint extends Constraint implements ConstVehicleConstraint
A special Constraint used in vehicle simulation.
  • Constructor Details

    • VehicleConstraint

      public VehicleConstraint(Body body, ConstVehicleConstraintSettings settings)
      Instantiate a constraint for the specified body and settings.
      Parameters:
      body - the body to which the constraint will apply (not null)
      settings - the desired settings (not null, unaffected)
  • Method Details

    • getController

      public VehicleController getController()
      Access the controller for this constraint.
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getStepListener

      public VehicleStepListener getStepListener()
      Access the vehicle's PhysicsStepListener. Since Java doesn't allow multiple inheritance, the listener is managed like a contained object.
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getVehicleBody

      public Body getVehicleBody()
      Access the vehicle body.
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getVehicleCollisionTester

      public VehicleCollisionTester getVehicleCollisionTester()
      Access the underlying tester, if any.
      Returns:
      the pre-existing instance or null if none
    • getWheel

      public Wheel getWheel(int wheelIndex)
      Access the specified wheel.
      Parameters:
      wheelIndex - the index of the wheel to access (≥0)
      Returns:
      a new JVM object with the pre-existing native object assigned
    • overrideGravity

      public void overrideGravity(float ax, float ay, float az)
      Override the vehicle's gravity vector.
      Parameters:
      ax - the X component of the desired acceleration vector
      ay - the Y component of the desired acceleration vector
      az - the Z component of the desired acceleration vector
    • overrideGravity

      public void overrideGravity(Vec3Arg acceleration)
      Override the vehicle's gravity vector.
      Parameters:
      acceleration - the desired acceleration vector (not null, unaffected)
    • resetGravityOverride

      public void resetGravityOverride()
      Remove the gravity override, if any.
    • setMaxPitchRollAngle

      public void setMaxPitchRollAngle(float angle)
      Alter the vehicle's maximum pitch/roll angle.
      Parameters:
      angle - the desired limit angle (in radians)
    • setNumStepsBetweenCollisionTestActive

      public void setNumStepsBetweenCollisionTestActive(int numSteps)
      Alter the number of simulation steps between wheel-collision tests when the vehicle is active.
      Parameters:
      numSteps - the desired number of steps (0=never test, 1=test every step, 2=test every other step, default=1)
    • setNumStepsBetweenCollisionTestInactive

      public void setNumStepsBetweenCollisionTestInactive(int numSteps)
      Alter the number of simulation steps between wheel-collision tests when the vehicle is inactive.
      Parameters:
      numSteps - the desired number of steps (0=never, 1=every step, 2=every other step, default=1)
    • setVehicleCollisionTester

      public void setVehicleCollisionTester(VehicleCollisionTester tester)
      Replace the collision tester.
      Parameters:
      tester - the desired tester (not null, counted reference created)
    • countAntiRollBars

      public int countAntiRollBars()
      Count how many anti-roll bars the vehicle has. The constraint is unaffected.
      Specified by:
      countAntiRollBars in interface ConstVehicleConstraint
      Returns:
      the count (≥0)
    • countWheels

      public int countWheels()
      Count how many wheels the vehicle has. The constraint is unaffected.
      Specified by:
      countWheels in interface ConstVehicleConstraint
      Returns:
      the count (≥0)
    • getAntiRollBar

      public VehicleAntiRollBar getAntiRollBar(int barIndex)
      Access the specified anti-roll bar.
      Specified by:
      getAntiRollBar in interface ConstVehicleConstraint
      Parameters:
      barIndex - the index of the bar to access (≥0)
      Returns:
      a new JVM object with the pre-existing native object assigned
    • getGravityOverride

      public Vec3 getGravityOverride()
      Copy the gravity override. The constraint is unaffected.
      Specified by:
      getGravityOverride in interface ConstVehicleConstraint
      Returns:
      a new vector
    • getLocalForward

      public Vec3 getLocalForward()
      Copy the local "forward" direction. The constraint is unaffected.
      Specified by:
      getLocalForward in interface ConstVehicleConstraint
      Returns:
      a new direction vector
    • getLocalUp

      public Vec3 getLocalUp()
      Copy the local "up" direction. The constraint is unaffected.
      Specified by:
      getLocalUp in interface ConstVehicleConstraint
      Returns:
      a new direction vector
    • getMaxPitchRollAngle

      public float getMaxPitchRollAngle()
      Return the vehicle's maximum pitch/roll angle. The constraint is unaffected.
      Specified by:
      getMaxPitchRollAngle in interface ConstVehicleConstraint
      Returns:
      the limit angle (in radians)
    • getNumStepsBetweenCollisionTestActive

      public int getNumStepsBetweenCollisionTestActive()
      Return the number of simulation steps between wheel-collision tests when the vehicle is active. The constraint is unaffected.
      Specified by:
      getNumStepsBetweenCollisionTestActive in interface ConstVehicleConstraint
      Returns:
      the number of steps
    • getNumStepsBetweenCollisionTestInactive

      public int getNumStepsBetweenCollisionTestInactive()
      Return the number of simulation steps between collision tests when the body is inactive. The constraint is unaffected.
      Specified by:
      getNumStepsBetweenCollisionTestInactive in interface ConstVehicleConstraint
      Returns:
      the number of steps
    • getWheelLocalBasis

      public void getWheelLocalBasis(Wheel wheel, Vec3 storeForward, Vec3 storeUp, Vec3 storeRight)
      Copy the basis vectors for the specified wheel.
      Specified by:
      getWheelLocalBasis in interface ConstVehicleConstraint
      Parameters:
      wheel - which wheel to query (not null)
      storeForward - storage for the forward vector (not null, modified)
      storeUp - storage for the up vector (not null, modified)
      storeRight - storage for the right vector (not null, modified)
    • getWheelWorldTransform

      public RMat44 getWheelWorldTransform(int wheelIndex, Vec3Arg right, Vec3Arg up)
      Copy the world transform of the specified wheel. The constraint is unaffected.
      Specified by:
      getWheelWorldTransform in interface ConstVehicleConstraint
      Parameters:
      wheelIndex - the index of the wheel to query (≥0)
      right - the wheel's axis of rotation (a unit vector in the wheel's model space)
      up - the "up" direction (a unit vector in the wheel's model space)
      Returns:
      a new coordinate transform matrix
    • getWorldUp

      public Vec3 getWorldUp()
      Copy the "up" direction based on gravity. The constraint is unaffected.
      Specified by:
      getWorldUp in interface ConstVehicleConstraint
      Returns:
      a new direction vector (in system coordinates)
    • isGravityOverridden

      public boolean isGravityOverridden()
      Test whether gravity is overridden. The constraint is unaffected.
      Specified by:
      isGravityOverridden in interface ConstVehicleConstraint
      Returns:
      true if overridden, otherwise false
    • toRef

      public VehicleConstraintRef toRef()
      Create a counted reference to the native VehicleConstraint.
      Specified by:
      toRef in interface RefTarget
      Overrides:
      toRef in class Constraint
      Returns:
      a new JVM object with a new native object assigned