My Project
|
a movie controller it will control the biped to follow a path defined in a movie file or record the biped' actions to a file. More...
#include <MovieCtrlers.h>
Public Types | |
enum | MovieMode { MOVIE_PLAYING, MOVIE_RECORDING, MOVIE_SUSPENDED } |
Public Member Functions | |
CMovieCtrler (CAIBase *pAI) | |
virtual void | SetTime (float fTime) |
set the internal timer. More... | |
virtual void | Resume () |
resume the controller. More... | |
virtual void | Suspend () |
suspend the controller, so it does not take effects on the next frame move. More... | |
void | RecordDialogKey (const string &sDialog, float fTime=-1.0f) |
Record a dialog key at the specified time please note that we will only record if it is not playing. More... | |
bool | RecordActionKey (const string &sActionName, float fTime=-1.0f) |
Record a action key at the specified time please note that we will only record if it is not playing. More... | |
bool | RecordActionKey (const ActionKey *actionKey, float fTime=-1.0f) |
void | RecordEffectKey (int effectID, const string &sTarget, float fTime=-1.0f) |
record the effect key, such as magic and missile effect More... | |
void | DisplayDialog (const string &sDialog) |
Display a dialog. | |
void | SetPosOffset (const Vector3 &vPos) |
Set the position offset. More... | |
const Vector3 & | GetPosOffset () |
get the offset position. More... | |
void | LoadFromFile (const std::string &filename) |
load a movie from file. More... | |
void | SetMode (MovieMode mode) |
set the mode for the current movie: there are 4 modes: Playing, Recording, Suspended. More... | |
void | SaveToFile (const std::string &filename) |
Save the key frames previously recorded to a specified file. More... | |
void | AddLoopingFrame (float fLoopToTime=0.f) |
It will add an additional key frame to the end, which point to the beginning of the animation. More... | |
virtual void | FrameMove (float fDeltaTime) |
a virtual function which is called every frame to process the controller. More... | |
![]() | |
CBipedController (CAIBase *pAI) | |
bool | IsActive () |
check whether the controller is active(not suspended). More... | |
float | GetTime () |
get the current movie time | |
IGameObject * | GetClosestBiped (IGameObject *pInput) |
get the biped in the perceived biped list, which is closet to the current biped. More... | |
IGameObject * | FindBiped (IGameObject *pInput, const std::string &searchString) |
Find a biped with a matching name. More... | |
CBipedObject * | GetBiped () |
get the biped, to which this biped controller is associated. More... | |
void | SetAI (CAIBase *pAI) |
set the AI object to which this object is associated. More... | |
Public Attributes | |
MovieMode | m_currentMode |
Additional Inherited Members | |
![]() | |
float | m_fTimeElapsed |
total time elapsed since the controller is active(not suspended). More... | |
a movie controller it will control the biped to follow a path defined in a movie file or record the biped' actions to a file.
It will also play animations at certain time. In short, it is a movie player and recorder. if it is still recording without saving the file when exits, we will save the movie to a default file. at "script/movie/movie_recorded.txt"
void CMovieCtrler::AddLoopingFrame | ( | float | fLoopToTime = 0.f | ) |
It will add an additional key frame to the end, which point to the beginning of the animation.
fLoopToTime | : to which time to loop to |
|
virtual |
a virtual function which is called every frame to process the controller.
fDeltaTime | the time elapsed since the last frame move is called. |
pInput | It holds any information that is perceived by a Active Biped object |
Reimplemented from ParaEngine::CBipedController.
const Vector3 & CMovieCtrler::GetPosOffset | ( | ) |
get the offset position.
void CMovieCtrler::LoadFromFile | ( | const std::string & | filename | ) |
load a movie from file.
The internal timer will be set to zero. call SetTime() to play from a specified time. Setting negative time will delay the movie from playing. Setting a value which is out side the range of the key frames will default to either the start or end of the key frame. the file format is given below: time [pos(x, y, z, facing)] [actionname]
time e.g. "0 pos(100,0,90, 3.14) j\r\n", "2 pos(100,0,90, 3.14)\r\n", "5 e_d\r\n" "5\r\nHello\r\r" Note: the time series should generally be in increasing order, except for the last frame the last frame can be a rewinding frame, which tells the movie to roll back to a previous frame for example:if t->{0,1,(2),3,(4),(2)}, then suppose the movie is played from 0, it will be a looping movie with time series as {0,1,2,3,4,2,3,4,2,3,4, ...}. To play consistent movie (2)(4)(2) in the time series should be identical. Note1: the position offset is set to the current location of the biped.
filename | a file name from which to load the file. It can also have a position offset value in the format:"filename pos(x,y,z)"| "filename". e.g. LoadFromFile("moive/movie1.txt pos(100,0,100)"); LoadFromFile("moive/movie1.txt"); If the position offset is not specified. it is assumed to be the current position of the associated biped.If specified, it is the current biped's position plus this offset value |
use the biped's current position as offset
clear the key frames.
load new ones from file
bool CMovieCtrler::RecordActionKey | ( | const string & | sActionName, |
float | fTime = -1.0f |
||
) |
Record a action key at the specified time please note that we will only record if it is not playing.
sActionName | the action name, it can be animation ID in string format, or it can be the name of the animation as defined in the animation table in AnimTable. |
fTime | the time at which to insert the key frame. If this value is -1.0f, it will be appended to the current recording time. |
void CMovieCtrler::RecordDialogKey | ( | const string & | sDialog, |
float | fTime = -1.0f |
||
) |
Record a dialog key at the specified time please note that we will only record if it is not playing.
sDialog | the dialog text to be added |
fTime | the time at which to insert the key frame. If this value is -1.0f, it will be appended to the current recording time. |
void CMovieCtrler::RecordEffectKey | ( | int | effectID, |
const string & | sTarget, | ||
float | fTime = -1.0f |
||
) |
record the effect key, such as magic and missile effect
fTime | the time at which to insert the key frame. If this value is -1.0f, it will be appended to the current recording time. |
|
virtual |
resume the controller.
Reimplemented from ParaEngine::CBipedController.
void CMovieCtrler::SaveToFile | ( | const std::string & | filename | ) |
Save the key frames previously recorded to a specified file.
filename | file path. |
void CMovieCtrler::SetMode | ( | MovieMode | mode | ) |
set the mode for the current movie: there are 4 modes: Playing, Recording, Suspended.
once playing or recording mode is set, the local movie time is set to 0 again. if we set to recording mode, the offset position will be set to the biped's current position when this function is called.
void CMovieCtrler::SetPosOffset | ( | const Vector3 & | vPos | ) |
Set the position offset.
all positions in the position key frames are relative to this location.
|
virtual |
set the internal timer.
This is useful when the behavior is relevant to the timer.
also update the time in the key frames.
move the character to the position.
use running as movement anyway. Because we can not easily find out the current walking style, so just assume the maximum speed.
Reimplemented from ParaEngine::CBipedController.
|
virtual |
suspend the controller, so it does not take effects on the next frame move.
Reimplemented from ParaEngine::CBipedController.