#include <HBTRecorder.h>
Collaboration diagram for HBT::Recorder:
Public Member Functions | |
Recorder () | |
Default constructor. | |
Recorder (const std::string &fileName) | |
Constructor. | |
virtual | ~Recorder () |
Destructor. | |
void | open (const std::string &fileName) |
Open the file. | |
operator bool () const | |
Boolean operator. | |
Recorder & | write (const InitialisationSequence &intialisationSequence) |
The initialisation sequence writer. | |
Recorder & | write (unsigned int date, const PostureData &posture) |
The posture writer. | |
Static Public Attributes | |
static const std::string | HEADER |
The header. | |
Protected Member Functions | |
Writers | |
void | write (const std::string &txt) |
Write a string. | |
void | write (const bool &flag) |
Write a bool. | |
void | write (const Ogre::Vector3 &vect) |
Write an Ogre::Vector3. | |
void | write (const Ogre::Quaternion &quat) |
Write an Ogre::Quaternion. | |
template<typename T> | |
void | write (const std::vector< T > &tab) |
Write a vector of T. | |
template<typename T> | |
void | write (const T &val) |
Write a T. | |
Protected Attributes | |
bool | _initRecorded |
The flag to know if the initialisation sequence is written. | |
std::ofstream | _file |
The file where the data will be written. |
The format is a binary file in three parts :
// Do the initialisations of the avatar mesh master and of the human control initialisationSequence = avatarMeshMaster.init( treehMesh, meshFile, name, true, nodeAssociationFile, useShadows, axis, scale, 0.0f ) ; humanControl.init( treehMesh ) ; // Store the initialisation sequence Recorder recorder( fileName ) ; recorder.write( *initialisationSequence ) ; for( ;; ) { // And for each step update the posture and store it humanControl.update( frequency ); humanControl.getPosture().computeToRelative( avatarMeshMaster ); recorder.write( *avatarMeshMaster.computeAndGetPostureDatas() ) ; }
Definition at line 39 of file HBTRecorder.h.
Recorder::Recorder | ( | ) |
Default constructor.
Use open to define the name of the file where the data will be written.
Definition at line 18 of file HBTRecorder.cpp.
00019 : _initRecorded( false ), 00020 _file() 00021 { 00022 }
Recorder::Recorder | ( | const std::string & | fileName | ) |
Constructor.
[in] | fileName,the | file where the data will be written. |
Definition at line 10 of file HBTRecorder.cpp.
References open().
00011 : _initRecorded( false ), 00012 _file() 00013 { 00014 // Open directly the file 00015 open( fileName ) ; 00016 }
Recorder::~Recorder | ( | ) | [virtual] |
Destructor.
Closes the file.
Definition at line 24 of file HBTRecorder.cpp.
References _file.
00025 { 00026 _file.close() ; 00027 }
void Recorder::open | ( | const std::string & | fileName | ) |
Open the file.
[in] | fileName,the | file where the data will be written. |
Definition at line 29 of file HBTRecorder.cpp.
References _file.
Referenced by OMK::HumanoRecorder::loadParameters(), and Recorder().
00030 { 00031 _file.open( fileName.c_str(), std::ios::binary ) ; 00032 }
HBT::Recorder::operator bool | ( | ) | const [inline] |
Boolean operator.
Definition at line 59 of file HBTRecorder.h.
00059 { return _initRecorded ; }
Recorder & Recorder::write | ( | const InitialisationSequence & | intialisationSequence | ) |
The initialisation sequence writer.
[in] | intialisationSequence | The intialisation sequence. |
Definition at line 86 of file HBTRecorder.cpp.
References _file, _initRecorded, HBT::InitialisationSequence::boneNumber, HBT::InitialisationSequence::generalScale, HEADER, HBT::InitialisationSequence::humanName, HBT::InitialisationSequence::meshFile, HBT::InitialisationSequence::postureQuat, HBT::InitialisationSequence::rootPos, HBT::InitialisationSequence::rootQuat, and HBT::InitialisationSequence::useShadows.
Referenced by OMK::HumanoRecorder::computeParameters(), and write().
00087 { 00088 OBT_ASSERT( _file.is_open() && "The file is not opened" ) ; 00089 OBT_ASSERT( 0 == _file.tellp() && "The file is not empty" ) ; 00090 00091 write( HEADER + "0" ) ; // Tag, this is the header with the version number 00092 00093 write( intialisationSequence.meshFile ) ; 00094 write( intialisationSequence.humanName ) ; 00095 write( intialisationSequence.useShadows ) ; 00096 write( intialisationSequence.generalScale ) ; 00097 write( intialisationSequence.rootQuat ) ; 00098 write( intialisationSequence.rootPos ) ; 00099 write( intialisationSequence.boneNumber ) ; 00100 write( intialisationSequence.postureQuat ) ; 00101 00102 _initRecorded = true ; 00103 00104 return *this ; 00105 }
Recorder & Recorder::write | ( | unsigned int | date, | |
const PostureData & | posture | |||
) |
The posture writer.
[in] | date | The date. |
[in] | posture | The posture. |
Definition at line 107 of file HBTRecorder.cpp.
References _file, _initRecorded, HBT::PostureData::generalScale, HBT::PostureData::postureQuat, HBT::PostureData::quatModified, HBT::PostureData::rootPos, HBT::PostureData::rootQuat, and write().
00108 { 00109 OBT_ASSERT( _file.is_open() && "The file is not opened" ) ; 00110 OBT_ASSERT( _initRecorded && "You must write InitialisationSequence before writeing the posture data" ) ; 00111 write( date ) ; 00112 write( posture.rootPos ) ; 00113 write( posture.rootQuat ) ; 00114 write( posture.generalScale ) ; 00115 write( posture.postureQuat ) ; 00116 write( posture.quatModified ) ; 00117 return *this ; 00118 }
void Recorder::write | ( | const std::string & | txt | ) | [protected] |
Write a string.
Definition at line 34 of file HBTRecorder.cpp.
References _file.
00035 { 00036 // size + c string (including the '\0') 00037 size_t size = txt.size() + 1 ; 00038 _file.write( (char*)&size, sizeof( size_t )) ; 00039 _file.write( (char*)txt.c_str(), size ) ; 00040 }
void Recorder::write | ( | const bool & | flag | ) | [protected] |
Write a bool.
Definition at line 42 of file HBTRecorder.cpp.
References _file.
00043 { 00044 // true => '1', false => '0' 00045 char tmp = flag ? '1' : '0' ; 00046 _file.write( &tmp, 1 ) ; 00047 }
void Recorder::write | ( | const Ogre::Vector3 & | vect | ) | [protected] |
Write an Ogre::Vector3.
Definition at line 56 of file HBTRecorder.cpp.
References _file.
00057 { 00058 // the 3 binary values 00059 _file.write( (char*)&vect.x, sizeof( Ogre::Real ) ) ; 00060 _file.write( (char*)&vect.y, sizeof( Ogre::Real ) ) ; 00061 _file.write( (char*)&vect.z, sizeof( Ogre::Real ) ) ; 00062 }
void Recorder::write | ( | const Ogre::Quaternion & | quat | ) | [protected] |
Write an Ogre::Quaternion.
Definition at line 64 of file HBTRecorder.cpp.
References _file.
00065 { 00066 // the 4 binary values 00067 _file.write( (char*)&quat.w, sizeof( Ogre::Real ) ) ; 00068 _file.write( (char*)&quat.x, sizeof( Ogre::Real ) ) ; 00069 _file.write( (char*)&quat.y, sizeof( Ogre::Real ) ) ; 00070 _file.write( (char*)&quat.z, sizeof( Ogre::Real ) ) ; 00071 }
void Recorder::write | ( | const std::vector< T > & | tab | ) | [protected] |
Write a vector of T.
Definition at line 74 of file HBTRecorder.cpp.
References _file, and write().
00075 { 00076 // size of the vector + the N values 00077 size_t size = tab.size() ; 00078 _file.write( (char*)&size, sizeof( size_t ) ) ; 00079 for( size_t i = 0 ; i < size ; i++ ) 00080 { 00081 write( tab[ i ] ) ; 00082 } 00083 }
void Recorder::write | ( | const T & | val | ) | [protected] |
Write a T.
Definition at line 50 of file HBTRecorder.cpp.
References _file.
00051 { 00052 // the binary value 00053 _file.write( (char*)&val, sizeof( T ) ) ; 00054 }
const std::string Recorder::HEADER [static] |
The header.
Definition at line 74 of file HBTRecorder.h.
Referenced by HBT::Player::read(), and write().
bool HBT::Recorder::_initRecorded [protected] |
The flag to know if the initialisation sequence is written.
Definition at line 77 of file HBTRecorder.h.
Referenced by write().
std::ofstream HBT::Recorder::_file [protected] |
The file where the data will be written.
Definition at line 79 of file HBTRecorder.h.
Referenced by open(), write(), and ~Recorder().
Documentation generated on Mon Jun 9 11:46:00 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |