OpenMW
|
#include <btKinematicCharacterController.h>
Public Types | |
enum | UpAxis { X_AXIS = 0, Y_AXIS = 1, Z_AXIS = 2 } |
Public Member Functions | |
btKinematicCharacterController (btPairCachingGhostObject *externalGhostObject, btPairCachingGhostObject *internalGhostObject, btScalar stepHeight, btScalar constantScale=btScalar(1.0), btScalar gravity=btScalar(9.8), btScalar fallVelocity=btScalar(55.0), btScalar jumpVelocity=btScalar(9.8), btScalar recoveringFactor=btScalar(0.2)) | |
~btKinematicCharacterController () | |
void | setVerticalVelocity (float z) |
virtual void | updateAction (btCollisionWorld *collisionWorld, btScalar deltaTime) |
btActionInterface interface | |
void | debugDraw (btIDebugDraw *debugDrawer) |
btActionInterface interface | |
void | setUpAxis (UpAxis axis) |
virtual void | setWalkDirection (const btVector3 &walkDirection) |
virtual void | setVelocityForTimeInterval (const btVector3 &velocity, btScalar timeInterval) |
void | reset () |
void | warp (const btVector3 &origin) |
void | preStep (btCollisionWorld *collisionWorld) |
void | playerStep (btCollisionWorld *collisionWorld, btScalar dt) |
void | setFallSpeed (btScalar fallSpeed) |
void | setJumpSpeed (btScalar jumpSpeed) |
void | setMaxJumpHeight (btScalar maxJumpHeight) |
bool | canJump () const |
void | jump () |
void | setGravity (btScalar gravity) |
btScalar | getGravity () const |
void | setMaxSlope (btScalar slopeRadians) |
btScalar | getMaxSlope () const |
void | setUseGhostSweepTest (bool useGhostObjectSweepTest) |
bool | onGround () const |
Public Attributes | |
bool | mCollision |
Private Member Functions | |
bool | recoverFromPenetration (btCollisionWorld *collisionWorld) |
btVector3 | stepUp (btCollisionWorld *collisionWorld, const btVector3 ¤tPosition, btScalar ¤tStepOffset) |
btVector3 | stepForwardAndStrafe (btCollisionWorld *collisionWorld, const btVector3 ¤tPosition, const btVector3 &walkMove) |
btScalar | addFallOffset (bool wasJumping, btScalar currentStepOffset, btScalar dt) |
Handle the gravity. | |
btVector3 | stepDown (btCollisionWorld *collisionWorld, const btVector3 ¤tPosition, btScalar currentStepOffset) |
Static Private Member Functions | |
static btVector3 * | getUpAxisDirections () |
Private Attributes | |
btPairCachingGhostObject * | externalGhostObject |
btPairCachingGhostObject * | internalGhostObject |
btScalar | m_verticalVelocity |
btScalar | m_verticalOffset |
btScalar | m_fallSpeed |
btScalar | m_jumpSpeed |
btScalar | m_maxJumpHeight |
btScalar | m_maxSlopeRadians |
btScalar | m_maxSlopeCosine |
btScalar | m_gravity |
btScalar | m_recoveringFactor |
btScalar | m_stepHeight |
btVector3 | m_walkDirection |
this is the desired walk direction, set by the user | |
btManifoldArray | m_manifoldArray |
keep track of the contact manifolds | |
bool | m_wasJumping |
Gravity attributes. | |
bool | m_useGhostObjectSweepTest |
bool | m_useWalkDirection |
btScalar | m_velocityTimeInterval |
UpAxis | m_upAxis |
btKinematicCharacterController is an object that supports a sliding motion in a world. It uses a ghost object and convex sweep test to test for upcoming collisions. This is combined with discrete collision detection to recover from penetrations. Interaction between btKinematicCharacterController and dynamic rigid bodies needs to be explicity implemented by the user.
btKinematicCharacterController::btKinematicCharacterController | ( | btPairCachingGhostObject * | externalGhostObject, |
btPairCachingGhostObject * | internalGhostObject, | ||
btScalar | stepHeight, | ||
btScalar | constantScale = btScalar( 1.0 ) , |
||
btScalar | gravity = btScalar( 9.8 ) , |
||
btScalar | fallVelocity = btScalar( 55.0 ) , |
||
btScalar | jumpVelocity = btScalar( 9.8 ) , |
||
btScalar | recoveringFactor = btScalar( 0.2 ) |
||
) |
externalGhostObject is used for querying the collisions for sliding along the wall, and internalGhostObject is used for querying the collisions for recovering from large penetrations. These parameters can point on the same object. Using a smaller internalGhostObject can help for removing some flickering but create some stopping artefacts when sliding along stairs or small walls. Don't forget to scale gravity and fallSpeed if you scale the world.
btScalar btKinematicCharacterController::addFallOffset | ( | bool | wasJumping, |
btScalar | currentStepOffset, | ||
btScalar | dt | ||
) | [private] |
Handle the gravity.
bool btKinematicCharacterController::canJump | ( | ) | const |
void btKinematicCharacterController::debugDraw | ( | btIDebugDraw * | debugDrawer | ) |
btActionInterface interface
btScalar btKinematicCharacterController::getGravity | ( | ) | const |
btScalar btKinematicCharacterController::getMaxSlope | ( | ) | const |
btVector3 * btKinematicCharacterController::getUpAxisDirections | ( | ) | [static, private] |
void btKinematicCharacterController::jump | ( | ) |
bool btKinematicCharacterController::onGround | ( | ) | const |
void btKinematicCharacterController::playerStep | ( | btCollisionWorld * | collisionWorld, |
btScalar | dt | ||
) |
void btKinematicCharacterController::preStep | ( | btCollisionWorld * | collisionWorld | ) |
bool btKinematicCharacterController::recoverFromPenetration | ( | btCollisionWorld * | collisionWorld | ) | [private] |
void btKinematicCharacterController::setFallSpeed | ( | btScalar | fallSpeed | ) |
void btKinematicCharacterController::setGravity | ( | btScalar | gravity | ) |
void btKinematicCharacterController::setJumpSpeed | ( | btScalar | jumpSpeed | ) |
void btKinematicCharacterController::setMaxJumpHeight | ( | btScalar | maxJumpHeight | ) |
void btKinematicCharacterController::setMaxSlope | ( | btScalar | slopeRadians | ) |
The max slope determines the maximum angle that the controller can walk up. The slope angle is measured in radians.
void btKinematicCharacterController::setUpAxis | ( | UpAxis | axis | ) | [inline] |
void btKinematicCharacterController::setUseGhostSweepTest | ( | bool | useGhostObjectSweepTest | ) | [inline] |
void btKinematicCharacterController::setVelocityForTimeInterval | ( | const btVector3 & | velocity, |
btScalar | timeInterval | ||
) | [virtual] |
Caller provides a velocity with which the character should move for the given time period. After the time period, velocity is reset to zero. This call will reset any walk direction set by setWalkDirection(). Negative time intervals will result in no motion.
void btKinematicCharacterController::setVerticalVelocity | ( | float | z | ) |
void btKinematicCharacterController::setWalkDirection | ( | const btVector3 & | walkDirection | ) | [virtual] |
This should probably be called setPositionIncrementPerSimulatorStep. This is neither a direction nor a velocity, but the amount to increment the position each simulation iteration, regardless of dt. This call will reset any velocity set by setVelocityForTimeInterval().
btVector3 btKinematicCharacterController::stepDown | ( | btCollisionWorld * | collisionWorld, |
const btVector3 & | currentPosition, | ||
btScalar | currentStepOffset | ||
) | [private] |
btVector3 btKinematicCharacterController::stepForwardAndStrafe | ( | btCollisionWorld * | collisionWorld, |
const btVector3 & | currentPosition, | ||
const btVector3 & | walkMove | ||
) | [private] |
btVector3 btKinematicCharacterController::stepUp | ( | btCollisionWorld * | collisionWorld, |
const btVector3 & | currentPosition, | ||
btScalar & | currentStepOffset | ||
) | [private] |
virtual void btKinematicCharacterController::updateAction | ( | btCollisionWorld * | collisionWorld, |
btScalar | deltaTime | ||
) | [inline, virtual] |
btActionInterface interface
void btKinematicCharacterController::warp | ( | const btVector3 & | origin | ) |
btPairCachingGhostObject* btKinematicCharacterController::externalGhostObject [private] |
btPairCachingGhostObject* btKinematicCharacterController::internalGhostObject [private] |
btScalar btKinematicCharacterController::m_fallSpeed [private] |
btScalar btKinematicCharacterController::m_gravity [private] |
btScalar btKinematicCharacterController::m_jumpSpeed [private] |
btManifoldArray btKinematicCharacterController::m_manifoldArray [private] |
keep track of the contact manifolds
btScalar btKinematicCharacterController::m_maxJumpHeight [private] |
btScalar btKinematicCharacterController::m_maxSlopeCosine [private] |
btScalar btKinematicCharacterController::m_maxSlopeRadians [private] |
btScalar btKinematicCharacterController::m_recoveringFactor [private] |
btScalar btKinematicCharacterController::m_stepHeight [private] |
bool btKinematicCharacterController::m_useGhostObjectSweepTest [private] |
bool btKinematicCharacterController::m_useWalkDirection [private] |
btScalar btKinematicCharacterController::m_velocityTimeInterval [private] |
btScalar btKinematicCharacterController::m_verticalOffset [private] |
btScalar btKinematicCharacterController::m_verticalVelocity [private] |
btVector3 btKinematicCharacterController::m_walkDirection [private] |
this is the desired walk direction, set by the user
bool btKinematicCharacterController::m_wasJumping [private] |
Gravity attributes.