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
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 #ifndef VRS_SG_JUMPNAVIGATION_H
00088 #define VRS_SG_JUMPNAVIGATION_H
00089
00090 #include <vrs/sg/inputevent.h>
00091 #include <vrs/sg/keyevent.h>
00092 #include <vrs/sg/navigation.h>
00093 #include <vrs/sg/timeevent.h>
00094 #include <vrs/directioninterpolator.h>
00095 #include <vrs/lookat.h>
00096 #include <vrs/time.h>
00097
00098 namespace VRS {
00099
00106 class VRS_CORE_API JumpNavigation : public Navigation {
00107
00108 public:
00109 JumpNavigation(
00110 const Vector& onPlane,
00111 LookAt* lookAt,
00112 double duration = 6.0
00113 );
00121 void setScaling(double horizontal = 1.0, double vertical = 1.0);
00130 double getHorizontalScaling() const;
00131 double getVerticalScaling() const;
00135 void setKeyCodes(
00136 Iterator<unsigned int>* startKeys,
00137 Iterator<unsigned int>* storeKeys,
00138 InputEvent::Modifier startModifier = InputEvent::NoModifier,
00139 InputEvent::Modifier storeModifier = InputEvent::Ctrl
00140 );
00146 void initPath(const std::string& camName, bool accelerate = true, bool decelerate = true);
00147 void initPath(const Vector& endPos, const Vector& endDir, bool accelerate = true, bool decelerate = true, const Vector& endUp = Vector(0.0, 1.0, 0.0));
00150 void initMultiStepPath(Array<Vector>* positions, Array<Vector>* directions);
00154 void enableKeys();
00155 void disableKeys();
00163 void setNavMode(Navigation::NavMode mode);
00164
00165 void setDuration(double duration);
00167 double getDuration() const;
00169
00170 bool pathActive() const;
00172
00173 void stopPath();
00175
00176 virtual BehaviorNode::InvalidationHint handle(Event* event);
00177
00178
00179
00180 void savePath(const std::string& fileName);
00181 void loadPath(const std::string& fileName);
00184 void enableLoadSaveKeys(const std::string& filename, unsigned char loadKey, unsigned char saveKey);
00185 void disableLoadSaveKeys();
00189
00190 static void useAlternativeImplementation(bool yesNo);
00192
00193
00194 VRS_TYPEINFO(JumpNavigation, Navigation);
00195 VRS_SERIALIZABLE(JumpNavigation);
00196
00197 protected:
00198 JumpNavigation();
00199
00200 private:
00201 BehaviorNode::InvalidationHint onTimer(double progress);
00202 BehaviorNode::InvalidationHint onKey(KeyEvent* e);
00203 void initPath(int index);
00204
00205 SO<Array<bool> > targetStored_;
00206 SO<Array<Vector> > targetPos_;
00207 SO<Array<Vector> > targetDir_;
00208
00209 bool interpolateUp_;
00210
00211 SO<DirectionInterpolator> interpolDir_;
00212 SO<DirectionInterpolator> interpolUp_;
00213 VRS::Vector bezierPoints_[4];
00214
00215 bool active_;
00216
00217 InputEvent::Modifier startModifier_;
00218 InputEvent::Modifier storeModifier_;
00219
00220 double arcHeight_;
00221 Vector onPlane_;
00222 int currentTarget_;
00223 bool shortPath_;
00224 double shortPathLengthLimit_;
00225
00226 double duration_;
00227
00228 double horScaling_;
00229 double vertScaling_;
00230
00231 SO<Iterator<unsigned int> > startKeys_;
00232 SO<Iterator<unsigned int> > storeKeys_;
00233
00234 Vector currentTargetPos_;
00235 Vector currentTargetDir_;
00236
00237 bool enableKeys_;
00238
00239 bool startTimeStampIsValid_;
00240 VRSTime startTimeStamp_;
00241
00242 bool accelerate_;
00243 bool decelerate_;
00244
00245
00246 static std::string KeyString;
00247 static std::string PathHeaderString;
00248 std::string pathASCIIFileName_;
00249 unsigned char loadKey_;
00250 unsigned char saveKey_;
00251 bool loadSaveEnabled_;
00252
00253
00254 bool multiStepPath_;
00255 SO<Array<Vector> > multiStepPositions_;
00256 SO<Array<Vector> > multiStepDirections_;
00257 unsigned int currentStep_;
00258 };
00259
00260 }
00261
00262 #endif // VRS_SG_JUMPNAVIGATION_H