#include <OMKMKMMoveToTaskExtension.h>
Inheritance diagram for OMK::MKMMoveToTaskExtension:
Protected Member Functions | |
virtual bool | loadExtensionParameters (const ConfigurationParameterDescriptor *node) |
Configuration parameters loader of Extension. | |
virtual void | preComputeParameters () |
method. | |
Protected Attributes | |
AttributeT< bool > | _activate |
AttributeT< bool > | _isWaiting |
AttributeT< float > | _threshold |
AttributeT< float > | _speed |
AttributeT< Type::Transform > | _target |
mkm::CHumanTask_Motion | _moveTask |
mkm::CHumanTask_Motion | _waitTask |
bool | _initDone |
std::string | _moveMotion |
std::string | _waitMotion |
float | _transitionDuration |
float | _weight |
float | _rank |
Private Member Functions | |
DECLARE_EXTENSION_FACTORY (MKMMoveToTaskExtension) |
Definition at line 32 of file OMKMKMMoveToTaskExtension.h.
OMK::MKMMoveToTaskExtension::DECLARE_EXTENSION_FACTORY | ( | MKMMoveToTaskExtension | ) | [private] |
bool MKMMoveToTaskExtension::loadExtensionParameters | ( | const ConfigurationParameterDescriptor * | node | ) | [protected, virtual] |
Configuration parameters loader of Extension.
[in] | node | the root node of the configuration parameter, null if no node defined for the extension. |
Reimplemented from OMK::Extension.
Definition at line 73 of file OMKMKMMoveToTaskExtension.cpp.
References _activate, _isWaiting, _moveMotion, _rank, _speed, _target, _threshold, _transitionDuration, _waitMotion, _weight, OMK::ParametersAccessor::get(), OMK::ExtensionT< OMK::MKMHumano >::getOwner(), and OMK::IAttributeBaseT< PrmType >::loadParameters().
00074 { 00075 // Retrieve all the parameters 00076 bool ok = true ; 00077 ok = ok && ParametersAccessor::get( node, "MoveMotion", _moveMotion, getOwner() ) ; 00078 ok = ok && ParametersAccessor::get( node, "WaitMotion", _waitMotion, getOwner() ) ; 00079 ParametersAccessor::get( node, "TansitionDuration", _transitionDuration ) ; 00080 ParametersAccessor::get( node, "PriorityWeight", _weight ) ; 00081 ParametersAccessor::get( node, "PriorityRank", _rank ) ; 00082 _threshold.loadParameters( node, "Threshold" ) ; 00083 _target.loadParameters( node, "Target" ) ; 00084 _activate.loadParameters( node, "Activation" ) ; 00085 _isWaiting.loadParameters( node, "Reached" ) ; 00086 _speed.loadParameters( node, "Speed" ) ; 00087 00088 return ok ; 00089 }
void MKMMoveToTaskExtension::preComputeParameters | ( | ) | [protected, virtual] |
method.
This method is called by the extensible simulated object at each compute step. Its call takes place in the compute method just after the inputs were retrieved by the computeInputs method and before the output parameters will be computed by the computeParameters
Reimplemented from OMK::Extension.
Definition at line 90 of file OMKMKMMoveToTaskExtension.cpp.
References _activate, OMK::MKMHumano::_controlMesh, _initDone, _isWaiting, _moveMotion, _moveTask, _rank, _speed, _target, _threshold, _transitionDuration, _waitMotion, _waitTask, _weight, OMK::IAttributeT< PrmType, ModelType, AccessorType >::get(), OMK::ExtensionT< OMK::MKMHumano >::getOwner(), OMK::IAttribute::isUpdated(), and OMK::IAttributeT< PrmType, ModelType, AccessorType >::set().
00091 { 00092 // Waiting for the avatar master is intialised 00093 if( !_initDone && getOwner()->_avatarMaster.isInitialized() ) 00094 { 00095 // Defines the motion task and starts it 00096 _initDone = true ; 00097 // Wait motion 00098 _waitTask.init( getOwner()->_controlMesh, _waitMotion ) ; 00099 _waitTask.setStartingDuration( _transitionDuration ) ; 00100 _waitTask.setStoppingDuration( _transitionDuration ) ; 00101 _waitTask.setPriorityWeight( _weight ) ; 00102 _waitTask.setPriorityRank( _rank ) ; 00103 // Move motion 00104 _moveTask.init( getOwner()->_controlMesh, _moveMotion ) ; 00105 _moveTask.setStartingDuration( _transitionDuration ) ; 00106 _moveTask.setStoppingDuration( _transitionDuration ) ; 00107 _moveTask.setPriorityWeight( _weight ) ; 00108 _moveTask.setPriorityRank( _rank ) ; 00109 // start waiting 00110 _waitTask.start() ; 00111 } 00112 if( _initDone ) 00113 { 00114 if( _activate.isUpdated() ) 00115 { 00116 if( !_activate.get() ) 00117 { 00118 _waitTask.stop() ; 00119 _moveTask.stop() ; 00120 } 00121 else 00122 { 00123 if( _isWaiting.get() ) 00124 { 00125 _waitTask.start() ; 00126 _moveTask.stop() ; 00127 } 00128 else 00129 { 00130 _waitTask.stop() ; 00131 _moveTask.start() ; 00132 } 00133 } 00134 } 00135 if( _activate.get() ) 00136 { 00137 Wm4::Vector3f target( _target.get().getTranslate() ) ; 00138 mkm::CVector3 pos( getOwner()->_controlMesh.getPosition() ) ; 00139 float deltaX = -target.X() - pos[mkm::X] ; 00140 float deltaZ = target.Z() - pos[mkm::Y] ; 00141 float distance = sqrt( deltaX * deltaX + deltaZ * deltaZ ) ; 00142 bool mustWait = distance < _threshold.get() ; 00143 if( mustWait && !_isWaiting.get() ) 00144 { // 00145 _waitTask.start() ; 00146 _moveTask.stop() ; 00147 _isWaiting.set( true ) ; 00148 } 00149 if( !mustWait && _isWaiting.get() ) 00150 { // 00151 _waitTask.stop() ; 00152 _moveTask.start() ; 00153 _isWaiting.set( false ) ; 00154 } 00155 if( !mustWait ) 00156 { 00157 getOwner()->_controlMesh.setOrientationToMoveToward( deltaX, deltaZ, _speed.get(), false ) ; 00158 } 00159 } 00160 } 00161 }
AttributeT< bool > OMK::MKMMoveToTaskExtension::_activate [protected] |
Definition at line 38 of file OMKMKMMoveToTaskExtension.h.
Referenced by loadExtensionParameters(), and preComputeParameters().
AttributeT< bool > OMK::MKMMoveToTaskExtension::_isWaiting [protected] |
Definition at line 39 of file OMKMKMMoveToTaskExtension.h.
Referenced by loadExtensionParameters(), and preComputeParameters().
AttributeT< float > OMK::MKMMoveToTaskExtension::_threshold [protected] |
Definition at line 40 of file OMKMKMMoveToTaskExtension.h.
Referenced by loadExtensionParameters(), and preComputeParameters().
AttributeT< float > OMK::MKMMoveToTaskExtension::_speed [protected] |
Definition at line 41 of file OMKMKMMoveToTaskExtension.h.
Referenced by loadExtensionParameters(), and preComputeParameters().
AttributeT< Type::Transform > OMK::MKMMoveToTaskExtension::_target [protected] |
Definition at line 42 of file OMKMKMMoveToTaskExtension.h.
Referenced by loadExtensionParameters(), and preComputeParameters().
mkm::CHumanTask_Motion OMK::MKMMoveToTaskExtension::_moveTask [protected] |
mkm::CHumanTask_Motion OMK::MKMMoveToTaskExtension::_waitTask [protected] |
bool OMK::MKMMoveToTaskExtension::_initDone [protected] |
std::string OMK::MKMMoveToTaskExtension::_moveMotion [protected] |
Definition at line 46 of file OMKMKMMoveToTaskExtension.h.
Referenced by loadExtensionParameters(), and preComputeParameters().
std::string OMK::MKMMoveToTaskExtension::_waitMotion [protected] |
Definition at line 47 of file OMKMKMMoveToTaskExtension.h.
Referenced by loadExtensionParameters(), and preComputeParameters().
float OMK::MKMMoveToTaskExtension::_transitionDuration [protected] |
Definition at line 48 of file OMKMKMMoveToTaskExtension.h.
Referenced by loadExtensionParameters(), and preComputeParameters().
float OMK::MKMMoveToTaskExtension::_weight [protected] |
Definition at line 49 of file OMKMKMMoveToTaskExtension.h.
Referenced by loadExtensionParameters(), and preComputeParameters().
float OMK::MKMMoveToTaskExtension::_rank [protected] |
Definition at line 50 of file OMKMKMMoveToTaskExtension.h.
Referenced by loadExtensionParameters(), and preComputeParameters().
Documentation generated on Mon Jun 9 11:46:04 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |