java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.NonCopyable
com.github.stephengold.joltjni.CharacterBase
com.github.stephengold.joltjni.Character
- All Implemented Interfaces:
ConstCharacter
,ConstCharacterBase
,ConstJoltPhysicsObject
,RefTarget
,AutoCloseable
,Comparable<JoltPhysicsObject>
A character implemented using a kinematic rigid body.
-
Constructor Summary
ConstructorsConstructorDescriptionCharacter
(ConstCharacterSettings settings, RVec3Arg location, QuatArg orientation, long userData, PhysicsSystem system) Instantiate a character with the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Wake up the character using the locking body interface.void
activate
(boolean lockBodies) Wake up the character.void
addImpulse
(Vec3Arg impulse) Apply an impulse to the character's center of mass, using the locking body interface.void
addImpulse
(Vec3Arg impulse, boolean lockBodies) Apply an impulse to the character's center of mass.void
addLinearVelocity
(Vec3Arg deltaV) Add to the character's linear velocity, using the locking body interface.void
addLinearVelocity
(Vec3Arg deltaV, boolean lockBodies) Add to the character's linear velocity.void
Add the character to itsPhysicsSystem
and activate it, using the locking body interface.void
addToPhysicsSystem
(EActivation activation) Add the character to itsPhysicsSystem
using the locking body interface.void
addToPhysicsSystem
(EActivation activation, boolean lockBodies) Add the character to itsPhysicsSystem
.int
Return the ID of the body associated with the character.Copy the location of the rigid body's center of mass using the locking body interface.getCenterOfMassPosition
(boolean lockBodies) Copy the location of the rigid body's center of mass.int
getLayer()
Return the character's object layer, using the locking body interface.int
getLayer
(boolean lockBodies) Return the character's object layer.Copy the linear velocity of the character using the locking body interface.getLinearVelocity
(boolean lockBodies) Copy the linear velocity of the character.Copy the location of the character using the locking body interface.getPosition
(boolean lockBodies) Copy the location of the character.void
getPositionAndRotation
(RVec3 storeLocation, Quat storeOrientation) Copy the position of the associated body using the locking body interface.void
getPositionAndRotation
(RVec3 storeLocation, Quat storeOrientation, boolean lockBodies) Copy the position of the associated body.Copy the orientation of the character using the locking body interface.getRotation
(boolean lockBodies) Copy the orientation of the character.Return a TransformedShape that represents the volume occupied by the character, using the locking body interface.getTransformedShape
(boolean lockBodies) Return a TransformedShape that represents the volume occupied by the character.Calculate the character's local-to-system coordinate transform using the locking body interface.getWorldTransform
(boolean lockBodies) Calculate the character's local-to-system coordinate transform.void
postSimulation
(float maxSeparation) Needs to be invoked after every physics update.void
postSimulation
(float maxSeparation, boolean lockBodies) Needs to be invoked after every physics update.void
Remove the character from itsPhysicsSystem
using the locking body interface.void
removeFromPhysicsSystem
(boolean lockBodies) Remove the character from itsPhysicsSystem
.void
setLayer
(int layer) Alter the character's object layer, using the locking body interface.void
setLayer
(int layer, boolean lockBodies) Alter the character's object layer.void
setLinearAndAngularVelocity
(Vec3Arg linearVelocity, Vec3Arg omega) Alter the character's motion using the locking body interface.void
setLinearAndAngularVelocity
(Vec3Arg linearVelocity, Vec3Arg omega, boolean lockBodies) Alter the character's motion.void
setLinearVelocity
(Vec3Arg velocity) Alter the character's linear velocity using the locking body interface.void
setLinearVelocity
(Vec3Arg velocity, boolean lockBodies) Alter the character's linear velocity.void
setPosition
(RVec3Arg location) Relocate and activate the character using the locking body interface.void
setPosition
(RVec3Arg location, EActivation activation) Relocate the character, optionally activating it, using the locking body interface.void
setPosition
(RVec3Arg location, EActivation activation, boolean lockBodies) Relocate the character, optionally activating it.void
setPositionAndRotation
(RVec3Arg location, QuatArg orientation) Reposition and activate the character using the locking body interface.void
setPositionAndRotation
(RVec3Arg location, QuatArg orientation, EActivation activation) Reposition the character, optionally activating it.void
setPositionAndRotation
(RVec3Arg location, QuatArg orientation, EActivation activation, boolean lockBodies) Reposition the character, optionally activating it.void
setRotation
(QuatArg orientation) Re-orient and activate the character using the locking body interface.void
setRotation
(QuatArg orientation, EActivation activation) Re-orient the character, optionally activating it.void
setRotation
(QuatArg orientation, EActivation activation, boolean lockBodies) Re-orient the character, optionally activating it.boolean
setShape
(ConstShape shape, float maxPenetrationDepth) Attempt to replace the character's shape using the locking body interface.boolean
setShape
(ConstShape shape, float maxPenetrationDepth, boolean lockBodies) Attempt to replace the character's shape.toRef()
Create a counted reference to the nativeCharacter
.toRefC()
Create a counted reference to the nativeCharacter
.Methods inherited from class com.github.stephengold.joltjni.CharacterBase
getCosMaxSlopeAngle, getGroundBodyId, getGroundMaterial, getGroundNormal, getGroundPosition, getGroundState, getGroundSubShapeId, getGroundUserData, getGroundVelocity, getRefCount, getShape, getUp, isSlopeTooSteep, isSupported, restoreState, saveState, setEmbedded, setMaxSlopeAngle, setUp
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.ConstCharacterBase
getCosMaxSlopeAngle, getGroundBodyId, getGroundMaterial, getGroundNormal, getGroundPosition, getGroundState, getGroundSubShapeId, getGroundUserData, getGroundVelocity, getShape, getUp, isSlopeTooSteep, isSupported, saveState
Methods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa
-
Constructor Details
-
Character
public Character(ConstCharacterSettings settings, RVec3Arg location, QuatArg orientation, long userData, PhysicsSystem system) Instantiate a character with the specified properties.- Parameters:
settings
- the settings to use (not null, unaffected)location
- the desired initial location (in system coordinates, not null, unaffected)orientation
- the desired initial orientation (in system coordinates, not null, unaffected)userData
- the desired user-data valuesystem
- where to add the body (not null)
-
-
Method Details
-
activate
public void activate()Wake up the character using the locking body interface. -
activate
public void activate(boolean lockBodies) Wake up the character.- Parameters:
lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
addImpulse
Apply an impulse to the character's center of mass, using the locking body interface.- Parameters:
impulse
- the impulse vector (kilogram.meters per second in system coordinates, not null, unaffected)
-
addImpulse
Apply an impulse to the character's center of mass.- Parameters:
impulse
- the impulse vector (kilogram.meters per second in system coordinates, not null, unaffected)lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
addLinearVelocity
Add to the character's linear velocity, using the locking body interface.- Parameters:
deltaV
- the change in velocity (meters per second in system coordinates, not null, unaffected)
-
addLinearVelocity
Add to the character's linear velocity.- Parameters:
deltaV
- the change in velocity (meters per second in system coordinates, not null, unaffected)lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
addToPhysicsSystem
public void addToPhysicsSystem()Add the character to itsPhysicsSystem
and activate it, using the locking body interface. -
addToPhysicsSystem
Add the character to itsPhysicsSystem
using the locking body interface.- Parameters:
activation
- whether to activate the character (not null, default=Activate)
-
addToPhysicsSystem
Add the character to itsPhysicsSystem
.- Parameters:
activation
- whether to activate the character (not null, default=Activate)lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
postSimulation
public void postSimulation(float maxSeparation) Needs to be invoked after every physics update.- Parameters:
maxSeparation
- the max distance between the floor and the character for standing (in meters)
-
postSimulation
public void postSimulation(float maxSeparation, boolean lockBodies) Needs to be invoked after every physics update.- Parameters:
maxSeparation
- the max distance between the floor and the character for standing (in meters)lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
removeFromPhysicsSystem
public void removeFromPhysicsSystem()Remove the character from itsPhysicsSystem
using the locking body interface. -
removeFromPhysicsSystem
public void removeFromPhysicsSystem(boolean lockBodies) Remove the character from itsPhysicsSystem
.- Parameters:
lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
setLayer
public void setLayer(int layer) Alter the character's object layer, using the locking body interface.- Parameters:
layer
- the index of the desired layer (default=0)
-
setLayer
public void setLayer(int layer, boolean lockBodies) Alter the character's object layer.- Parameters:
layer
- the index of the desired layer (default=0)lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
setLinearAndAngularVelocity
Alter the character's motion using the locking body interface.- Parameters:
linearVelocity
- the desired linear velocity (meters per second in system coordinates, not null, unaffected)omega
- the desired angular velocity (radians per second in system coordinates, not null, unaffected)
-
setLinearAndAngularVelocity
Alter the character's motion.- Parameters:
linearVelocity
- the desired linear velocity (meters per second in system coordinates, not null, unaffected)omega
- the desired angular velocity (radians per second in system coordinates, not null, unaffected)lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
setLinearVelocity
Alter the character's linear velocity using the locking body interface.- Parameters:
velocity
- the desired velocity (meters per second in system coordinates, not null, unaffected)
-
setLinearVelocity
Alter the character's linear velocity.- Parameters:
velocity
- the desired velocity (meters per second in system coordinates, not null, unaffected)lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
setPosition
Relocate and activate the character using the locking body interface.- Parameters:
location
- the desired location (in system coordinates, not null, unaffected)
-
setPosition
Relocate the character, optionally activating it, using the locking body interface.- Parameters:
location
- the desired location (in system coordinates, not null, unaffected)activation
- whether to activate the character (not null, default=Activate)
-
setPosition
Relocate the character, optionally activating it.- Parameters:
location
- the desired location (in system coordinates, not null, unaffected)activation
- whether to activate the character (not null, default=Activate)lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
setPositionAndRotation
Reposition and activate the character using the locking body interface.- Parameters:
location
- the desired location (in system coordinates, not null, unaffected)orientation
- the desired orientation (in system coordinates, not null, unaffected)
-
setPositionAndRotation
Reposition the character, optionally activating it.- Parameters:
location
- the desired location (in system coordinates, not null, unaffected)orientation
- the desired orientation (in system coordinates, not null, unaffected)activation
- whether to activate the character (not null, default=Activate)
-
setPositionAndRotation
public void setPositionAndRotation(RVec3Arg location, QuatArg orientation, EActivation activation, boolean lockBodies) Reposition the character, optionally activating it.- Parameters:
location
- the desired location (in system coordinates, not null, unaffected)orientation
- the desired orientation (in system coordinates, not null, unaffected)activation
- whether to activate the character (not null, default=Activate)lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
setRotation
Re-orient and activate the character using the locking body interface.- Parameters:
orientation
- the desired orientation (in system coordinates, not null, unaffected)
-
setRotation
Re-orient the character, optionally activating it.- Parameters:
orientation
- the desired orientation (in system coordinates, not null, unaffected)activation
- whether to activate the character (not null, default=Activate)
-
setRotation
Re-orient the character, optionally activating it.- Parameters:
orientation
- the desired orientation (in system coordinates, not null, unaffected)activation
- whether to activate the character (not null, default=Activate)lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
setShape
Attempt to replace the character's shape using the locking body interface.- Parameters:
shape
- the desired shape (not null, unaffected)maxPenetrationDepth
- the maximum penetration to allow, or MAX_VALUE to skip the penetration check- Returns:
true
if the replacement succeeded, otherwisefalse
-
setShape
Attempt to replace the character's shape.- Parameters:
shape
- the desired shape (not null, unaffected)maxPenetrationDepth
- the maximum penetration to allow, or MAX_VALUE to skip the penetration checklockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)- Returns:
true
if the replacement succeeded, otherwisefalse
-
toRef
Create a counted reference to the nativeCharacter
. -
getBodyId
public int getBodyId()Return the ID of the body associated with the character. The character is unaffected. (native method: GetBodyID)- Specified by:
getBodyId
in interfaceConstCharacter
- Returns:
- the
BodyID
value
-
getCenterOfMassPosition
Copy the location of the rigid body's center of mass using the locking body interface. The character is unaffected.- Specified by:
getCenterOfMassPosition
in interfaceConstCharacter
- Returns:
- a new location vector (in system coordinates)
-
getCenterOfMassPosition
Copy the location of the rigid body's center of mass. The character is unaffected.- Specified by:
getCenterOfMassPosition
in interfaceConstCharacter
- Parameters:
lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)- Returns:
- a new location vector (in system coordinates)
-
getLayer
public int getLayer()Return the character's object layer, using the locking body interface. The character is unaffected.- Specified by:
getLayer
in interfaceConstCharacter
- Returns:
- a layer index (≥0)
-
getLayer
public int getLayer(boolean lockBodies) Return the character's object layer. The character is unaffected.- Specified by:
getLayer
in interfaceConstCharacter
- Parameters:
lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)- Returns:
- a layer index (≥0)
-
getLinearVelocity
Copy the linear velocity of the character using the locking body interface. The character is unaffected.- Specified by:
getLinearVelocity
in interfaceConstCharacter
- Returns:
- a new velocity vector (meters per second in system coordinates)
-
getLinearVelocity
Copy the linear velocity of the character. The character is unaffected.- Specified by:
getLinearVelocity
in interfaceConstCharacter
- Parameters:
lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)- Returns:
- a new velocity vector (meters per second in system coordinates)
-
getPosition
Copy the location of the character using the locking body interface. The character is unaffected.- Specified by:
getPosition
in interfaceConstCharacter
- Returns:
- a new location vector (in system coordinates)
-
getPosition
Copy the location of the character. The character is unaffected.- Specified by:
getPosition
in interfaceConstCharacter
- Parameters:
lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)- Returns:
- a new location vector (in system coordinates)
-
getPositionAndRotation
Copy the position of the associated body using the locking body interface. The character is unaffected.- Specified by:
getPositionAndRotation
in interfaceConstCharacter
- Parameters:
storeLocation
- the desired location (in system coordinates, not null, unaffected)storeOrientation
- the desired orientation (in system coordinates, not null, unaffected)
-
getPositionAndRotation
Copy the position of the associated body. The character is unaffected.- Specified by:
getPositionAndRotation
in interfaceConstCharacter
- Parameters:
storeLocation
- the desired location (in system coordinates, not null, unaffected)storeOrientation
- the desired orientation (in system coordinates, not null, unaffected)lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)
-
getRotation
Copy the orientation of the character using the locking body interface. The character is unaffected.- Specified by:
getRotation
in interfaceConstCharacter
- Returns:
- a new rotation quaternion (in system coordinates)
-
getRotation
Copy the orientation of the character. The character is unaffected.- Specified by:
getRotation
in interfaceConstCharacter
- Parameters:
lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)- Returns:
- a new rotation quaternion (in system coordinates)
-
getTransformedShape
Return a TransformedShape that represents the volume occupied by the character, using the locking body interface. The character is unaffected.- Specified by:
getTransformedShape
in interfaceConstCharacter
- Returns:
- a new object
-
getTransformedShape
Return a TransformedShape that represents the volume occupied by the character. The character is unaffected.- Specified by:
getTransformedShape
in interfaceConstCharacter
- Parameters:
lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)- Returns:
- a new object
-
getWorldTransform
Calculate the character's local-to-system coordinate transform using the locking body interface. The character is unaffected.- Specified by:
getWorldTransform
in interfaceConstCharacter
- Returns:
- a new coordinate transform matrix
-
getWorldTransform
Calculate the character's local-to-system coordinate transform. The character is unaffected.- Specified by:
getWorldTransform
in interfaceConstCharacter
- Parameters:
lockBodies
-true
→ use the locking body interface,false
→ use the non-locking body interface (default=true)- Returns:
- a new transform matrix
-
toRefC
Create a counted reference to the nativeCharacter
.- Specified by:
toRefC
in interfaceConstCharacter
- Returns:
- a new JVM object with a new native object assigned
-