![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /******************************************************************************* 00002 ** Copyright (c) 2009 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 /********************************************************************************** 00006 ** $RCSfile: aggregatedMoveAlongController.h,v $ $Revision: 1.3 $ $State: Exp $ 00007 ***********************************************************************************/ 00008 00011 00012 #ifndef aggregatedMoveAlongController_H_ 00013 #define aggregatedMoveAlongController_H_ 00014 00015 #include "vrfobjcore/singleTaskControllerComponent.h" 00016 00017 class DtCgf; 00018 class DtAnalogOutputPort; 00019 class DtVectorOutputPort; 00020 class DtVrfAggregateStateRepository; 00021 class DtAggregatedMoveAlongPSR; 00022 00026 #include "vrfmodel/vrfmodelDefines.h" 00027 class DT_DLL_vrfmodel DtAggregatedMoveAlongController : public DtSingleTaskControllerComponent 00028 { 00029 private: 00031 DtAggregatedMoveAlongController(); 00033 DtAggregatedMoveAlongController(const DtAggregatedMoveAlongController& orig); 00035 DtAggregatedMoveAlongController& operator=( 00036 const DtAggregatedMoveAlongController& orig); 00037 public: 00039 DtAggregatedMoveAlongController(const DtString& name, DtVrfObject* owner, 00040 DtSimManager* simManager, DtComponentDescriptor* desc=0, 00041 DtReaderWriterRegistry *parentRegistry=0); 00042 00044 virtual ~DtAggregatedMoveAlongController(); 00045 00047 virtual bool init(); 00048 00050 virtual DtString type() const; 00051 00053 virtual void tick(); 00054 00058 static void moveAlongCallback(DtSimMessage * msg, void * usr, DtSimTaskStatePtr taskState); 00059 00062 virtual void processMoveAlongTask(DtSimMessage * msg, DtSimTaskStatePtr taskState); 00063 00067 static void routeChangedCallback(DtVrfObject* obj, void * usr); 00068 virtual void processRouteChanged(DtVrfObject* obj); 00069 00071 virtual void registerTaskMsgCallbacks(); 00072 00080 virtual bool setupRoute(); 00081 00088 virtual bool setupDestination(); 00089 00091 virtual double findDesiredSpeed(); 00092 00098 virtual void stop(); 00099 00101 static void objectAddedCb(DtVrfObject * vrfObject, void * usr); 00102 00104 static DtSimComponent* creator(const DtString& name, DtVrfObject* owner, 00105 DtSimManager* simManager, DtComponentDescriptor* desc=0, 00106 DtReaderWriterRegistry* parentRegistry=0); 00107 00109 virtual bool createPorts(); 00110 00112 virtual bool createPortGroups(); 00113 00119 virtual bool createPSR(); 00120 00123 virtual void doMoving(); 00124 00126 virtual double findDesiredHeading(); 00127 00129 //virtual bool destinationIsInsideObstruction( 00131 00134 //virtual bool decideToGiveUpTask() const; 00135 00136 protected: 00137 00141 virtual void buildLocalRoute(); 00142 00145 virtual void emptyVertexList(); 00146 00150 virtual void processObjectAdded(DtVrfObject * vrfObject); 00151 00154 virtual void clearTask(); 00155 00157 virtual void moveToDestination(); 00158 00160 virtual void invalidateDestinationVector() const; 00161 virtual double distanceToDestination() const; 00162 00171 virtual bool atDestination(); 00172 00182 virtual bool passedDestination(); 00183 00192 virtual bool getDestination(DtVector & destination); 00193 00198 virtual const DtVector& destinationVector() const; 00199 00208 virtual void setupDestinationVector() const; 00209 00214 virtual double atDistance() const; 00215 00221 virtual bool stayOnRoute() const; 00222 00228 virtual double minCorrectionDistance() const; 00229 00237 virtual double maxCorrectionDistance() const; 00238 00242 virtual double maxCorrectionAngle() const; 00243 00247 virtual bool getCurrentRouteSegment(DtVector& routeSegmentStart, 00248 DtVector& routeSegmentEnd) const; 00249 00250 DtSimTaskStatePtr currentTaskState() const; 00251 00252 protected: 00253 00256 DtOutputPortGroup* myMovementControlPortGroup; 00261 DtAnalogOutputPort* mySpeedPort; 00262 00267 DtAnalogOutputPort* myMovementDirectionPort; 00268 00274 DtVectorOutputPort* myDestinationOutputPort; 00275 00276 DtVrfAggregateStateRepository* myTrueAggregateRepository; 00277 00280 DtAggregatedMoveAlongPSR* myProcessState; 00281 00282 00285 DtVrfObject* myRoute; 00286 00289 bool myRouteHasChanged; 00290 bool myResetVertex; 00291 00292 bool myFirstTick; 00293 00294 int myPreviousVertex; 00295 00296 bool myAtDestination; 00297 bool myNearDestination; 00298 bool myPassedDestination; 00299 00300 double myDistanceSquared; 00301 DtVector myLocalDestination; 00302 DtVector myWorldDestination; 00303 double myCurrentSpeed; 00304 mutable bool myDestinationVectorIsValid; 00305 mutable DtVector myDestinationVector; 00306 00307 }; 00308 00309 #endif