WaypointWalkNode.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_WaypointWalkNode_h_
00003 #define INCLUDED_WaypointWalkNode_h_
00004
00005 #include "MCNode.h"
00006 #include "Motion/MotionManager.h"
00007 #define WALKMC_NO_WARN_NOOP
00008 #include "Motion/WaypointWalkMC.h"
00009 #undef WALKMC_NO_WARN_NOOP
00010 #include "Events/EventRouter.h"
00011 #include "Events/LocomotionEvent.h"
00012 #include "DualCoding/VRmixin.h"
00013
00014
00015
00016 extern const char defWaypointWalkNodeName[];
00017
00018
00019 extern const char defWaypointWalkNodeDesc[];
00020
00021
00022 template<typename W, const char* mcName=defWaypointWalkNodeName, const char* mcDesc=defWaypointWalkNodeDesc>
00023 class WaypointEngineNode : public MCNode<W,mcName,mcDesc> {
00024 public:
00025
00026
00027 WaypointEngineNode() : MCNode<W,mcName,mcDesc>() {}
00028
00029
00030 WaypointEngineNode(const std::string& name) : MCNode<W,mcName,mcDesc>(name) {}
00031
00032
00033 ~WaypointEngineNode() {}
00034
00035 virtual void postStart() {
00036
00037
00038 MCNode<W,mcName,mcDesc>::postStart();
00039 if ( MCNode<W,mcName,mcDesc>::isActive() ) {
00040 erouter->addListener(this, EventBase::locomotionEGID, MCNode<W,mcName,mcDesc>::getMC_ID(), EventBase::statusETID);
00041 MCNode<W,mcName,mcDesc>::getMC()->go();
00042 }
00043 erouter->addTimer(this, 9999, 2000, true);
00044
00045 DualCoding::VRmixin::isWalkingFlag = true;
00046 }
00047
00048 virtual void stop() {
00049 { MMAccessor<W> wp_walker = MCNode<W,mcName,mcDesc>::getMC();
00050 wp_walker->pause();
00051 wp_walker->zeroVelocities();
00052 }
00053
00054
00055 DualCoding::VRmixin::autoRefreshSketchWorld();
00056 MCNode<W,mcName,mcDesc>::stop();
00057
00058 DualCoding::VRmixin::isWalkingFlag = false;
00059 }
00060
00061 protected:
00062
00063 WaypointEngineNode(const std::string& className, const std::string& instanceName) :
00064 MCNode<W,mcName,mcDesc>(className,instanceName) {}
00065
00066 void doEvent() {
00067 if ( MCNode<W,mcName,mcDesc>::event->getGeneratorID() == EventBase::timerEGID && MCNode<W,mcName,mcDesc>::event->getSourceID() == 9999 )
00068 DualCoding::VRmixin::autoRefreshSketchWorld();
00069 else if ( static_cast<const LocomotionEvent&>(*MCNode<W,mcName,mcDesc>::event).isStop() )
00070 MCNode<W,mcName,mcDesc>::postStateCompletion();
00071 }
00072
00073 };
00074
00075
00076 typedef WaypointEngineNode<WaypointWalkMC> WaypointWalkNode;
00077
00078
00079
00080
00081
00082
00083 #endif