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 SummaryConstructorsConstructorDescriptionCharacter(ConstCharacterSettings settings, RVec3Arg location, QuatArg orientation, long userData, PhysicsSystem system) Instantiate a character with the specified properties.
- 
Method SummaryModifier and TypeMethodDescriptionvoidactivate()Wake up the character using the locking body interface.voidactivate(boolean lockBodies) Wake up the character.voidaddImpulse(Vec3Arg impulse) Apply an impulse to the character's center of mass, using the locking body interface.voidaddImpulse(Vec3Arg impulse, boolean lockBodies) Apply an impulse to the character's center of mass.voidaddLinearVelocity(Vec3Arg deltaV) Add to the character's linear velocity, using the locking body interface.voidaddLinearVelocity(Vec3Arg deltaV, boolean lockBodies) Add to the character's linear velocity.voidAdd the character to itsPhysicsSystemand activate it, using the locking body interface.voidaddToPhysicsSystem(EActivation activation) Add the character to itsPhysicsSystemusing the locking body interface.voidaddToPhysicsSystem(EActivation activation, boolean lockBodies) Add the character to itsPhysicsSystem.intReturn 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.Generate settings to reconstruct the character, using the locking body interface.getCharacterSettings(boolean lockBodies) Generate settings to reconstruct the character.intgetLayer()Return the character's object layer, using the locking body interface.intgetLayer(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.voidgetPositionAndRotation(RVec3 storeLocation, Quat storeOrientation) Copy the position of the associated body using the locking body interface.voidgetPositionAndRotation(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.Generate a TransformedShape that represents the volume occupied by the character, using the locking body interface.getTransformedShape(boolean lockBodies) Generate 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.voidpostSimulation(float maxSeparation) Needs to be invoked after every physics update.voidpostSimulation(float maxSeparation, boolean lockBodies) Needs to be invoked after every physics update.voidRemove the character from itsPhysicsSystemusing the locking body interface.voidremoveFromPhysicsSystem(boolean lockBodies) Remove the character from itsPhysicsSystem.voidsetLayer(int layer) Alter the character's object layer, using the locking body interface.voidsetLayer(int layer, boolean lockBodies) Alter the character's object layer.voidsetLinearAndAngularVelocity(Vec3Arg linearVelocity, Vec3Arg omega) Alter the character's motion using the locking body interface.voidsetLinearAndAngularVelocity(Vec3Arg linearVelocity, Vec3Arg omega, boolean lockBodies) Alter the character's motion.voidsetLinearVelocity(float vx, float vy, float vz) Alter the character's linear velocity using the locking body interface.voidsetLinearVelocity(float vx, float vy, float vz, boolean lockBodies) Alter the character's linear velocity.voidsetLinearVelocity(Vec3Arg velocity) Alter the character's linear velocity using the locking body interface.voidsetLinearVelocity(Vec3Arg velocity, boolean lockBodies) Alter the character's linear velocity.voidsetPosition(RVec3Arg location) Relocate and activate the character using the locking body interface.voidsetPosition(RVec3Arg location, EActivation activation) Relocate the character, optionally activating it, using the locking body interface.voidsetPosition(RVec3Arg location, EActivation activation, boolean lockBodies) Relocate the character, optionally activating it.voidsetPositionAndRotation(RVec3Arg location, QuatArg orientation) Reposition and activate the character using the locking body interface.voidsetPositionAndRotation(RVec3Arg location, QuatArg orientation, EActivation activation) Reposition the character, optionally activating it.voidsetPositionAndRotation(RVec3Arg location, QuatArg orientation, EActivation activation, boolean lockBodies) Reposition the character, optionally activating it.voidsetRotation(QuatArg orientation) Re-orient and activate the character using the locking body interface.voidsetRotation(QuatArg orientation, EActivation activation) Re-orient the character, optionally activating it.voidsetRotation(QuatArg orientation, EActivation activation, boolean lockBodies) Re-orient the character, optionally activating it.booleansetShape(ConstShape shape, float maxPenetrationDepth) Attempt to replace the character's shape using the locking body interface.booleansetShape(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.CharacterBasegetCosMaxSlopeAngle, getGroundBodyId, getGroundMaterial, getGroundNormal, getGroundPosition, getGroundState, getGroundSubShapeId, getGroundUserData, getGroundVelocity, getRefCount, getShape, getUp, isSlopeTooSteep, isSupported, restoreState, saveState, setEmbedded, setMaxSlopeAngle, setUpMethods inherited from class com.github.stephengold.joltjni.JoltPhysicsObjectclose, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, vaMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.ComparablecompareToMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstCharacterBasegetCosMaxSlopeAngle, getGroundBodyId, getGroundMaterial, getGroundNormal, getGroundPosition, getGroundState, getGroundSubShapeId, getGroundUserData, getGroundVelocity, getRefCount, getShape, getUp, isSlopeTooSteep, isSupported, saveStateMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObjectclose, hasAssignedNativeObject, ownsNativeObject, targetVa
- 
Constructor Details- 
Characterpublic 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 value
- system- where to add the body (not null)
 
 
- 
- 
Method Details- 
activatepublic void activate()Wake up the character using the locking body interface.
- 
activatepublic 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)
 
- 
addImpulseApply 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)
 
- 
addImpulseApply 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)
 
- 
addLinearVelocityAdd 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)
 
- 
addLinearVelocityAdd 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)
 
- 
addToPhysicsSystempublic void addToPhysicsSystem()Add the character to itsPhysicsSystemand activate it, using the locking body interface.
- 
addToPhysicsSystemAdd the character to itsPhysicsSystemusing the locking body interface.- Parameters:
- activation- whether to activate the character (not null, default=Activate)
 
- 
addToPhysicsSystemAdd 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)
 
- 
postSimulationpublic 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)
 
- 
postSimulationpublic 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)
 
- 
removeFromPhysicsSystempublic void removeFromPhysicsSystem()Remove the character from itsPhysicsSystemusing the locking body interface.
- 
removeFromPhysicsSystempublic 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)
 
- 
setLayerpublic 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)
 
- 
setLayerpublic 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)
 
- 
setLinearAndAngularVelocityAlter 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)
 
- 
setLinearAndAngularVelocityAlter 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)
 
- 
setLinearVelocitypublic void setLinearVelocity(float vx, float vy, float vz) Alter the character's linear velocity using the locking body interface.- Parameters:
- vx- the X component of the desired velocity (in meters per second, default=0)
- vy- the Y component of the desired velocity (in meters per second, default=0)
- vz- the Z component of the desired velocity (in meters per second, default=0)
 
- 
setLinearVelocitypublic void setLinearVelocity(float vx, float vy, float vz, boolean lockBodies) Alter the character's linear velocity.- Parameters:
- vx- the X component of the desired velocity (in meters per second, default=0)
- vy- the Y component of the desired velocity (in meters per second, default=0)
- vz- the Z component of the desired velocity (in meters per second, default=0)
- lockBodies-- true→ use the locking body interface,- false→ use the non-locking body interface (default=true)
 
- 
setLinearVelocityAlter the character's linear velocity using the locking body interface.- Parameters:
- velocity- the desired velocity (meters per second in system coordinates, not null, unaffected)
 
- 
setLinearVelocityAlter 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)
 
- 
setPositionRelocate and activate the character using the locking body interface.- Parameters:
- location- the desired location (in system coordinates, not null, unaffected)
 
- 
setPositionRelocate 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)
 
- 
setPositionRelocate 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)
 
- 
setPositionAndRotationReposition 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)
 
- 
setPositionAndRotationReposition 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)
 
- 
setPositionAndRotationpublic 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)
 
- 
setRotationRe-orient and activate the character using the locking body interface.- Parameters:
- orientation- the desired orientation (in system coordinates, not null, unaffected)
 
- 
setRotationRe-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)
 
- 
setRotationRe-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)
 
- 
setShapeAttempt 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:
- trueif the replacement succeeded, otherwise- false
 
- 
setShapeAttempt 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 check
- lockBodies-- true→ use the locking body interface,- false→ use the non-locking body interface (default=true)
- Returns:
- trueif the replacement succeeded, otherwise- false
 
- 
toRefCreate a counted reference to the nativeCharacter.
- 
getBodyIdpublic int getBodyId()Return the ID of the body associated with the character. The character is unaffected. (native method: GetBodyID)- Specified by:
- getBodyIdin interface- ConstCharacter
- Returns:
- the BodyIDvalue
 
- 
getCenterOfMassPositionCopy the location of the rigid body's center of mass using the locking body interface. The character is unaffected.- Specified by:
- getCenterOfMassPositionin interface- ConstCharacter
- Returns:
- a new location vector (in system coordinates)
 
- 
getCenterOfMassPositionCopy the location of the rigid body's center of mass. The character is unaffected.- Specified by:
- getCenterOfMassPositionin interface- ConstCharacter
- 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)
 
- 
getCharacterSettingsGenerate settings to reconstruct the character, using the locking body interface. The character is unaffected.- Specified by:
- getCharacterSettingsin interface- ConstCharacter
- Returns:
- a new object
 
- 
getCharacterSettingsGenerate settings to reconstruct the character. The character is unaffected.- Specified by:
- getCharacterSettingsin interface- ConstCharacter
- Parameters:
- lockBodies-- true→ use the locking body interface,
- Returns:
- a new object
 
- 
getLayerpublic int getLayer()Return the character's object layer, using the locking body interface. The character is unaffected.- Specified by:
- getLayerin interface- ConstCharacter
- Returns:
- a layer index (≥0)
 
- 
getLayerpublic int getLayer(boolean lockBodies) Return the character's object layer. The character is unaffected.- Specified by:
- getLayerin interface- ConstCharacter
- Parameters:
- lockBodies-- true→ use the locking body interface,- false→ use the non-locking body interface (default=true)
- Returns:
- a layer index (≥0)
 
- 
getLinearVelocityCopy the linear velocity of the character using the locking body interface. The character is unaffected.- Specified by:
- getLinearVelocityin interface- ConstCharacter
- Returns:
- a new velocity vector (meters per second in system coordinates)
 
- 
getLinearVelocityCopy the linear velocity of the character. The character is unaffected.- Specified by:
- getLinearVelocityin interface- ConstCharacter
- 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)
 
- 
getPositionCopy the location of the character using the locking body interface. The character is unaffected.- Specified by:
- getPositionin interface- ConstCharacter
- Returns:
- a new location vector (in system coordinates)
 
- 
getPositionCopy the location of the character. The character is unaffected.- Specified by:
- getPositionin interface- ConstCharacter
- 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)
 
- 
getPositionAndRotationCopy the position of the associated body using the locking body interface. The character is unaffected.- Specified by:
- getPositionAndRotationin interface- ConstCharacter
- Parameters:
- storeLocation- storage for the location (in system coordinates, not null, modified)
- storeOrientation- storage for the orientation (in system coordinates, not null, modified)
 
- 
getPositionAndRotationCopy the position of the associated body. The character is unaffected.- Specified by:
- getPositionAndRotationin interface- ConstCharacter
- Parameters:
- storeLocation- storage for the location (in system coordinates, not null, modified)
- storeOrientation- storage for the orientation (in system coordinates, not null, modified)
- lockBodies-- true→ use the locking body interface,- false→ use the non-locking body interface (default=true)
 
- 
getRotationCopy the orientation of the character using the locking body interface. The character is unaffected.- Specified by:
- getRotationin interface- ConstCharacter
- Returns:
- a new rotation quaternion (in system coordinates)
 
- 
getRotationCopy the orientation of the character. The character is unaffected.- Specified by:
- getRotationin interface- ConstCharacter
- 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)
 
- 
getTransformedShapeGenerate a TransformedShape that represents the volume occupied by the character, using the locking body interface. The character is unaffected.- Specified by:
- getTransformedShapein interface- ConstCharacter
- Returns:
- a new object
 
- 
getTransformedShapeGenerate a TransformedShape that represents the volume occupied by the character. The character is unaffected.- Specified by:
- getTransformedShapein interface- ConstCharacter
- Parameters:
- lockBodies-- true→ use the locking body interface,- false→ use the non-locking body interface (default=true)
- Returns:
- a new object
 
- 
getWorldTransformCalculate the character's local-to-system coordinate transform using the locking body interface. The character is unaffected.- Specified by:
- getWorldTransformin interface- ConstCharacter
- Returns:
- a new coordinate transform matrix
 
- 
getWorldTransformCalculate the character's local-to-system coordinate transform. The character is unaffected.- Specified by:
- getWorldTransformin interface- ConstCharacter
- Parameters:
- lockBodies-- true→ use the locking body interface,- false→ use the non-locking body interface (default=true)
- Returns:
- a new transform matrix
 
- 
toRefCCreate a counted reference to the nativeCharacter.- Specified by:
- toRefCin interface- ConstCharacter
- Returns:
- a new JVM object with a new native object assigned
 
 
-