My Project
|
managing biped state More...
#include <BipedStateManager.h>
Public Types | |
enum | BipedState { STATE_MOVING = 0, STATE_WALK_FORWORD, STATE_RUN_FORWORD, STATE_WALK_LEFT, STATE_WALK_RIGHT, STATE_WALK_BACKWORD, STATE_WALK_POINT, STATE_SWIM_FORWORD, STATE_SWIM_LEFT, STATE_SWIM_RIGHT, STATE_SWIM_BACKWORD, STATE_FLY_DOWNWARD, STATE_STANDING = 100, STATE_IN_WATER, STATE_SWIM, STATE_JUMP_IN_AIR, STATE_JUMP_START, STATE_JUMP_END, STATE_STAND, STATE_TURNING, STATE_ATTACK, STATE_ATTACK1, STATE_ATTACK2, STATE_MOUNT, STATE_DANCE } |
enum | ActionSymbols { S_STANDING = 0, S_IN_WATER, S_ON_FEET, S_ON_WATER_SURFACE, POP_ACTION, S_STAND, S_WALK_FORWORD, S_RUN_FORWORD, S_WALK_LEFT, S_WALK_RIGHT, S_WALK_POINT, S_TURNING, S_WALK_BACKWORD, S_SWIM_FORWORD, S_SWIM_LEFT, S_SWIM_RIGHT, S_SWIM_BACKWORD, S_JUMP_START, S_JUMP_IN_AIR, S_JUMP_END, S_MOUNT, S_FALLDOWN, S_ATTACK, S_ATTACK1, S_ATTACK2, S_DANCE, S_ACTIONKEY, S_FLY_DOWNWARD, S_NONE } |
state object that saves in memory More... | |
Public Member Functions | |
CBipedStateManager (CBipedObject *pBiped) | |
bool | IsMounted () |
whether the object is mounted on another object. More... | |
void | SetMounted (bool bIsMounted) |
set mount state | |
bool | IsRecording () |
whether the state is being recorded to a movie controller. More... | |
void | SetRecording (bool bIsRecording=true) |
Set the recording state. | |
bool | WalkingOrRunning () |
return true if character uses walk as the default moving animation.otherwise it uses running. More... | |
void | SetWalkOrRun (bool bWalk) |
Set default moving style. More... | |
bool | GetStateAnimName (BipedState s, char *sName, int nNameSize=8) |
get the default animation name for a given state. More... | |
BipedState | GetLastAnimState () |
last animation state, which is the animation played in the last frame. More... | |
int | FindStateInMemory (BipedState s) |
Find a specified state in memory. More... | |
BipedState | GetLastState () |
get the last biped state | |
BipedState | GetFirstState () |
get the last biped state | |
bool | HasMovingState () |
whether the memory contains at least one moving state. More... | |
bool | IsSwimming () |
whether the biped is swimming | |
bool | IsFlying () |
whether the biped is flying | |
CBipedObject * | GetBiped () |
void | SetBiped (CBipedObject *pBiped) |
BipedState | AddAction (ActionSymbols nAct, const void *pData=NULL) |
read an action symbol, and let the manager determine which states it should go to. More... | |
void | SetAngleDelta (float fAngleDelta) |
set user data: angle delta | |
float | GetAngleDelta () |
Get user data: angle delta. | |
void | SetJumpupSpeed (float fSpeed) |
set user data: jump up speed | |
float | GetJumpupSpeed () |
Get user data: jump up speed. | |
void | SetPos (const DVector3 &v) |
set user data: position | |
const DVector3 & | GetPos () |
Get user data: position. | |
void | Update (float fTimeDelta) |
update the associated biped according to the memory or state of the manager. More... | |
Static Public Member Functions | |
static bool | IsStandingState (BipedState s) |
static bool | IsMovingState (BipedState s) |
Protected Member Functions | |
void | RemoveState (BipedState s) |
remove all occurrence of a given state | |
void | CheckMemory () |
make sure that the memory has space left for one more state | |
void | ReplaceState (BipedState s) |
replace the current state with the one in the input | |
void | PushState (BipedState s) |
add a new state to state memory | |
void | PushUniqueState (BipedState s) |
all occurrence of the same state will be removed from the memory before this state is pushed to the memory | |
void | PrependState (BipedState s) |
prepend a new state to state memory | |
void | PrependUniqueState (BipedState s) |
all occurrence of the same state will be removed from the memory before this state is prepended to the memory | |
void | SetUniqueState (BipedState s) |
ensure that state s is unique in the memory. More... | |
Friends | |
class | CAutoCamera |
managing biped state
state object that saves in memory
CBipedStateManager::BipedState CBipedStateManager::AddAction | ( | ActionSymbols | nAct, |
const void * | pData = NULL |
||
) |
read an action symbol, and let the manager determine which states it should go to.
this function will not perform any concrete actions on the biped objects. Call Update() method to perform these actions on the associated biped after adding series of actions to the state manager. The recommended order of calling is StateManager::Update()->Environment Simulator->IO:{StateManager::AddAction}
nAct | the action |
data | the data specifying more details about the action. This value default to NULL if nAct is S_ACTIONKEY, then pData is const ActionKey* if nAct is S_WALK_POINT, then pData is NULL or 1, specifying whether to use angle. |
some looking back states in memory
TODO: one may need to prevent the biped from changing speed direction, when it is in air. this can be done by by examining the memory for STATE_JUMP_IN_AIR and STATE_IN_WATER.
TODO: you can prevent jumping multiple times on land by examining the memory for STATE_JUMP_IN_AIR. currently, it is allowed for debugging purposes only.
TODO: you can prevent jumping multiple times on land by examining the memory for STATE_JUMP_IN_AIR. currently, it is allowed for debugging purposes only.
perform the action in the action key. this is usually from a superimposed user action or the movie replaying.
int CBipedStateManager::FindStateInMemory | ( | BipedState | s | ) |
Find a specified state in memory.
s | the state to be found. |
CBipedStateManager::BipedState CBipedStateManager::GetLastAnimState | ( | ) |
last animation state, which is the animation played in the last frame.
this is used for AI or other modules to check for the current biped animations.
bool CBipedStateManager::GetStateAnimName | ( | CBipedStateManager::BipedState | s, |
char * | sName, | ||
int | nNameSize = 8 |
||
) |
get the default animation name for a given state.
s | the biped state |
sName | [out] a buffer to get the name |
nNameSize | size of the name in bytes, the default value is 8. |
bool CBipedStateManager::HasMovingState | ( | ) |
whether the memory contains at least one moving state.
bool CBipedStateManager::IsMounted | ( | ) |
whether the object is mounted on another object.
bool CBipedStateManager::IsRecording | ( | ) |
whether the state is being recorded to a movie controller.
|
protected |
ensure that state s is unique in the memory.
If there is one than one such state, it will be deleted.
void CBipedStateManager::SetWalkOrRun | ( | bool | bWalk | ) |
Set default moving style.
bWalk | true if character uses walk as the default moving animation.otherwise it uses running. |
void CBipedStateManager::Update | ( | float | fTimeDelta | ) |
update the associated biped according to the memory or state of the manager.
this function is automatically by each active biped during each frame move. it may sometimes change the memory of state manager. But in most cases, it just carries out actions according to the current state.
fTimeDelta | the time elapsed since the last time this function is called. Units in seconds. |
some looking back states in memory
the new biped speed direction and model direction is mostly set according to the head facing. the old head facing is maintained the same.
way point
handling object speed according to moving states, such as running, swimming, etc.
the biped is at standing state, such as attacking, idling, dancing,etc.
the head turns first, then the body follows up.
set biped's model facing, head facing and speed facing.
if the biped is mounted, play the mounted animation as the default standing animation.
play animation
bool CBipedStateManager::WalkingOrRunning | ( | ) |
return true if character uses walk as the default moving animation.otherwise it uses running.