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
,RefTarget
,AutoCloseable
,Comparable<JoltPhysicsObject>
A special
Constraint
used in vehicle simulation.-
Constructor Summary
ConstructorsConstructorDescriptionVehicleConstraint
(Body body, VehicleConstraintSettings settings) Instantiate a constraint for the specified body and settings. -
Method Summary
Modifier and TypeMethodDescriptionint
Count how many wheels the vehicle has.Access the controller for this constraint.Access the vehicle'sPhysicsStepListener
.Access the vehicle body.Access the underlying tester, if any.getWheel
(int wheelIndex) Access 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.void
overrideGravity
(Vec3Arg acceleration) Override the vehicle's gravity vector.void
Remove the gravity override, if any.void
setNumStepsBetweenCollisionTestActive
(int numSteps) Alter the number of simulation steps between wheel-collision tests when the vehicle is active.void
setNumStepsBetweenCollisionTestInactive
(int numSteps) Alter the number of simulation steps between wheel-collision tests when the vehicle is inactive.void
Replace 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, notifyShapeChanged, setConstraintPriority, setEmbedded, setEnabled, setNumPositionStepsOverride, setNumVelocityStepsOverride
Methods 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
-
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
-
countWheels
public int countWheels()Count how many wheels the vehicle has. The constraint is unaffected.- Returns:
- the count (≥0)
-
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:
- a new JVM object with the pre-existing native object assigned
-
getVehicleCollisionTester
Access the underlying tester, if any.- Returns:
- the pre-existing instance or
null
if none
-
getWheel
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
-
getWheelWorldTransform
Copy the world transform of the specified wheel. The constraint is unaffected.- 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.- Returns:
- a new direction vector (in system coordinates)
-
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. -
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, alias created)
-
toRef
Create a counted reference to the nativeVehicleConstraint
.- Specified by:
toRef
in interfaceRefTarget
- Overrides:
toRef
in classConstraint
- Returns:
- a new JVM object with a new native object assigned
-