Class PhysicsCharacter

java.lang.Object
com.jme3.bullet.collision.PhysicsCollisionObject
com.jme3.bullet.objects.PhysicsCharacter
All Implemented Interfaces:
Savable
Direct Known Subclasses:
CharacterControl

public class PhysicsCharacter extends PhysicsCollisionObject
Basic Bullet Character
  • Field Details

    • character

      protected com.bulletphysics.dynamics.character.KinematicCharacterController character
    • stepHeight

      protected float stepHeight
    • walkDirection

      protected Vector3f walkDirection
    • fallSpeed

      protected float fallSpeed
    • jumpSpeed

      protected float jumpSpeed
    • upAxis

      protected int upAxis
    • gObject

      protected com.bulletphysics.collision.dispatch.PairCachingGhostObject gObject
    • locationDirty

      protected boolean locationDirty
    • tmp_inverseWorldRotation

      protected final Quaternion tmp_inverseWorldRotation
  • Constructor Details

    • PhysicsCharacter

      protected PhysicsCharacter()
    • PhysicsCharacter

      public PhysicsCharacter(CollisionShape shape, float stepHeight)
      Parameters:
      shape - The CollisionShape (no Mesh or CompoundCollisionShapes)
      stepHeight - The quantization size for vertical movement
  • Method Details

    • buildObject

      protected void buildObject()
    • warp

      public void warp(Vector3f location)
      Sets the location of this physics character
      Parameters:
      location - the desired physics location (not null, unaffected)
    • setWalkDirection

      public void setWalkDirection(Vector3f vec)
      Set the walk direction, works continuously. This should probably be called setPositionIncrementPerSimulatorStep. This is neither a direction nor a velocity, but the amount to increment the position each physics tick. So vector length = accuracy*speed in m/s
      Parameters:
      vec - the walk direction to set
    • getWalkDirection

      public Vector3f getWalkDirection()
      Returns:
      the currently set walkDirection
    • setUpAxis

      public void setUpAxis(int axis)
    • getUpAxis

      public int getUpAxis()
    • setFallSpeed

      public void setFallSpeed(float fallSpeed)
    • getFallSpeed

      public float getFallSpeed()
    • setJumpSpeed

      public void setJumpSpeed(float jumpSpeed)
    • getJumpSpeed

      public float getJumpSpeed()
    • setGravity

      public void setGravity(float value)
      Alter the character's gravitational acceleration without altering its "up" vector.
      Parameters:
      value - the desired downward acceleration (in physics-space units per second squared, default=29.4)
    • getGravity

      public float getGravity()
    • setMaxSlope

      public void setMaxSlope(float slopeRadians)
    • getMaxSlope

      public float getMaxSlope()
    • setContactResponse

      public void setContactResponse(boolean newState)
      Enable/disable this body's contact response.
      Parameters:
      newState - true to respond to contacts (default=true)
    • isContactResponse

      public boolean isContactResponse()
      Test whether this body responds to contacts.
      Returns:
      true if responsive, otherwise false
    • onGround

      public boolean onGround()
    • jump

      public void jump()
    • setCollisionShape

      public void setCollisionShape(CollisionShape collisionShape)
      Description copied from class: PhysicsCollisionObject
      Sets a CollisionShape to this physics object, note that the object should not be in the physics space when adding a new collision shape as it is rebuilt on the physics side.
      Overrides:
      setCollisionShape in class PhysicsCollisionObject
      Parameters:
      collisionShape - the CollisionShape to set
    • setPhysicsLocation

      public void setPhysicsLocation(Vector3f location)
      Set the physics location (same as warp())
      Parameters:
      location - the location of the actual physics object
    • getPhysicsLocation

      public Vector3f getPhysicsLocation(Vector3f trans)
      Parameters:
      trans - storage for the result (modified if not null)
      Returns:
      the physicsLocation
    • getPhysicsLocation

      public Vector3f getPhysicsLocation()
      Returns:
      the physicsLocation
    • setCcdSweptSphereRadius

      public void setCcdSweptSphereRadius(float radius)
    • setCcdMotionThreshold

      public void setCcdMotionThreshold(float threshold)
    • getCcdSweptSphereRadius

      public float getCcdSweptSphereRadius()
    • getCcdMotionThreshold

      public float getCcdMotionThreshold()
    • getCcdSquareMotionThreshold

      public float getCcdSquareMotionThreshold()
    • getControllerId

      public com.bulletphysics.dynamics.character.KinematicCharacterController getControllerId()
      used internally
      Returns:
      the pre-existing object
    • getObjectId

      public com.bulletphysics.collision.dispatch.PairCachingGhostObject getObjectId()
      used internally
      Returns:
      the pre-existing object
    • destroy

      public void destroy()
    • write

      public void write(JmeExporter e) throws IOException
      Specified by:
      write in interface Savable
      Overrides:
      write in class PhysicsCollisionObject
      Throws:
      IOException
    • read

      public void read(JmeImporter importer) throws IOException
      Specified by:
      read in interface Savable
      Overrides:
      read in class PhysicsCollisionObject
      Throws:
      IOException