00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #ifndef VRS_SG_PATHNAVIGATION_H
00053 #define VRS_SG_PATHNAVIGATION_H
00054
00055 #include <vrs/sg/navigation.h>
00056 #include <vrs/vector.h>
00057
00058 namespace VRS {
00059
00060 class DirectionInterpolator;
00061 class JumpNavigation;
00062 class ButtonEvent;
00063 class MotionEvent;
00064 class TimeEvent;
00065 class Event;
00066 class Bezier;
00067 class LookAt;
00068
00076 class VRS_CORE_API PathNavigation : public Navigation {
00077
00078 public:
00079
00080 PathNavigation(Vector onPlane, LookAt* lookAt);
00083 virtual ~PathNavigation();
00084
00085 void setPath(Iterator<Vector>* keyPositions, Iterator<Vector>* keyDirections);
00089 bool startPossible() const;
00093 void gotoStart();
00095 void startPath();
00097 bool playing();
00100 void setJumpNavigation(JumpNavigation* jumpNav);
00106 void setSpeedParameters(double accel, double maxSpeed);
00111 void setTangentLength(double tangentLength);
00118 void enableKeys(unsigned char recordKey, unsigned char startKey, unsigned char clearKey);
00123 void disableKeys();
00126 virtual BehaviorNode::InvalidationHint handle(Event*);
00129 void setLoopEnable(bool enabled);
00132 void savePath(const std::string& fileName);
00133 void loadPath(const std::string& fileName);
00136 void enableLoadSaveKeys(const std::string& filename, unsigned char loadKey, unsigned char saveKey);
00137 void disableLoadSaveKeys();
00141 VRS_SERIALIZABLE(PathNavigation);
00142 VRS_TYPEINFO(PathNavigation, Navigation);
00143
00144 private:
00145
00146 PathNavigation();
00147
00148 BehaviorNode::InvalidationHint onTimer(TimeEvent* e);
00149
00150 SO<JumpNavigation> jumper_;
00151 SO<Array<SO<Bezier> > > path_;
00152 SO<LookAt> lookAt_;
00153 SO<DirectionInterpolator> interpol_;
00154 SO<Iterator<Vector> > dirs_;
00155
00156 SO<Array<Vector> > arrayPos_;
00157 SO<Array<Vector> > arrayDir_;
00158
00159 UINT section_;
00160 double localParam_;
00161 double speed_;
00162 double acceleration_;
00163 double maxSpeed_;
00164 double rotationSpeed_;
00165 double tangentLength_;
00166
00167 bool jumping_;
00168 bool pathActive_;
00169 bool enableLoop_;
00170
00171 bool enableKeys_;
00172 unsigned char recordKey_;
00173 unsigned char startKey_;
00174 unsigned char clearKey_;
00175
00176 double elapsedTime_;
00177
00178
00179 static std::string KeyString;
00180 static std::string PathHeaderString;
00181 std::string pathASCIIFileName_;
00182 unsigned char loadKey_;
00183 unsigned char saveKey_;
00184 bool loadSaveEnabled_;
00185
00186 };
00187
00188 }
00189
00190 #endif // VRS_SG_PATHNAVIGATION_H
00191