OMKMKMHeadToTaskExtension.cpp

Go to the documentation of this file.
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 "OMKMKMHeadToTaskExtension.h"
00022 #include "OMKAvatarVisualObject.h"
00023 #include "OMKParametersAccessor.inl"
00024 
00025 using namespace OMK ;
00026 using namespace OMK::Type ;
00027 
00028 REGISTER_EXTENSION_FACTORY( MKMHeadToTaskExtension, "HeadToTask" ) ;
00029 
00030 //-------------------------------------------------------------------------
00031 // constructor
00032 //-------------------------------------------------------------------------
00033 MKMHeadToTaskExtension::MKMHeadToTaskExtension( OMK::ExtensibleSimulatedObject* owner, const Name& id, bool registerExtension ) 
00034 : ExtensionT< MKMHumano >( owner, id, registerExtension ),
00035   _activate( "HeadingActivation", true ),
00036   _speed( "HeadingSpeed", 1.0f ),
00037   _target( "HeadingTarget", Transform() )
00038 {
00039   owner->addAttribute( _activate ) ;
00040   owner->addAttribute( _speed ) ;
00041   owner->addAttribute( _target ) ;
00042 }
00043 
00044 //-------------------------------------------------------------------------
00045 // destructor
00046 //-------------------------------------------------------------------------
00047 MKMHeadToTaskExtension::~MKMHeadToTaskExtension()
00048 {
00049 }
00050 bool MKMHeadToTaskExtension::loadExtensionParameters( const ConfigurationParameterDescriptor * node ) 
00051 {
00052   // Retrieve all the parameters
00053   _activate.loadParameters( node, "Activation" ) ;
00054   _speed.loadParameters( node, "Speed" ) ;
00055   _target.loadParameters( node, "Target" ) ;
00056 
00057   return true ;
00058 }
00059 void MKMHeadToTaskExtension::preComputeParameters()
00060 {
00061   // Waiting for the avatar master is intialised
00062   if( getOwner()->_avatarMaster.isInitialized() && _activate.get() )
00063   {
00064     Wm4::Vector3f target( _target.get().getTranslate() ) ;  
00065     mkm::CVector3 pos( getOwner()->_controlMesh.getPosition() ) ;
00066     float deltaX = -target.X() - pos[mkm::X] ;
00067     float deltaZ = target.Z() - pos[mkm::Y] ;
00068     getOwner()->_controlMesh.setOrientationToMoveToward( deltaX, deltaZ, _speed.get(), false ) ;
00069   }
00070 }

logo OpenMask

Documentation generated on Mon Jun 9 11:45:56 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007