Package com.github.stephengold.joltjni
Class VehicleConstraint
java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.NonCopyable
com.github.stephengold.joltjni.Constraint
com.github.stephengold.joltjni.VehicleConstraint
- All Implemented Interfaces:
ConstConstraint,ConstJoltPhysicsObject,ConstVehicleConstraint,RefTarget,AutoCloseable,Comparable<JoltPhysicsObject>
A special single-body
Constraint used in vehicle simulation.-
Constructor Summary
ConstructorsConstructorDescriptionVehicleConstraint(Body body, ConstVehicleConstraintSettings settings) Instantiate a constraint for the specified body and settings. -
Method Summary
Modifier and TypeMethodDescriptionintCount how many anti-roll bars the vehicle has.intCount how many wheels the vehicle has.getAntiRollBar(int barIndex) Access the specified anti-roll bar.Access the controller for this constraint.Copy the gravity override.Copy the local "forward" direction.Copy the local "up" direction.floatReturn the vehicle's maximum pitch/roll angle.intReturn the number of simulation steps between wheel-collision tests when the vehicle is active.intReturn the number of simulation steps between collision tests when the body is inactive.Access the vehicle'sPhysicsStepListener.Access the vehicle body.Access the underlying tester, if any.getWheel(int wheelIndex) Access the specified wheel.voidgetWheelLocalBasis(Wheel wheel, Vec3 storeForward, Vec3 storeUp, Vec3 storeRight) Copy the basis vectors for the specified wheel.voidgetWheelPositionAndRotation(int wheelIndex, Vec3Arg right, Vec3Arg up, RVec3 storePosition, Quat storeRotation) Copy the world transform of the specified wheel.getWheelWorldTransform(int wheelIndex, Vec3Arg right, Vec3Arg up) Copy the world transform of the specified wheel.Copy the "up" direction based on gravity.booleanTest whether gravity is overridden.voidoverrideGravity(float ax, float ay, float az) Override the vehicle's gravity vector.voidoverrideGravity(Vec3Arg acceleration) Override the vehicle's gravity vector.voidRemove the gravity override, if any.voidsetMaxPitchRollAngle(float angle) Alter the vehicle's maximum pitch/roll angle.voidsetNumStepsBetweenCollisionTestActive(int numSteps) Alter the number of simulation steps between wheel-collision tests when the vehicle is active.voidsetNumStepsBetweenCollisionTestInactive(int numSteps) Alter the number of simulation steps between wheel-collision tests when the vehicle is inactive.voidReplace the collision tester.toRef()Create a counted reference to the nativeVehicleConstraint.Methods inherited from class com.github.stephengold.joltjni.Constraint
getConstraintPriority, getConstraintSettings, getEnabled, getNumPositionStepsOverride, getNumVelocityStepsOverride, getRefCount, getSubType, getType, isActive, notifyShapeChanged, restoreState, saveState, setConstraintPriority, setEmbedded, setEnabled, setNumPositionStepsOverride, setNumVelocityStepsOverride, setVirtualAddressAsCoOwnerMethods 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.ConstConstraint
getConstraintPriority, getConstraintSettings, getEnabled, getNumPositionStepsOverride, getNumVelocityStepsOverride, getSubType, getType, isActive, saveStateMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa
-
Constructor Details
-
VehicleConstraint
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
Access the controller for this constraint.- Returns:
- a new JVM object with the pre-existing native object assigned
-
getStepListener
Access the vehicle'sPhysicsStepListener. 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
Access the vehicle body.- Returns:
- the pre-existing instance
-
getVehicleCollisionTester
Access the underlying tester, if any.- Returns:
- the pre-existing instance or
nullif none
-
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 vectoray- the Y component of the desired acceleration vectoraz- the Z component of the desired acceleration vector
-
overrideGravity
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
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:
countAntiRollBarsin interfaceConstVehicleConstraint- Returns:
- the count (≥0)
-
countWheels
public int countWheels()Count how many wheels the vehicle has. The constraint is unaffected.- Specified by:
countWheelsin interfaceConstVehicleConstraint- Returns:
- the count (≥0)
-
getAntiRollBar
Access the specified anti-roll bar.- Specified by:
getAntiRollBarin interfaceConstVehicleConstraint- Parameters:
barIndex- the index of the bar to access (≥0)- Returns:
- a new JVM object with the pre-existing native object assigned
-
getGravityOverride
Copy the gravity override. The constraint is unaffected.- Specified by:
getGravityOverridein interfaceConstVehicleConstraint- Returns:
- a new vector
-
getLocalForward
Copy the local "forward" direction. The constraint is unaffected.- Specified by:
getLocalForwardin interfaceConstVehicleConstraint- Returns:
- a new direction vector
-
getLocalUp
Copy the local "up" direction. The constraint is unaffected.- Specified by:
getLocalUpin interfaceConstVehicleConstraint- Returns:
- a new direction vector
-
getMaxPitchRollAngle
public float getMaxPitchRollAngle()Return the vehicle's maximum pitch/roll angle. The constraint is unaffected.- Specified by:
getMaxPitchRollAnglein interfaceConstVehicleConstraint- 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:
getNumStepsBetweenCollisionTestActivein interfaceConstVehicleConstraint- 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:
getNumStepsBetweenCollisionTestInactivein interfaceConstVehicleConstraint- Returns:
- the number of steps
-
getWheel
Access the specified wheel.- Specified by:
getWheelin interfaceConstVehicleConstraint- Parameters:
wheelIndex- the index of the wheel to access (≥0)- Returns:
- a new JVM object with the pre-existing native object assigned
-
getWheelLocalBasis
Copy the basis vectors for the specified wheel.- Specified by:
getWheelLocalBasisin interfaceConstVehicleConstraint- 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)
-
getWheelPositionAndRotation
public void getWheelPositionAndRotation(int wheelIndex, Vec3Arg right, Vec3Arg up, RVec3 storePosition, Quat storeRotation) Copy the world transform of the specified wheel. The constraint is unaffected.- Specified by:
getWheelPositionAndRotationin interfaceConstVehicleConstraint- 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)storePosition- storage for the translation component (not null, modified)storeRotation- storage for the rotation component (not null, modified)
-
getWheelWorldTransform
Copy the world transform of the specified wheel. The constraint is unaffected.- Specified by:
getWheelWorldTransformin interfaceConstVehicleConstraint- 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
Copy the "up" direction based on gravity. The constraint is unaffected.- Specified by:
getWorldUpin interfaceConstVehicleConstraint- Returns:
- a new direction vector (in system coordinates)
-
isGravityOverridden
public boolean isGravityOverridden()Test whether gravity is overridden. The constraint is unaffected.- Specified by:
isGravityOverriddenin interfaceConstVehicleConstraint- Returns:
trueif overridden, otherwisefalse
-
toRef
Create a counted reference to the nativeVehicleConstraint.- Specified by:
toRefin interfaceRefTarget- Overrides:
toRefin classConstraint- Returns:
- a new JVM object with a new native object assigned
-