![]() |
VR-Forces 4.0.4 Class Documentation
|
DtSurfaceEntityMoveToController is a controller that models the movement of a surface entity to a specific waypoint. More...

Public Member Functions | |
| DtSurfaceEntityMoveToController (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0) | |
| (const DtString&,DtVrfObject*,DtSimManager*, | |
| virtual | ~DtSurfaceEntityMoveToController () |
| destructor | |
| virtual DtString | type () const |
| Returns a string identifies the class type of component. | |
| virtual void | tick () |
| Takes control of the surface entity output port group and determines the progress controls required to move the ship to the destination waypoint. | |
| virtual void | setupGoalVector (const DtVector &goalPosition) |
| Updates myGoalVector. | |
| virtual void | doMoving (double desiredSpeed) |
| Calls driftTo with the value returned by getLocalDestination() and the given desired speed. | |
| virtual bool | passedGoal () |
| Determines if the ship has sailed past myControlpoint. | |
| virtual bool | atGoal () |
| Determines if the entity is within the at-distance parameter to the waypoint. | |
| virtual bool | nearGoal () |
| Determines if the entity is within the near-distance parameter to the waypoint. | |
| virtual double | findDesiredSpeed () |
| virtual void | processMoveToTask (DtSimMessage *msg) |
| Retrieves the name of the target waypoint from the task message. | |
| virtual void | registerTaskMsgCallbacks () |
| Registers interest in move to tasks by calling addTaskProcessorCallback with moveToCallback as the function pointer, and the 'this' pointer as the user data. | |
Static Public Member Functions | |
| static void | moveToCallback (DtSimMessage *msg, void *user) |
| Called when a move to message is received. | |
| static DtSimComponent * | creator (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0) |
| (const DtString&,DtVrfObject*,DtSimManager*, | |
Protected Member Functions | |
| virtual bool | setupControlPoint () |
| Updates myControlPoint. | |
| virtual double | distanceSquaredToDestination2D (const DtVector ¤t) const |
| Returns distance squared from destination point to current location. | |
| virtual void | getLocalDestination (DtVector &local) const |
Protected Attributes | |
| DtVrfObject * | myControlPoint |
| Pointer to the target waypoint. | |
| DtVector | myControlPointLastLocation |
| Stores last known location of the waypoint. | |
| DtVector | myGoalVector |
| Maintained by setupGoalVector() | |
| bool | myAtGoal |
| bool | myNearGoal |
| bool | myPassedGoal |
Private Member Functions | |
| DtSurfaceEntityMoveToController () | |
| default constructor - not implemented | |
| DtSurfaceEntityMoveToController (const DtSurfaceEntityMoveToController &orig) | |
| copy constructor | |
| const DtSurfaceEntityMoveToController & | operator= (const DtSurfaceEntityMoveToController &orig) |
| assignment operator | |
DtSurfaceEntityMoveToController is a controller that models the movement of a surface entity to a specific waypoint.
End User Description: DtSurfaceEntityMoveToController (surfEntMvToCtl.h) is derived from DtSurfaceEntityPilotController and implements the Move To Waypoint task for surface entities. It is the parent class of most of the movement controllers. It overrides DtTaskControllerComponent:: registerTaskMsgCallbacks() and registers the callback function moveToCallback() for DtMoveToType. When a move to message is received, the callback invokes processMoveToTask(), which looks up the waypoint in the object manager and stores a pointer to it in myControlPoint.
Uses Descriptor Type: DtSurfaceEntityPilotControllerDescriptor
| DtSurfaceEntityMoveToController::DtSurfaceEntityMoveToController | ( | const DtString & | name, |
| DtVrfObject * | owner, | ||
| DtSimManager * | simManager, | ||
| DtComponentDescriptor * | desc = 0, |
||
| DtReaderWriterRegistry * | parentRegistry = 0 |
||
| ) |
(const DtString&,DtVrfObject*,DtSimManager*,
| name | Reader writer name of this component. |
| owner | The DtVrfObject that owns this component |
| simManager | The simulation manager (provides access to terrain, message interface, simulation clock). |
| desc | The component descriptor used to initialize this component. |
| parentRegistry | Pointer to the parent reader writer registry (the containing object that reads/writes this object). |
| virtual DtSurfaceEntityMoveToController::~DtSurfaceEntityMoveToController | ( | ) | [virtual] |
destructor
default constructor - not implemented
| DtSurfaceEntityMoveToController::DtSurfaceEntityMoveToController | ( | const DtSurfaceEntityMoveToController & | orig | ) | [private] |
copy constructor
| virtual DtString DtSurfaceEntityMoveToController::type | ( | ) | const [virtual] |
Returns a string identifies the class type of component.
Type values are defined in compTypes.h. DtSimComponent creation functions are registered with the DtSimComponentFactory using the type values as the key.
Reimplemented from DtSurfaceEntityPilotController.
Reimplemented in DtSurfaceEntityMoveAlongController, DtSurfaceEntityPatrolRouteController, DtSurfaceEntityPatrolBetweenController, DtSurfaceEntityMoveToLocationController, and DtSurfaceEntityFollowEntityController.
| virtual void DtSurfaceEntityMoveToController::tick | ( | ) | [virtual] |
Takes control of the surface entity output port group and determines the progress controls required to move the ship to the destination waypoint.
The steps are:
Reimplemented from DtSurfaceEntityPilotController.
Reimplemented in DtSurfaceEntityFollowEntityController.
| virtual void DtSurfaceEntityMoveToController::setupGoalVector | ( | const DtVector & | goalPosition | ) | [virtual] |
Updates myGoalVector.
When the move to task arrives (or when the waypoint we're following moves), set up a vector from the waypoint to the entity to use in determining when/if we pass the waypoint. This is done by subtracting the DtVector representing the control point's position from the one representing the entity's position. This vector is used by passedGoal() to determine when (or if) the entity goes to far, and should stop. The result is stored in myGoalVector.
Reimplemented in DtSurfaceEntityFollowEntityController.
| virtual void DtSurfaceEntityMoveToController::doMoving | ( | double | desiredSpeed | ) | [virtual] |
Calls driftTo with the value returned by getLocalDestination() and the given desired speed.
Reimplemented in DtSurfaceEntityFollowEntityController, DtSurfaceEntityPatrolBetweenController, DtSurfaceEntityMoveAlongController, and DtSurfaceEntityPatrolRouteController.
| virtual bool DtSurfaceEntityMoveToController::passedGoal | ( | ) | [virtual] |
Determines if the ship has sailed past myControlpoint.
The determination is done based on an imaginary line drawn through the goal vector, perpendicular to the entity's heading. If the entity has passed that line, or will pass it during this simulation frame based on the current speed (computed last frame) passedGoal returns true.
Reimplemented in DtSurfaceEntityFollowEntityController, DtSurfaceEntityPatrolBetweenController, and DtSurfaceEntityMoveAlongController.
| virtual bool DtSurfaceEntityMoveToController::atGoal | ( | ) | [virtual] |
Determines if the entity is within the at-distance parameter to the waypoint.
If the myDistanceSquared member calculated in tick() is less than or equal to the square of the value provided in the at-distance parameter of the DtGroundMoveToDescriptor, atGoal() returns true. The result is stored in myAtGoal.
Reimplemented in DtSurfaceEntityMoveAlongController, and DtSurfaceEntityPatrolBetweenController.
| virtual bool DtSurfaceEntityMoveToController::nearGoal | ( | ) | [virtual] |
Determines if the entity is within the near-distance parameter to the waypoint.
If the myDistanceSquared member calculated in tick() is less than or equal to the square of the value provided in the near-distance parameter of the DtGroundMoveToDescriptor, nearGoal() returns true. This is not currently used for moving to a point, only for entity following. The result is stored in myNearGoal.
| virtual double DtSurfaceEntityMoveToController::findDesiredSpeed | ( | ) | [virtual] |
Reimplemented in DtSurfaceEntityFollowEntityController.
| static void DtSurfaceEntityMoveToController::moveToCallback | ( | DtSimMessage * | msg, |
| void * | user | ||
| ) | [static] |
Called when a move to message is received.
Instances of this component will register this callback in registerTaskMsgCallbacks (with their own 'this' pointer as user data) by calling addTaskProcessorCallback in order to request for notification of move-to tasks. When this callback is activated, the user data pointer is cast to an instance of this class upon which processMoveToTask is called with the move to task message.
| virtual void DtSurfaceEntityMoveToController::processMoveToTask | ( | DtSimMessage * | msg | ) | [virtual] |
Retrieves the name of the target waypoint from the task message.
Called by moveToCallback to lookup the control point stored in the move to message and store a pointer to it in myControlPoint. If the lookup is successful, setupGoalVector() is called. The name of the waypoint is saved as the control object name in the process state repository.
| virtual void DtSurfaceEntityMoveToController::registerTaskMsgCallbacks | ( | ) | [virtual] |
Registers interest in move to tasks by calling addTaskProcessorCallback with moveToCallback as the function pointer, and the 'this' pointer as the user data.
Reimplemented from DtTaskControllerComponent.
Reimplemented in DtSurfaceEntityMoveAlongController, DtSurfaceEntityPatrolBetweenController, DtSurfaceEntityPatrolRouteController, DtSurfaceEntityFollowEntityController, and DtSurfaceEntityMoveToLocationController.
| static DtSimComponent* DtSurfaceEntityMoveToController::creator | ( | const DtString & | name, |
| DtVrfObject * | owner, | ||
| DtSimManager * | simManager, | ||
| DtComponentDescriptor * | desc = 0, |
||
| DtReaderWriterRegistry * | parentRegistry = 0 |
||
| ) | [static] |
(const DtString&,DtVrfObject*,DtSimManager*,
| name | Reader writer name of this component. |
| owner | The DtVrfObject that owns this component |
| simManager | The simulation manager (provides access to terrain, message interface, simulation clock). |
| desc | The component descriptor used to initialize this component. |
| parentRegistry | Pointer to the parent reader writer registry (the containing object that reads/writes this object). |
Reimplemented from DtSurfaceEntityPilotController.
Reimplemented in DtSurfaceEntityFollowEntityController, DtSurfaceEntityMoveAlongController, DtSurfaceEntityMoveToLocationController, DtSurfaceEntityPatrolBetweenController, and DtSurfaceEntityPatrolRouteController.
| const DtSurfaceEntityMoveToController& DtSurfaceEntityMoveToController::operator= | ( | const DtSurfaceEntityMoveToController & | orig | ) | [private] |
assignment operator
| virtual bool DtSurfaceEntityMoveToController::setupControlPoint | ( | ) | [protected, virtual] |
Updates myControlPoint.
Looks up the control point based on the control object name stored in the process state repository. If necessary the myControlPoint pointer is updated. If the control point has changed, setupGoalVector is called to reset myGoalVector.
Reimplemented in DtSurfaceEntityMoveAlongController, DtSurfaceEntityFollowEntityController, and DtSurfaceEntityMoveToLocationController.
| virtual double DtSurfaceEntityMoveToController::distanceSquaredToDestination2D | ( | const DtVector & | current | ) | const [protected, virtual] |
Returns distance squared from destination point to current location.
Positions are all in local coordinates.
Reimplemented in DtSurfaceEntityMoveToLocationController.
| virtual void DtSurfaceEntityMoveToController::getLocalDestination | ( | DtVector & | local | ) | const [protected, virtual] |
Reimplemented in DtSurfaceEntityMoveToLocationController.
Pointer to the target waypoint.
Stores last known location of the waypoint.
Maintained by setupGoalVector()
bool DtSurfaceEntityMoveToController::myAtGoal [protected] |
bool DtSurfaceEntityMoveToController::myNearGoal [protected] |
bool DtSurfaceEntityMoveToController::myPassedGoal [protected] |