00001 #include "OMKHumanoRecorder.h" 00002 #include "OMKParametersAccessor.inl" 00003 #include "OMKTransform.h" 00004 #include "OMKVisBase.h" 00005 #include "OMKAddVisualObjectPrm.h" 00006 #include "OMKConversion.h" 00007 00008 using namespace OMK ; 00009 using namespace OMK::Type ; 00010 using namespace OMK::Vis ; 00011 00012 00013 //============================================================================= 00014 00015 //----------------------------------------------------------------------------- 00016 REGISTER_OBJECT_FACTORY( OMK::HumanoRecorder, "HumanoRecorder" ) ; 00017 //----------------------------------------------------------------------------- 00018 00019 HumanoRecorder::HumanoRecorder( Controller& ctrl, const ObjectDescriptor& objectDescriptor ) 00020 : ExtensibleSimulatedObject( ctrl, objectDescriptor ), 00021 _posture( "Posture", HBT::PostureData() ), 00022 _record( "Record", false ), 00023 _humanoToRecord(), 00024 _file() 00025 { 00026 // The attribute to get the posture of the avatar 00027 addAttribute( _posture, false ) ; 00028 addAttribute( _record ) ; 00029 } 00030 //----------------------------------------------------------------------------- 00031 HumanoRecorder::~HumanoRecorder() 00032 { 00033 } 00034 //----------------------------------------------------------------------------- 00035 bool HumanoRecorder::processInitialisationSequence( InitialisationSequenceEvent* e ) 00036 { 00037 _file.write( e->value.getValue() ) ; 00038 return false ; 00039 } 00040 //----------------------------------------------------------------------------- 00041 bool HumanoRecorder::loadParameters( const ConfigurationParameterDescriptor * node ) 00042 { 00043 bool ok = true ; 00044 // Get the humano to record 00045 ok = ok && ParametersAccessor::get( node, "Record", _humanoToRecord, this ) ; 00046 00047 // get the file to output data 00048 std::string file( _humanoToRecord.getString() + ".rec" ) ; 00049 if( !ParametersAccessor::get( node, "File", file ) ) 00050 { 00051 OMMESSAGE( "No file name given, use \"" << file << "\"" ) ; 00052 } 00053 _file.open( file.c_str() ) ; 00054 00055 ok = ok && _posture.connectTo( _humanoToRecord, "Posture" ) ; 00056 new ValuedEventListenerCallBack< HumanoRecorder, InitialisationSequenceType >( 00057 *this, 00058 &HumanoRecorder::processInitialisationSequence, 00059 EventId::INITIALISATION_SEQUENCE ) ; 00060 ok = ok && registerForSignalBy( EventId::INITIALISATION_SEQUENCE, _humanoToRecord ) ; 00061 return ok ; 00062 } 00063 00064 //----------------------------------------------------------------------------- 00065 void HumanoRecorder::computeParameters() 00066 { 00067 if( _record && _file ) 00068 { 00069 unsigned int date = getController().getSimulatedDate() ; 00070 _file.write( date, _posture.get() ) ; 00071 } 00072 } 00073
Documentation generated on Mon Jun 9 11:45:56 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |