public class PhysicsCharacter extends PhysicsCollisionObject
Modifier and Type | Field and Description |
---|---|
protected long |
characterId
Unique identifier of btKinematicCharacterController (as opposed to its
collision object, which is a ghost).
|
protected float |
fallSpeed |
protected float |
jumpSpeed |
protected boolean |
locationDirty |
protected float |
stepHeight |
protected Quaternion |
tmp_inverseWorldRotation |
protected int |
upAxis |
protected Vector3f |
walkDirection |
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, collisionGroup, collisionGroupsMask, collisionShape, objectId
Modifier | Constructor and Description |
---|---|
protected |
PhysicsCharacter()
No-argument constructor needed by SavableClassUtil.
|
|
PhysicsCharacter(CollisionShape shape,
float stepHeight)
Instantiate a character with the specified collision shape and step
height.
|
Modifier and Type | Method and Description |
---|---|
protected void |
buildObject()
Create the configured character in Bullet.
|
void |
destroy()
Has no effect.
|
protected void |
finalize()
Finalize this physics character just before it is destroyed.
|
float |
getAngularDamping()
Read this character's angular damping.
|
Vector3f |
getAngularVelocity(Vector3f out)
Copy this character's angular velocity.
|
float |
getCcdMotionThreshold()
Calculate this character's continuous collision detection (CCD) motion
threshold.
|
float |
getCcdSquareMotionThreshold()
Calculate the square of this character's continuous collision detection
(CCD) motion threshold.
|
float |
getCcdSweptSphereRadius()
Read the radius of the sphere used for continuous collision detection
(CCD).
|
long |
getControllerId()
used internally
|
float |
getFallSpeed()
Read this character's fall speed.
|
float |
getGravity()
Deprecated.
Deprecated in bullet 2.86.1. Use getGravity(Vector3f)
instead.
|
Vector3f |
getGravity(Vector3f out)
Copy this character's gravitational acceleration.
|
float |
getJumpSpeed()
Read this character's jump speed.
|
float |
getLinearDamping()
Read this character's linear damping.
|
Vector3f |
getLinearVelocity(Vector3f out)
Copy the linear velocity of this character's center of mass.
|
float |
getMaxPenetrationDepth()
Read this character's maximum penetration depth.
|
float |
getMaxSlope()
Read this character's maximum slope angle.
|
Vector3f |
getPhysicsLocation()
Copy the location of this character's center of mass.
|
Vector3f |
getPhysicsLocation(Vector3f trans)
Copy the location of this character's center of mass.
|
float |
getStepHeight()
Read this character's step height.
|
int |
getUpAxis()
Read the index of the "up" axis.
|
Vector3f |
getWalkDirection()
Access the walk offset.
|
void |
jump()
Deprecated.
Deprecated in bullet 2.86.1. Use jump(Vector3f) instead.
|
void |
jump(Vector3f dir)
Jump in the specified direction.
|
boolean |
onGround()
Test whether this character is on the ground.
|
void |
read(JmeImporter e)
De-serialize this character from the specified importer, for example when
loading from a J3O file.
|
void |
setAngularDamping(float v)
Alter this character's angular damping.
|
void |
setAngularVelocity(Vector3f v)
Alter this character's angular velocity.
|
void |
setCcdMotionThreshold(float threshold)
Alter the amount of motion required to activate continuous collision
detection (CCD).
|
void |
setCcdSweptSphereRadius(float radius)
Alter this character's continuous collision detection (CCD) swept sphere
radius.
|
void |
setCollisionShape(CollisionShape collisionShape)
Apply the specified CollisionShape to this character.
|
void |
setContactResponse(boolean responsive)
Enable/disable this character's contact response.
|
void |
setFallSpeed(float fallSpeed)
Alter this character's fall speed.
|
void |
setGravity(float value)
Deprecated.
Deprecated in bullet 2.86.1. Use setGravity(Vector3f)
instead.
|
void |
setGravity(Vector3f value)
Alter this character's gravitational acceleration.
|
void |
setJumpSpeed(float jumpSpeed)
Alter this character's jump speed.
|
void |
setLinearDamping(float v)
Alter this character's linear damping.
|
void |
setLinearVelocity(Vector3f v)
Alter the linear velocity of this character's center of mass.
|
void |
setMaxPenetrationDepth(float v)
Alter this character's maximum penetration depth.
|
void |
setMaxSlope(float slopeRadians)
Alter this character's maximum slope angle.
|
void |
setPhysicsLocation(Vector3f location)
Directly alter this character's location.
|
void |
setStepHeight(float v)
Alter this character's step height.
|
void |
setUp(Vector3f axis)
Alter this character's "up" direction.
|
void |
setUpAxis(int axis)
Deprecated.
Deprecated in bullet 2.86.1 use setUp(Vector3f) instead
|
void |
setWalkDirection(Vector3f vec)
Alter the walk offset.
|
void |
warp(Vector3f location)
Directly alter the location of this character's center of mass.
|
void |
write(JmeExporter e)
Serialize this character, for example when saving to a J3O file.
|
addCollideWithGroup, attachCollisionShape, finalizeNative, getCollideWithGroups, getCollisionFlags, getCollisionGroup, getCollisionShape, getDeactivationTime, getObjectId, getUserObject, initUserPointer, isContactResponse, removeCollideWithGroup, setCollideWithGroups, setCollisionFlags, setCollisionGroup, setUserObject
protected long characterId
protected float stepHeight
protected Vector3f walkDirection
protected float fallSpeed
protected float jumpSpeed
protected int upAxis
protected boolean locationDirty
protected final Quaternion tmp_inverseWorldRotation
protected PhysicsCharacter()
public PhysicsCharacter(CollisionShape shape, float stepHeight)
shape
- the desired shape (not null, alias created)stepHeight
- the quantization size for vertical movementprotected void buildObject()
public void warp(Vector3f location)
location
- the desired physics location (not null, unaffected)public void setWalkDirection(Vector3f vec)
vec
- the desired position increment for each physics tick (not
null, unaffected)public Vector3f getWalkDirection()
@Deprecated public void setUpAxis(int axis)
axis
- which axis: 0→X, 1→Y, 2→Zpublic void setUp(Vector3f axis)
axis
- the desired direction (not null, not zero, unaffected)public void setAngularVelocity(Vector3f v)
v
- the desired angular velocity vector (not null, unaffected)public Vector3f getAngularVelocity(Vector3f out)
out
- storage for the result (modified if not null)public void setLinearVelocity(Vector3f v)
v
- the desired velocity vector (not null)public Vector3f getLinearVelocity(Vector3f out)
out
- storage for the result (modified if not null)public int getUpAxis()
public void setFallSpeed(float fallSpeed)
fallSpeed
- the desired speed (default=55)public float getFallSpeed()
public void setJumpSpeed(float jumpSpeed)
jumpSpeed
- the desired speed (default=10)public float getJumpSpeed()
@Deprecated public void setGravity(float value)
value
- the desired downward (-Y) component of the acceleration
(typically positive)public void setGravity(Vector3f value)
value
- the desired acceleration vector (not null, unaffected)@Deprecated public float getGravity()
public Vector3f getGravity(Vector3f out)
out
- storage for the result (modified if not null)public float getLinearDamping()
public void setLinearDamping(float v)
v
- the desired viscous damping ratio (0→no damping,
1→critically damped)public float getAngularDamping()
public void setAngularDamping(float v)
v
- the desired viscous damping ratio (0→no damping,
1→critically damped, default=0)public float getStepHeight()
public void setStepHeight(float v)
v
- the desired height (in physics-space units)public float getMaxPenetrationDepth()
public void setMaxPenetrationDepth(float v)
v
- the desired depth (in physics-space units)public void setMaxSlope(float slopeRadians)
slopeRadians
- the desired angle (in radians)public float getMaxSlope()
public void setContactResponse(boolean responsive)
responsive
- true to respond to contacts, false to ignore them
(default=true)public boolean onGround()
@Deprecated public void jump()
public void jump(Vector3f dir)
dir
- desired jump direction (not null, unaffected)public void setCollisionShape(CollisionShape collisionShape)
setCollisionShape
in class PhysicsCollisionObject
collisionShape
- the shape to apply (not null, alias created)public void setPhysicsLocation(Vector3f location)
warp(com.jme3.math.Vector3f)
).)location
- the desired location (not null, unaffected)public Vector3f getPhysicsLocation(Vector3f trans)
trans
- storage for the result (modified if not null)public Vector3f getPhysicsLocation()
public void setCcdSweptSphereRadius(float radius)
radius
- (≥0, default=0)public void setCcdMotionThreshold(float threshold)
This addresses the issue of fast objects passing through other objects with no collision detected.
threshold
- the desired threshold velocity (>0) or zero to
disable CCD (default=0)public float getCcdSweptSphereRadius()
public float getCcdMotionThreshold()
public float getCcdSquareMotionThreshold()
public long getControllerId()
public void destroy()
public void write(JmeExporter e) throws java.io.IOException
write
in interface Savable
write
in class PhysicsCollisionObject
e
- exporter (not null)java.io.IOException
- from exporterpublic void read(JmeImporter e) throws java.io.IOException
read
in interface Savable
read
in class PhysicsCollisionObject
e
- importer (not null)java.io.IOException
- from importerprotected void finalize() throws java.lang.Throwable
finalize
in class PhysicsCollisionObject
java.lang.Throwable
- ignored by the garbage collector