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 TypeMethodDescriptionvoidAdd 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.floatReturn the maximum slope the character can walk on.intReturn 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.intIdentify the face on the supporting surface where contact is occurring.longReturn the user data of the supporting surface.Copy the world-space velocity of the supporting surface.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.getPtr()Temporarily access the referencedCharacter.intCount the active references to the nativeCharacter.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.voidUpdate the specified counted reference to refer to the character's shape.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.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.booleanisSlopeTooSteep(Vec3Arg normal) Test whether the specified normal direction is too steep.booleanTest whether the character is supported.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.voidrestoreState(StateRecorder recorder) Restore the character's state from the specified recorder.voidsaveState(StateRecorder recorder) Save the character's state to the specified recorder.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.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.longtargetVa()Return the address of the nativeCharacter.toRef()Create another counted reference to the nativeCharacter.toRefC()Create another counted reference to the nativeCharacter.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, toString, vaMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods 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 itsPhysicsSystemand activate it, using the locking body interface. -
addToPhysicsSystem
Add the character to itsPhysicsSystemusing the locking body interface.- Parameters:
activation- whether to activate the character (notnull, default=Activate)
-
addToPhysicsSystem
Add the character to itsPhysicsSystem.- Parameters:
activation- whether to activate the character (notnull, 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 itsPhysicsSystemusing 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 (notnull)
-
setLinearVelocity
public 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)
-
setLinearVelocity
public 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)
-
setLinearVelocity
Alter the character's linear velocity using the locking body interface.- Parameters:
velocity- the desired velocity (meters per second in system coordinates, notnull, unaffected)
-
setLinearVelocity
Alter the character's linear velocity.- Parameters:
velocity- the desired velocity (meters per second in system coordinates, notnull, 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 (notnull, unaffected)maxPenetrationDepth- the maximum penetration to allow, or MAX_VALUE to skip the penetration check- Returns:
trueif the replacement succeeded, otherwisefalse
-
setShape
Attempt to replace the character's shape.- Parameters:
shape- the desired shape (notnull, 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:
trueif the replacement succeeded, otherwisefalse
-
getBodyId
public int getBodyId()Return the ID of the body associated with the character. The character is unaffected. (native function: GetBodyID)- Specified by:
getBodyIdin interfaceConstCharacter- Returns:
- the
BodyIDvalue
-
getCenterOfMassPosition
Copy the location of the rigid body's center of mass using the locking body interface. The character is unaffected.- Specified by:
getCenterOfMassPositionin 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:
getCenterOfMassPositionin 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)
-
getCharacterSettings
Generate settings to reconstruct the character, using the locking body interface. The character is unaffected.- Specified by:
getCharacterSettingsin interfaceConstCharacter- Returns:
- a new object
-
getCharacterSettings
Generate settings to reconstruct the character. The character is unaffected.- Specified by:
getCharacterSettingsin interfaceConstCharacter- Parameters:
lockBodies-true→ use the locking body interface,- Returns:
- a new object
-
getCosMaxSlopeAngle
public float getCosMaxSlopeAngle()Return the maximum slope the character can walk on. The character is unaffected.- Specified by:
getCosMaxSlopeAnglein 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:
getGroundBodyIdin interfaceConstCharacterBase- Returns:
- the
BodyIDvalue
-
getGroundMaterial
Access the material of the supporting surface. The character is unaffected.- Specified by:
getGroundMaterialin 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:
getGroundNormalin 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:
getGroundPositionin 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:
getGroundStatein 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:
getGroundSubShapeIdin interfaceConstCharacterBase- Returns:
- a
SubShapeIDvalue
-
getGroundUserData
public long getGroundUserData()Return the user data of the supporting surface. The character is unaffected.- Specified by:
getGroundUserDatain interfaceConstCharacterBase- Returns:
- the 64-bit value
-
getGroundVelocity
Copy the world-space velocity of the supporting surface. The character is unaffected.- Specified by:
getGroundVelocityin 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:
getLayerin interfaceConstCharacter- Returns:
- a layer index (≥0)
-
getLayer
public int getLayer(boolean lockBodies) Return the character's object layer. The character is unaffected.- Specified by:
getLayerin 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:
getLinearVelocityin 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:
getLinearVelocityin 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:
getPositionin interfaceConstCharacter- Returns:
- a new location vector (in system coordinates)
-
getPosition
Copy the location of the character. The character is unaffected.- Specified by:
getPositionin 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:
getPositionAndRotationin interfaceConstCharacter- Parameters:
storeLocation- storage for the location (in system coordinates, notnull, modified)storeOrientation- storage for the orientation (in system coordinates, notnull, modified)
-
getPositionAndRotation
Copy the position of the associated body. The character is unaffected.- Specified by:
getPositionAndRotationin interfaceConstCharacter- Parameters:
storeLocation- storage for the location (in system coordinates, notnull, modified)storeOrientation- storage for the orientation (in system coordinates, notnull, modified)lockBodies-true→ use the locking body interface,false→ use the non-locking body interface (default=true)
-
getRefCount
public int getRefCount()Count the active references to the nativeCharacter. The settings are unaffected.- Specified by:
getRefCountin interfaceConstCharacterBase- Returns:
- the count (≥0)
-
getRotation
Copy the orientation of the character using the locking body interface. The character is unaffected.- Specified by:
getRotationin interfaceConstCharacter- Returns:
- a new rotation quaternion (in system coordinates)
-
getRotation
Copy the orientation of the character. The character is unaffected.- Specified by:
getRotationin 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:
getShapein interfaceConstCharacterBase- Returns:
- a new immutable JVM object with the pre-existing native object
assigned, or
nullif none
-
getShape
Update the specified counted reference to refer to the character's shape. The character is unaffected.- Specified by:
getShapein interfaceConstCharacterBase- Parameters:
storeRef- storage for the reference (notnull, modified)
-
getTransformedShape
Generate a TransformedShape that represents the volume occupied by the character, using the locking body interface. The character is unaffected.- Specified by:
getTransformedShapein interfaceConstCharacter- Returns:
- a new object
-
getTransformedShape
Generate a TransformedShape that represents the volume occupied by the character. The character is unaffected.- Specified by:
getTransformedShapein 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:
getUpin 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:
getWorldTransformin interfaceConstCharacter- Returns:
- a new coordinate transform matrix
-
getWorldTransform
Calculate the character's local-to-system coordinate transform. The character is unaffected.- Specified by:
getWorldTransformin 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:
isSlopeTooSteepin interfaceConstCharacterBase- Parameters:
normal- the surface normal to test (notnull, unaffected)- Returns:
trueif too steep, otherwisefalse
-
isSupported
public boolean isSupported()Test whether the character is supported. The character is unaffected.- Specified by:
isSupportedin interfaceConstCharacterBase- Returns:
trueif supported, otherwisefalse
-
saveState
Save the character's state to the specified recorder. The character is unaffected.- Specified by:
saveStatein interfaceConstCharacterBase- Parameters:
recorder- the recorder to save to (notnull)
-
toRefC
Create another counted reference to the nativeCharacter.- Specified by:
toRefCin 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:
targetVain interfaceConstJoltPhysicsObject- Overrides:
targetVain classJoltPhysicsObject- Returns:
- a virtual address (not zero)
-
toRef
Create another counted reference to the nativeCharacter.
-