Character Class Reference

Character controller. More...

Inheritance diagram for Character:

Inheritance graph
[legend]
Collaboration diagram for Character:

Collaboration graph
[legend]

List of all members.

Public Types

enum  Direction {
  Left = 1, Right = 2, Forward = 4, Backward = 8,
  Jump = 16, DirectionCount
}

Public Member Functions

 Character (Object *object, World *world)
 ctor
virtual ~Character ()
 dtor
bool onGround () const
virtual void update (btScalar dt)
 Update the character position.
virtual void move (int direction)
 Set movement direction (OR combination of movement directions).
void setFallSpeed (btScalar fallSpeed)
 Set falling speed.
void setJumpSpeed (btScalar jumpSpeed)
 Set jump speed.
void setMaxJumpHeight (btScalar maxJumpHeight)
 Set maximum jump height.
bool canJump () const
void jump ()
 jump

Protected Member Functions

bool fall (const btCollisionWorld *w, btScalar dt, const btVector3 &down)
bool recoverFromPenetration (const btCollisionWorld *collisionWorld)
void stepUp (const btCollisionWorld *collisionWorld)
void updateTargetPositionBasedOnCollision (const btVector3 &hit_normal, btScalar tangentMag=btScalar(0.0), btScalar normalMag=btScalar(1.0))
void stepForwardAndStrafe (const btCollisionWorld *collisionWorld, const btVector3 &walkMove)
void stepDown (const btCollisionWorld *collisionWorld, btScalar dt)

Protected Attributes

Worldm_world
Objectm_object
bool m_onGround
int m_directions
btScalar m_halfHeight
btConvexShape * m_shape
btCollisionObject * m_collisionObject
btOverlappingPairCache * m_pairCache
btCollisionDispatcher * m_dispatcher
btScalar m_fallSpeed
btScalar m_jumpSpeed
btScalar m_maxJumpHeight
btScalar m_turnAngle
btScalar m_walkVelocity
btScalar m_height
btScalar m_width
btScalar m_stepHeight
btVector3 m_currentPosition
btVector3 m_targetPosition
bool m_touchingContact
btVector3 m_touchingNormal


Detailed Description

Character controller.

Physics engine are great for collision, rigid body dynamics, soft body dynamics but they seldom provide a built in way of making characters move realistically, and Bullet is not exception to that rule.

The Character class allows an Object to be moved in the World simply and to collide with other objects in its path. It can be tuned to prevent the character from walking up to steep slopes, to change the falling speed, the walking speed, ...


Constructor & Destructor Documentation

Character::Character ( Object object,
World world 
)

ctor

Parameters:
object Game object to manage
world World in which the object evolves
Note:
the object must be using a convex shape (Mesh and SharedMesh are the only POTENTIALLY concave shapes) or the character controller will fall back on a box shape.

References Object::getBody(), World::getDynamicsWorld(), and World::removeObject().


Member Function Documentation

bool Character::onGround (  )  const

Returns:
whether the character is resting on the ground

Referenced by canJump().

void Character::move ( int  direction  )  [virtual]

Set movement direction (OR combination of movement directions).

Note:
This function does NOT move the character, it simply schedules movements which will be processed in the next update() call.

bool Character::canJump (  )  const

Returns:
whether the character can jump

References onGround().

Referenced by jump().


The documentation for this class was generated from the following files:

Generated on Sat Jul 26 13:58:39 2008 for TFK:GE by  doxygen 1.5.5