00001 /************************************************************************/ 00002 /* This file is part of openMask(c) INRIA, CNRS, Universite de Rennes 1 */ 00003 /* 1993-2002, thereinafter the Software */ 00004 /* */ 00005 /* The Software has been developped within the Siames Project. */ 00006 /* INRIA, the University of Rennes 1 and CNRS jointly hold intellectual */ 00007 /* property rights */ 00008 /* */ 00009 /* The Software has been registered with the Agence pour la Protection */ 00010 /* des Programmes (APP) under registration number */ 00011 /* IDDN.FR.001.510008.00.S.P.2001.000.41200 */ 00012 /* */ 00013 /* This file may be distributed under the terms of the Q Public License */ 00014 /* version 1.0 as defined by Trolltech AS of Norway and appearing in */ 00015 /* the file LICENSE.QPL included in the packaging of this file. */ 00016 /* */ 00017 /* Licensees holding valid specific licenses issued by INRIA, CNRS or */ 00018 /* Universite Rennes 1 for the software may use this file in */ 00019 /* acordance with that specific license */ 00020 /************************************************************************/ 00021 #include "OMKAvatarVisualObject.h" 00022 #include "HBTAvatarMesh.h" 00023 #include "HBTDataTypes.h" 00024 #include "OMKOgreVis.h" 00025 #include "OMKValuedEventListenerCallBack.h" 00026 #include "OMKValuedEvent.h" 00027 #include "OMKParametersAccessor.inl" 00028 00029 using namespace OMK ; 00030 using namespace OMK::Type ; 00031 using namespace OMK::Vis ; 00032 00033 //----------------------------------------------------------------------------- 00034 REGISTER_VISUAL_OBJECT_FACTORY( AvatarVisualObject, "AvatarVisualObject" ) ; 00035 //----------------------------------------------------------------------------- 00036 00037 AvatarVisualObject::AvatarVisualObject( Vis::VisBase& vis, const Name& id, 00038 const ConfigurationParameterDescriptor* node ) 00039 : Vis::OgreObject( vis, id, node ), 00040 _avatarMesh( 0 ), 00041 _initialised( false ) 00042 { 00043 // The event listener to initialise the avatar 00044 _initEventListener = new InitialisationSequenceListener( 00045 vis, this, 00046 &AvatarVisualObject::processInit, 00047 EventId::INITIALISATION_SEQUENCE ) ; 00048 vis.registerForSignalBy( EventId::INITIALISATION_SEQUENCE, getId() ) ; 00049 } 00050 00051 //----------------------------------------------------------------------------- 00052 00053 AvatarVisualObject::~AvatarVisualObject() 00054 { 00055 delete _initEventListener ; 00056 } 00057 //----------------------------------------------------------------------------- 00058 00059 void AvatarVisualObject::visualise() 00060 { 00061 } 00062 //----------------------------------------------------------------------------- 00063 00064 void AvatarVisualObject::updatePosture( const OMK::Type::PostureDataType& value ) 00065 { 00066 if( _initialised ) 00067 { // Must be initialised 00068 _avatarMesh->update( value.getValue() ) ; 00069 } 00070 } 00071 //----------------------------------------------------------------------------- 00072 00073 bool AvatarVisualObject::processInit( InitialisationSequenceEvent* e ) 00074 { 00075 // is it the good event (good name and uninitialised)? 00076 bool ok = ( getId().getString() == e->value.getValue().humanName ) && !_initialised ; 00077 if( ok ) 00078 { 00079 // Creates the avatar and initialises it 00080 _avatarMesh = HBT::AvatarMesh::create() ; 00081 _avatarMesh->init( _ogreVis.touchRoot().getSceneManager( "sceneManager" ), &e->value.getValue() ) ; 00082 _ogreVis.touchRoot().getSceneManager( "sceneManager" )->getRootSceneNode()->removeChild( 00083 _avatarMesh->getOgreSceneNode() ); 00084 _sceneNode.addChild( _avatarMesh->getOgreSceneNode() ); 00085 00086 _avatarMesh->show() ; 00087 _initialised = true ; 00088 } 00089 return ok ; 00090 } 00091 //-----------------------------------------------------------------------------
Documentation generated on Mon Jun 9 11:45:55 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |