java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.template.Ref
com.github.stephengold.joltjni.CharacterRef
- All Implemented Interfaces:
ConstCharacter
,ConstCharacterBase
,ConstJoltPhysicsObject
,AutoCloseable
,Comparable<JoltPhysicsObject>
A counted reference to a
Character
. (native type:
Ref<Character>
)-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.float
Return the maximum slope the character can walk on.int
Return the body ID of the supporting surface.Access the material of the supporting surface.Copy the normal direction at the point of contact with the supporting surface.Copy the location of the point of contact with the supporting surface.Return the relationship between the character and its supporting surface.int
Identify the face on the supporting surface where contact is occurring.long
Return the user data of the supporting surface.Copy the world-space velocity of the supporting surface.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.getPtr()
Temporarily access the referencedCharacter
.Copy the orientation of the character using the locking body interface.getRotation
(boolean lockBodies) Copy the orientation of the character.getShape()
Access the character's shape.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.getUp()
Copy the character's "up" direction.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.boolean
isSlopeTooSteep
(Vec3Arg normal) Test whether the specified normal direction is too steep.boolean
Test whether the character is supported.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
restoreState
(StateRecorder recorder) Restore the character's state from the specified recorder.void
saveState
(StateRecorder recorder) Save the character's state to the specified recorder.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.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.long
targetVa()
Return the address of the nativeCharacter
.toRef()
Create another counted reference to the nativeCharacter
.toRefC()
Create a counted reference to the nativeCharacter
.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, 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
-
Constructor Details
-
CharacterRef
public CharacterRef()Instantiate an empty reference.
-
-
Method Details
-
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
-
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 standinglockBodies
-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)
-
restoreState
Restore the character's state from the specified recorder.- Parameters:
recorder
- the recorder to restore from (not null)
-
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)
-
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
-
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)
-
getCosMaxSlopeAngle
public float getCosMaxSlopeAngle()Return the maximum slope the character can walk on. The character is unaffected.- Specified by:
getCosMaxSlopeAngle
in interfaceConstCharacterBase
- Returns:
- the cosine of the slope angle
-
getGroundBodyId
public int getGroundBodyId()Return the body ID of the supporting surface. The character is unaffected.- Specified by:
getGroundBodyId
in interfaceConstCharacterBase
- Returns:
- the
BodyID
value
-
getGroundMaterial
Access the material of the supporting surface. The character is unaffected.- Specified by:
getGroundMaterial
in interfaceConstCharacterBase
- Returns:
- a new JVM object with the pre-existing native object assigned, or
else
null
-
getGroundNormal
Copy the normal direction at the point of contact with the supporting surface. The character is unaffected.- Specified by:
getGroundNormal
in interfaceConstCharacterBase
- Returns:
- a new direction vector (in system coordinates)
-
getGroundPosition
Copy the location of the point of contact with the supporting surface. The character is unaffected.- Specified by:
getGroundPosition
in interfaceConstCharacterBase
- Returns:
- a new location vector (in system coordinates)
-
getGroundState
Return the relationship between the character and its supporting surface. The character is unaffected.- Specified by:
getGroundState
in interfaceConstCharacterBase
- Returns:
- an enum value (not null)
-
getGroundSubShapeId
public int getGroundSubShapeId()Identify the face on the supporting surface where contact is occurring. The character is unaffected.- Specified by:
getGroundSubShapeId
in interfaceConstCharacterBase
- Returns:
- a
SubShapeId
value
-
getGroundUserData
public long getGroundUserData()Return the user data of the supporting surface. The character is unaffected.- Specified by:
getGroundUserData
in interfaceConstCharacterBase
- Returns:
- the 64-bit value
-
getGroundVelocity
Copy the world-space velocity of the supporting surface. The character is unaffected.- Specified by:
getGroundVelocity
in interfaceConstCharacterBase
- Returns:
- a new velocity vector (meters per second 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)
-
getShape
Access the character's shape. The character is unaffected.- Specified by:
getShape
in interfaceConstCharacterBase
- Returns:
- a new immutable JVM object with the pre-existing native object
assigned, or
null
if none
-
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
-
getUp
Copy the character's "up" direction. The character is unaffected.- Specified by:
getUp
in interfaceConstCharacterBase
- Returns:
- a new direction vector
-
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
-
isSlopeTooSteep
Test whether the specified normal direction is too steep. The character is unaffected.- Specified by:
isSlopeTooSteep
in interfaceConstCharacterBase
- Parameters:
normal
- the surface normal to test (not null, unaffected)- Returns:
true
if too steep, otherwisefalse
-
isSupported
public boolean isSupported()Test whether the character is supported. The character is unaffected.- Specified by:
isSupported
in interfaceConstCharacterBase
- Returns:
true
if supported, otherwisefalse
-
saveState
Save the character's state to the specified recorder. The character is unaffected.- Specified by:
saveState
in interfaceConstCharacterBase
- Parameters:
recorder
- the recorder to save to (not null)
-
toRefC
Create a counted reference to the nativeCharacter
.- Specified by:
toRefC
in interfaceConstCharacter
- Returns:
- a new JVM object with a new native object assigned
-
getPtr
Temporarily access the referencedCharacter
. -
targetVa
public long targetVa()Return the address of the nativeCharacter
. No objects are affected.- Specified by:
targetVa
in interfaceConstJoltPhysicsObject
- Overrides:
targetVa
in classJoltPhysicsObject
- Returns:
- a virtual address (not zero)
-
toRef
Create another counted reference to the nativeCharacter
.
-