java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.NonCopyable
com.github.stephengold.joltjni.CharacterBase
- All Implemented Interfaces:
ConstCharacterBase
,ConstJoltPhysicsObject
,RefTarget
,AutoCloseable
,Comparable<JoltPhysicsObject>
- Direct Known Subclasses:
Character
,CharacterVirtual
Base class to represent a player navigating a
PhysicsSystem
.-
Method Summary
Modifier and TypeMethodDescriptionfloat
Return the maximum slope that 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
Count the active references to the nativeCharacterBase
.getShape()
Access the character's shape.getUp()
Copy the character's "up" direction.boolean
isSlopeTooSteep
(Vec3Arg normal) Test whether the specified normal direction is too steep.boolean
Test whether the character is supported.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
Mark the nativeCharacterBase
as embedded.void
setMaxSlopeAngle
(float angle) Alter the maximum slope that the character can walk on.void
Alter the character's "up" direction.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
-
Method Details
-
restoreState
Restore the character's state from the specified recorder.- Parameters:
recorder
- the recorder to restore from (not null)
-
setMaxSlopeAngle
public void setMaxSlopeAngle(float angle) Alter the maximum slope that the character can walk on.- Parameters:
angle
- the desired slope angle (in radians, default=5*Pi/18)
-
setUp
Alter the character's "up" direction.- Parameters:
up
- the desired direction (not null, unaffected, default=(0,1,0))
-
getCosMaxSlopeAngle
public float getCosMaxSlopeAngle()Return the maximum slope that 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. (native method: GetGroundBodyID)- 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)
-
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
-
getUp
Copy the character's "up" direction. The character is unaffected.- Specified by:
getUp
in interfaceConstCharacterBase
- Returns:
- a new direction vector
-
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)
-
getRefCount
public int getRefCount()Count the active references to the nativeCharacterBase
. The character is unaffected.- Specified by:
getRefCount
in interfaceRefTarget
- Returns:
- the count (≥0)
-
setEmbedded
public void setEmbedded()Mark the nativeCharacterBase
as embedded.- Specified by:
setEmbedded
in interfaceRefTarget
-