00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef VRS_SG_BOOKMARKNAVIGATION_H
00021 #define VRS_SG_BOOKMARKNAVIGATION_H
00022
00023 #include <vrs/sg/interactiontechnique.h>
00024
00025 namespace VRS {
00026
00027 class DirectionInterpolator;
00028
00035 class VRS_CORE_API BookmarkNavigation : public InteractionTechnique {
00036
00037 public:
00041 BookmarkNavigation(double duration = 6.0);
00042
00046 static InteractionTechnique::KeyFunctionID getStoreKeyID(int i);
00047 static InteractionTechnique::KeyFunctionID getActivationKeyID(int i);
00048
00054 void setBookmarkKeys(
00055 SO<Iterator<unsigned int> > storeKeys = NULL,
00056 SO<Iterator<unsigned int> > activationKeys = NULL,
00057 InputEvent::Modifier storeKeyMustModifier = InputEvent::Ctrl,
00058 InputEvent::Modifier activationKeyMustModifier = InputEvent::NoModifier,
00059 InputEvent::Modifier storeKeyMustNotModifier = InputEvent::AllKeys,
00060 InputEvent::Modifier activationKeyMustNotModifier = InputEvent::AllKeys
00061 );
00062
00071 void initPath(const Vector& endPos, const Vector& endDir, bool accelerate = true, bool decelerate = true);
00072
00075 void initMultiStepPath(SO<Array<Vector> > positions, SO<Array<Vector> > directions);
00076
00078 enum PathStyle {
00079 LookInFlightDirection,
00081 LookAtTarget,
00082 Simple
00084 };
00085
00088 void setPathStyle(PathStyle pathStyle);
00089
00091 PathStyle getPathStyle() const;
00092
00094 void setDuration(double duration);
00095
00097 double getDuration() const;
00098
00100 bool pathActive() const;
00101
00103 void stopPath();
00104
00106 void savePath(const std::string& fileName);
00107 void loadPath(const std::string& fileName);
00108
00111 static const InteractionTechnique::KeyFunctionID LoadKey;
00112 static const InteractionTechnique::KeyFunctionID SaveKey;
00113 void setBookmarkFilename(const std::string& filename);
00114 const std::string& getBookmarkFilename() const;
00115
00117 virtual void onDeactivation();
00118
00121 void setStopOnDeactivation(bool stop);
00122 bool stopOnDeactivation() const;
00123
00124 VRS_TYPEINFO(BookmarkNavigation, InteractionTechnique);
00125 VRS_SERIALIZABLE(BookmarkNavigation);
00126
00127 private:
00128
00129 virtual void onKey(SO<KeyEvent> event, KeyFunctionID id);
00130 virtual void onTimer(SO<VRS::TimeEvent> event, double secondsSinceLastTimeEvent);
00131
00132 SO<Array<bool> > m_targetStored;
00133 SO<Array<Vector> > m_targetPos;
00134 SO<Array<Vector> > m_targetDir;
00135
00136 double m_duration;
00137 PathStyle m_pathStyle;
00138
00139
00140 SO<DirectionInterpolator> m_interpol;
00141 bool m_active;
00142 Vector m_currentTargetPos;
00143 Vector m_currentTargetDir;
00144 Vector m_currentStartPos;
00145 bool m_accelerate;
00146 bool m_decelerate;
00147 double m_progress;
00148 bool m_stopOnDeactivation;
00149
00150
00151 static std::string KeyString;
00152 static std::string PathHeaderString;
00153 std::string m_pathASCIIFileName;
00154
00155
00156 bool m_multiStepPath;
00157 SO<Array<Vector> > m_multiStepPositions;
00158 SO<Array<Vector> > m_multiStepDirections;
00159 unsigned int m_currentStep;
00160 };
00161
00162 }
00163
00164 #endif // VRS_SG_BOOKMARKNAVIGATION_H