#include <OMKTriggerExtension.h>
Inheritance diagram for OMK::DistanceToExtension:
Protected Member Functions | |
virtual bool | loadExtensionParameters (const ConfigurationParameterDescriptor *node) |
Configuration parameters loader of Extension. | |
virtual void | preComputeParameters () |
method. | |
Protected Attributes | |
IAttributeBaseT< Type::Transform > * | _target |
AttributeT< float > | _distance |
IAccessorT< OMK::Type::Transform > * | _positionAccessor |
The associated attribute. | |
bool | _deleteTarget |
Private Member Functions | |
DECLARE_EXTENSION_FACTORY (DistanceToExtension) |
To find the attribute which gives the position of the target, this extension follows these steps:
To find the attribute which gives the position of the object, this extension find the attribute id in the field PositionId the extension configuration node. By default the looked for attribute is the one named Position.
See also TriggerAttributeExtension and TriggerExtension which use this extension as their ancestor.
object { Class Tracker Scheduling { Frequency 60 } UserParams { TargetConnect [trajectory Position] Position [[0 0 200]] Speed 0.01 } Extensions { reach { Class DistanceTo // By default uses "Target" as target attribute and "Position" as position attribute } } }
object { Class SimplePoint Scheduling { Frequency 60 } UserParams { Position [[0 0 200]] } Extensions { reach { Class DistanceTo TargetConnect [trajectory Position] // By default adds a "reachTarget" attribute and uses "Position" as position attribute } } }
Definition at line 130 of file OMKTriggerExtension.h.
OMK::DistanceToExtension::DECLARE_EXTENSION_FACTORY | ( | DistanceToExtension | ) | [private] |
bool DistanceToExtension::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.
Reimplemented in OMK::TriggerBaseExtension, OMK::TriggerAttributeExtension, and OMK::TriggerExtension.
Definition at line 67 of file OMKTriggerExtension.cpp.
References _deleteTarget, _distance, OMK::ExtensionT< OMK::ExtensibleSimulatedObject >::_owner, _positionAccessor, _target, OMK::ParametersAccessor::get(), OMK::ExtensibleSimulatedObject::getBaseAttribute(), and OMK::IAttributeBaseT< PrmType >::loadParameters().
Referenced by OMK::TriggerBaseExtension::loadExtensionParameters().
00068 { 00069 // Retrieve all the parameters 00070 Name attributeName( "Position" ) ; 00071 ParametersAccessor::get( node, "PositionId", attributeName ) ; 00072 _positionAccessor = _owner->getBaseAttribute< OMK::Type::Transform >( attributeName ) ; 00073 if( _deleteTarget ) 00074 { 00075 _target->loadParameters( node, "Target" ) ; 00076 } 00077 _distance.loadParameters( node, "Distance" ) ; 00078 00079 return _positionAccessor != 0 ; 00080 }
void DistanceToExtension::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.
Reimplemented in OMK::TriggerBaseExtension.
Definition at line 82 of file OMKTriggerExtension.cpp.
References _distance, _positionAccessor, _target, OMK::IAccessorT< T >::get(), OMK::Type::Transform::getTranslate(), and OMK::IAttributeT< PrmType, ModelType, AccessorType >::set().
Referenced by OMK::TriggerBaseExtension::preComputeParameters().
00083 { 00084 Wm4::Vector3f target( _target->get().getTranslate() ) ; 00085 Wm4::Vector3f pos( _positionAccessor->get().getTranslate() ) ; 00086 float deltaX = target.X() - pos.X() ; 00087 float deltaY = target.Y() - pos.Y() ; 00088 float deltaZ = target.Z() - pos.Z() ; 00089 _distance.set( sqrt( deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ ) ) ; 00090 }
IAttributeBaseT< Type::Transform >* OMK::DistanceToExtension::_target [protected] |
Definition at line 136 of file OMKTriggerExtension.h.
Referenced by loadExtensionParameters(), and preComputeParameters().
AttributeT< float > OMK::DistanceToExtension::_distance [protected] |
Definition at line 137 of file OMKTriggerExtension.h.
Referenced by loadExtensionParameters(), OMK::TriggerBaseExtension::preComputeParameters(), and preComputeParameters().
The associated attribute.
It must be defined by the configuration parameter named AttributeId.
Definition at line 140 of file OMKTriggerExtension.h.
Referenced by loadExtensionParameters(), and preComputeParameters().
bool OMK::DistanceToExtension::_deleteTarget [protected] |
Documentation generated on Mon Jun 9 11:46:03 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |