Package com.jme3.bullet.objects
Class PhysicsCharacter
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.PhysicsCollisionObject
com.jme3.bullet.objects.PhysicsCharacter
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
A collision object for simplified character simulation, based on Bullet's
btKinematicCharacterController
.-
Field Summary
Fields inherited from class com.jme3.bullet.collision.PhysicsCollisionObject
COLLISION_GROUP_01, COLLISION_GROUP_02, COLLISION_GROUP_03, COLLISION_GROUP_04, COLLISION_GROUP_05, COLLISION_GROUP_06, COLLISION_GROUP_07, COLLISION_GROUP_08, COLLISION_GROUP_09, COLLISION_GROUP_10, COLLISION_GROUP_11, COLLISION_GROUP_12, COLLISION_GROUP_13, COLLISION_GROUP_14, COLLISION_GROUP_15, COLLISION_GROUP_16, COLLISION_GROUP_NONE, logger
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ModifierConstructorDescriptionprotected
No-argument constructor needed by SavableClassUtil.PhysicsCharacter
(ConvexShape shape, float stepHeight) Instantiate a responsive character with the specified CollisionShape and step height. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned character into a deep-cloned one, using the specified Cloner and original to resolve copied fields.float
Determine this character's angular damping.com.jme3.math.Vector3f
getAngularVelocity
(com.jme3.math.Vector3f storeResult) Determine this character's angular velocity.long
Determine the ID of the btKinematicCharacterController.float
Determine this character's maximum fall speed (terminal velocity).com.jme3.math.Vector3f
getGravity
(com.jme3.math.Vector3f storeResult) Determine this character's gravitational acceleration.float
Determine this character's jump speed.float
Determine this character's linear damping.com.jme3.math.Vector3f
getLinearVelocity
(com.jme3.math.Vector3f storeResult) Determine the linear velocity of this character's center.float
Determine this character's maximum penetration depth.float
Determine this character's maximum slope angle.float
Determine this character's step height.com.jme3.math.Vector3f
getUpDirection
(com.jme3.math.Vector3f storeResult) Determine this character's "up" direction.com.jme3.math.Vector3f
getWalkDirection
(com.jme3.math.Vector3f storeResult) Determine the character's walk offset.boolean
Test whether the ghost's convex-sweep test is in use.void
jump()
Jump in the "up" direction.void
jump
(com.jme3.math.Vector3f direction) Jump in the specified direction.boolean
onGround()
Test whether this character is on the ground.void
read
(com.jme3.export.JmeImporter importer) De-serialize this character from the specified importer, for example when loading from a J3O file.void
reset
(PhysicsSpace space) Reset this character, including its velocity.void
setAngularDamping
(float damping) Alter this character's angular damping.void
setAngularVelocity
(com.jme3.math.Vector3f angularVelocity) Alter this character's angular velocity.void
setCollisionShape
(CollisionShape collisionShape) Apply the specified CollisionShape to this character.void
setContactResponse
(boolean newState) Enable/disable this character's contact response.void
setFallSpeed
(float fallSpeed) Alter this character's maximum fall speed (terminal velocity).void
setGravity
(float downwardAcceleration) Alter the character's gravitational acceleration without altering its "up" vector.void
setGravity
(com.jme3.math.Vector3f gravity) Alter this character's gravitational acceleration.void
setJumpSpeed
(float jumpSpeed) Alter this character's jump speed.void
setLinearDamping
(float damping) Alter this character's linear damping.void
setLinearVelocity
(com.jme3.math.Vector3f velocity) Alter the linear velocity of this character's center.void
setMaxPenetrationDepth
(float depth) Alter this character's maximum penetration depth.void
setMaxSlope
(float slopeRadians) Alter this character's maximum slope angle.void
setPhysicsLocation
(com.jme3.math.Vector3f location) Directly alter this character's location.void
setPhysicsLocationDp
(com.simsilica.mathd.Vec3d location) Directly alter this character's location.void
setStepHeight
(float height) Alter this character's step height.void
setSweepTest
(boolean useGhostSweepTest) Alter which convex-sweep test is used.void
setUp
(com.jme3.math.Vector3f direction) Alter this character's "up" direction.void
setWalkDirection
(com.jme3.math.Vector3f offset) Alter this character's walk offset.void
warp
(com.jme3.math.Vector3f location) Directly alter the location of this character's center.void
write
(com.jme3.export.JmeExporter exporter) Serialize this character to the specified exporter, for example when saving to a J3O file.Methods inherited from class com.jme3.bullet.collision.PhysicsCollisionObject
activate, addCollideWithGroup, addToIgnoreList, attachCollisionShape, boundingBox, clearIgnoreList, cloneIgnoreList, collisionFlags, copyPcoProperties, countIgnored, debugMeshInitListener, debugMeshNormals, debugMeshResolution, debugNumSides, finalizeNative, findInstance, getActivationState, getAnisotropicFriction, getApplicationData, getCcdMotionThreshold, getCcdSquareMotionThreshold, getCcdSweptSphereRadius, getCollideWithGroups, getCollisionGroup, getCollisionShape, getCollisionSpace, getContactDamping, getContactProcessingThreshold, getContactStiffness, getDeactivationTime, getDebugMaterial, getFriction, getInternalType, getPhysicsLocation, getPhysicsLocation, getPhysicsLocationDp, getPhysicsRotation, getPhysicsRotationDp, getPhysicsRotationMatrix, getPhysicsRotationMatrixDp, getRestitution, getRollingFriction, getScale, getSpinningFriction, getTransform, getUserObject, hasAnisotropicFriction, ignores, initUserPointer, isActive, isContactResponse, isInWorld, isStatic, jmeClone, listIgnoredPcos, proxyGroup, proxyMask, readPcoProperties, removeCollideWithGroup, removeFromIgnoreList, setActivationState, setAnisotropicFriction, setApplicationData, setCcdMotionThreshold, setCcdSweptSphereRadius, setCollideWithGroups, setCollisionFlags, setCollisionGroup, setContactDamping, setContactProcessingThreshold, setContactStiffness, setDeactivationTime, setDebugMaterial, setDebugMeshInitListener, setDebugMeshNormals, setDebugMeshResolution, setDebugNumSides, setFriction, setIgnoreList, setLocationAndBasis, setRestitution, setRollingFriction, setSpinningFriction, setUserIndex, setUserIndex2, setUserIndex3, setUserObject, spaceId, toString, userIndex, userIndex2, userIndex3
Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, unassignNativeObject
-
Field Details
-
logger2
message logger for this class
-
-
Constructor Details
-
PhysicsCharacter
protected PhysicsCharacter()No-argument constructor needed by SavableClassUtil. -
PhysicsCharacter
Instantiate a responsive character with the specified CollisionShape and step height.- Parameters:
shape
- the desired shape (not null, convex, alias created)stepHeight
- the maximum amount of vertical movement without jumping or falling (in physics-space units)
-
-
Method Details
-
getAngularDamping
public float getAngularDamping()Determine this character's angular damping.- Returns:
- the viscous damping ratio (0→no damping, 1→critically damped)
-
getAngularVelocity
public com.jme3.math.Vector3f getAngularVelocity(com.jme3.math.Vector3f storeResult) Determine this character's angular velocity.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the velocity vector (either storeResult or a new vector, not null)
-
getControllerId
public long getControllerId()Determine the ID of the btKinematicCharacterController. Used internally.- Returns:
- the unique identifier (not zero)
-
getFallSpeed
public float getFallSpeed()Determine this character's maximum fall speed (terminal velocity).- Returns:
- the speed (in physics-space units per second)
-
getGravity
public com.jme3.math.Vector3f getGravity(com.jme3.math.Vector3f storeResult) Determine this character's gravitational acceleration.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- an acceleration vector (in physics-space units per second squared, direction opposite the "up" vector, either storeResult or a new vector, not null)
-
getJumpSpeed
public float getJumpSpeed()Determine this character's jump speed.- Returns:
- the speed (in physics-space units per second)
-
getLinearDamping
public float getLinearDamping()Determine this character's linear damping.- Returns:
- the viscous damping ratio (0→no damping, 1→critically damped)
-
getLinearVelocity
public com.jme3.math.Vector3f getLinearVelocity(com.jme3.math.Vector3f storeResult) Determine the linear velocity of this character's center.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a vector (either storeResult or a new vector, not null)
-
getMaxPenetrationDepth
public float getMaxPenetrationDepth()Determine this character's maximum penetration depth.- Returns:
- the depth (in physics-space units)
-
getMaxSlope
public float getMaxSlope()Determine this character's maximum slope angle.- Returns:
- the angle relative to the horizontal (in radians)
-
getStepHeight
public float getStepHeight()Determine this character's step height.- Returns:
- the maximum amount of vertical movement without jumping or falling (in physics-space units)
-
getUpDirection
public com.jme3.math.Vector3f getUpDirection(com.jme3.math.Vector3f storeResult) Determine this character's "up" direction.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a unit vector (in physics-space coordinates, in the direction opposite the gravity vector, either storeResult or a new vector, not null)
-
getWalkDirection
public com.jme3.math.Vector3f getWalkDirection(com.jme3.math.Vector3f storeResult) Determine the character's walk offset.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- an offset vector (either storeResult or a new vector, not null)
-
isUsingGhostSweepTest
public boolean isUsingGhostSweepTest()Test whether the ghost's convex-sweep test is in use.- Returns:
- true if using the ghost's test, otherwise false
-
jump
public void jump()Jump in the "up" direction. -
jump
public void jump(com.jme3.math.Vector3f direction) Jump in the specified direction.- Parameters:
direction
- desired jump direction (not null, unaffected) or (0,0,0) to jump in the "up" direction
-
onGround
public boolean onGround()Test whether this character is on the ground.- Returns:
- true if on the ground, otherwise false
-
reset
Reset this character, including its velocity.- Parameters:
space
- (not null)
-
setAngularDamping
public void setAngularDamping(float damping) Alter this character's angular damping.- Parameters:
damping
- the desired viscous damping ratio (0→no damping, 1→critically damped, default=0)
-
setAngularVelocity
public void setAngularVelocity(com.jme3.math.Vector3f angularVelocity) Alter this character's angular velocity.- Parameters:
angularVelocity
- the desired angular velocity vector (not null, unaffected)
-
setCollisionShape
Apply the specified CollisionShape to this character. Note that the character should not be in any PhysicsSpace while changing shape; the character gets rebuilt on the physics side.- Overrides:
setCollisionShape
in classPhysicsCollisionObject
- Parameters:
collisionShape
- the shape to apply (not null, convex, alias created)
-
setContactResponse
public void setContactResponse(boolean newState) Enable/disable this character's contact response.- Parameters:
newState
- true to respond to contact forces, false to ignore them (default=true)
-
setFallSpeed
public void setFallSpeed(float fallSpeed) Alter this character's maximum fall speed (terminal velocity).- Parameters:
fallSpeed
- the desired speed (in physics-space units per second, default=55)
-
setGravity
public void setGravity(float downwardAcceleration) Alter the character's gravitational acceleration without altering its "up" vector.- Parameters:
downwardAcceleration
- the desired downward acceleration (in physics-space units per second squared, default=29.4)
-
setGravity
public void setGravity(com.jme3.math.Vector3f gravity) Alter this character's gravitational acceleration. This may also alter its "up" vector.- Parameters:
gravity
- the desired acceleration vector (in physics-space units per second squared, not null, unaffected, default=(0,-29.4,0))
-
setJumpSpeed
public void setJumpSpeed(float jumpSpeed) Alter this character's jump speed.- Parameters:
jumpSpeed
- the desired speed (in physics-space units per second, default=10)
-
setLinearDamping
public void setLinearDamping(float damping) Alter this character's linear damping.- Parameters:
damping
- the desired viscous damping ratio (0→no damping, 1→critically damped, default=0)
-
setLinearVelocity
public void setLinearVelocity(com.jme3.math.Vector3f velocity) Alter the linear velocity of this character's center.- Parameters:
velocity
- the desired velocity vector (not null)
-
setMaxPenetrationDepth
public void setMaxPenetrationDepth(float depth) Alter this character's maximum penetration depth.- Parameters:
depth
- the desired depth (in physics-space units, default=0.2)
-
setMaxSlope
public void setMaxSlope(float slopeRadians) Alter this character's maximum slope angle.- Parameters:
slopeRadians
- the desired angle above to the horizontal plane (in radians, ≥0, ≤Pi/2, default=Pi/4)
-
setPhysicsLocation
public void setPhysicsLocation(com.jme3.math.Vector3f location) Directly alter this character's location. (This is equivalent towarp(com.jme3.math.Vector3f)
.)- Parameters:
location
- the desired location (not null, finite, unaffected)
-
setPhysicsLocationDp
public void setPhysicsLocationDp(com.simsilica.mathd.Vec3d location) Directly alter this character's location.- Parameters:
location
- the desired location (not null, unaffected)
-
setStepHeight
public void setStepHeight(float height) Alter this character's step height.- Parameters:
height
- the desired maximum amount of vertical movement without jumping or falling (in physics-space units, default=1)
-
setSweepTest
public void setSweepTest(boolean useGhostSweepTest) Alter which convex-sweep test is used.- Parameters:
useGhostSweepTest
- true to use the ghost's test, false to use the world's test (default=true)
-
setUp
public void setUp(com.jme3.math.Vector3f direction) Alter this character's "up" direction. This may also alter its gravity vector.- Parameters:
direction
- the desired direction (not null, not zero, unaffected, default=(0,1,0))
-
setWalkDirection
public void setWalkDirection(com.jme3.math.Vector3f offset) Alter this character's walk offset. The offset must be perpendicular to the "up" direction. It will continue to be applied until altered again.- Parameters:
offset
- the desired location increment for each simulation step (in physics-space coordinates, not null, unaffected, default=(0,0,0))
-
warp
public void warp(com.jme3.math.Vector3f location) Directly alter the location of this character's center.- Parameters:
location
- the desired physics location (not null, finite, unaffected)
-
cloneFields
Callback fromCloner
to convert this shallow-cloned character into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFields
in interfacecom.jme3.util.clone.JmeCloneable
- Overrides:
cloneFields
in classPhysicsCollisionObject
- Parameters:
cloner
- the Cloner that's cloning this character (not null)original
- the instance from which this character was shallow-cloned (not null, unaffected)
-
read
De-serialize this character from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Overrides:
read
in classPhysicsCollisionObject
- Parameters:
importer
- (not null)- Throws:
IOException
- from the importer
-
write
Serialize this character to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfacecom.jme3.export.Savable
- Overrides:
write
in classPhysicsCollisionObject
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-