00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SHEEP_FRAMEWORK_SCENEORBITER_H
00024 #define SHEEP_FRAMEWORK_SCENEORBITER_H
00025
00026 #include "common/math/point3.h"
00027 #include "common/math/real.h"
00028 #include "common/math/vector2.h"
00029
00030 #include <cassert>
00031 #include <cmath>
00032
00033
00034
00035 namespace sheep {
00036
00037 class SceneOrbiter {
00038 public:
00039 enum Movement {
00040 TUMBLE, TRACK, DOLLY
00041 };
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 SceneOrbiter(
00053 const Point3 ¢er = 0,
00054 Real azimuth = PI / 4.0,
00055 Real elevation = PI / 4.0,
00056 Real distance = 1.0
00057 );
00058
00059 void Configure(
00060 const Point3 ¢er,
00061 Real azimuth,
00062 Real elevation,
00063 Real distance
00064 );
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 void BeginDrag(Movement m, const Vector2 &p);
00076 void UpdateDrag(const Vector2 &p);
00077 void EndDrag();
00078 void CancelDrag();
00079
00080 bool IsTumbling() const;
00081 bool IsTracking() const;
00082 bool IsDollying() const;
00083 bool IsDragging() const;
00084
00085 void SetCenter(const Point3 ¢er);
00086 const Point3 &GetCenter() const;
00087
00088 Point3 GetEyePosition() const;
00089
00090 Real GetAzimuth() const;
00091 Real GetElevation() const;
00092 Real GetDistance() const;
00093
00094 private:
00095 Point3 m_center, m_old_center;
00096 Real m_azimuth, m_old_azimuth;
00097 Real m_elevation, m_old_elevation;
00098 Real m_distance, m_old_distance;
00099
00100 Movement m_movement;
00101 Vector2 m_old_point;
00102
00103 bool m_is_dragging;
00104
00105 #ifdef REVERSE_AZIMUTH
00106 bool m_reverse_azimuth;
00107 #endif // REVERSE_AZIMUTH
00108
00109 void tumble(const Vector2 &delta);
00110 void track(const Vector2 &delta);
00111 void dolly(const Vector2 &delta);
00112 };
00113
00114 #include "sceneorbiter.inl"
00115
00116 }
00117
00118 #endif // !SHEEP_FRAMEWORK_SCENEORBITER_H