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 #ifndef VRS_SG_UFOPHYSICALNAVIGATION_H
00071 #define VRS_SG_UFOPHYSICALNAVIGATION_H
00072
00073 #include <vrs/sg/physicalnavigation.h>
00074
00075 #undef min
00076 #undef max
00077
00078 namespace VRS {
00079
00105 class VRS_CORE_API UfoPhysicalNavigation : public PhysicalNavigation {
00106
00107 public:
00108 UfoPhysicalNavigation(
00109 LookAt* lookAt = NULL,
00110 InputEvent::Button button = InputEvent::MouseButton1,
00111 InputEvent::Modifier must_modifier = InputEvent::NoModifier,
00112 InputEvent::Modifier must_not_modifier = InputEvent::NoModifier,
00113 double meterDefinition = 1.0,
00114 double minHeight = 0.0,
00115 double heightSensitivity = 0.1,
00116 FilterTag* filterTag = NULL,
00117 Vector gravitationDir = Vector(0.0, -1.0, 0.0),
00118 PhysicalForce::ForceMode forceMode = PhysicalForce::Spring
00119 );
00150 double getMinHeight() const;
00152 void setMinHeight(double minHeight);
00154
00155 double getSpeedSensitivity() const;
00157 void setSpeedSensitivity(double);
00159
00160 double getMaxLookDownAngle() const;
00163 void setMaxLookDownAngle(double angle);
00165 double getMinLookDownAngle() const;
00168 void setMinLookDownAngle(double angle);
00170 void setMinMaxLookDownAngles(double minAngle, double maxAngle);
00172
00173 bool allowBackwardMovement() const;
00175 void setAllowBackwardMovement(bool yesNo);
00177
00178 VRS_TYPEINFO(UfoPhysicalNavigation, PhysicalNavigation);
00179 VRS_SERIALIZABLE(UfoPhysicalNavigation);
00180
00181 protected:
00182 float minHeight_;
00187 virtual void translateInteractionIntoTargetPos(
00188 Vector& target, Vector& dir,
00189 float x, float y,
00190 double time_now, double time_lastCalc
00191 );
00196 virtual bool validateTargetPosition(Vector& target, const Vector& oldTarget, const Vector& dir);
00203 virtual BehaviorNode::InvalidationHint processKeyEvent(KeyEvent*);
00208 virtual void updateLookAt(const Vector& pos, const Vector& dir);
00217 virtual void initPhysicalNavigation(const Vector&);
00227 virtual bool keyCanWakeUpNavigation(KeyEvent*);
00232 virtual InvalidationHint handle(Event*);
00234
00235 private:
00236 float currentHeight_;
00239 double heightSensitivity_;
00243 double speed_;
00246 double speedSensitivity_;
00250 double leftrightSensitivity_;
00254 double lookingDownOnTerrainAngle_;
00261 double maxLookingDownOnTerrainAngle_;
00264 double minLookingDownOnTerrainAngle_;
00267 double lookingDownSensitivity_;
00271 bool m_allowBackwardMovement;
00272 };
00273
00274 inline double UfoPhysicalNavigation::getSpeedSensitivity() const { return speedSensitivity_; }
00275 inline void UfoPhysicalNavigation::setSpeedSensitivity(double val) { if (val>0.0) speedSensitivity_ = val; }
00276
00277 inline double UfoPhysicalNavigation::getMinHeight() const { return (double)minHeight_; }
00278 inline void UfoPhysicalNavigation::setMinHeight(double val) { if (val>=0.0) minHeight_ = (float)val; }
00279
00280 }
00281
00282 #endif // VRS_SG_UFOPHYSICALNAVIGATION_H