GlobeEngine
ArcBallCamera.h
Go to the documentation of this file.
1 
9 #ifndef GlobeEngine_ArcBallCamera_h
10 #define GlobeEngine_ArcBallCamera_h
11 
12 #include "Camera.h"
13 #include <vmmlib/quaternion.hpp>
14 
15 namespace ge {
16 
17 #define Epsilon 1.0e-5
18 
19  class ArcBallCamera : public Camera
20  {
21  public:
22  ArcBallCamera();
24  void clear();
25  void create() {};
26  void create(float _width, float _height,ViewFrustumProperties _in, vmml::Vector3d _pos);
27 
28  //Set new bounds
29  inline void setBounds(vmml::Vector2d _viewport)
30  {
31  //Set adjustment factor for width/height
32  this->adjustWidth = 1.0f / ((_viewport.x() - 1.0f) * 0.5f);
33  this->adjustHeight = 1.0f / ((_viewport.y() - 1.0f) * 0.5f);
34  }
35 
36  vmml::Vector3d mapToSphere(const vmml::Vector2d NewPt);
37  vmml::Quaterniond calculateRotationQuat();
38  vmml::Matrix4d setRotationFromQuaternion(vmml::Quaterniond q1);
39 
40  void update();
41  void setClicked(bool _in);
42  void setZooming(bool _in);
43  void setMousePointer(float _x, float _y);
44 
45  void setPanning(bool _in);
46  void resetPanning();
47 
48  void setCenter(vmml::Vector3d);
49 
50  vmml::Vector3d getCenter();
51 
52  void resetZoom();
53  void setZoomFactorLimit(double _radius);
54 
55 
56 protected:
57  void calculateViewMatrix();
58 
59  vmml::Quaterniond rot_quat;
60  vmml::Vector3d lastVec;
61  vmml::Vector3d activeVec;
62 
63  vmml::Matrix4d activeRot;
64  vmml::Matrix4d lastRot;
65  vmml::Matrix4d zoomMatrix;
66  vmml::Vector2d activePan;
67  vmml::Vector2d lastPan;
68 
69  vmml::Matrix4d trans;
70  vmml::Vector3d center;
71 
72  double adjustWidth; //Mouse bounds width
73  double adjustHeight; //Mouse bounds height
74 
75  bool isRotating;
76  bool isDragging;
77  bool isPanning;
78 
79  double zoomfactor;
80 
81  vmml::Vector2d MousePt;
82  vmml::Vector2d firstMousePt;
83  vmml::Vector3d initPos;
84 
86  };
87 }
88 #endif
~ArcBallCamera()
Definition: ArcBallCamera.cpp:23
void clear()
Definition: ArcBallCamera.cpp:27
vmml::Vector2d firstMousePt
Definition: ArcBallCamera.h:82
vmml::Vector2d activePan
Definition: ArcBallCamera.h:66
void setMousePointer(float _x, float _y)
Definition: ArcBallCamera.cpp:158
vmml::Matrix4d activeRot
Definition: ArcBallCamera.h:63
void update()
Definition: ArcBallCamera.cpp:63
void setCenter(vmml::Vector3d)
Definition: ArcBallCamera.cpp:286
void setPanning(bool _in)
Definition: ArcBallCamera.cpp:274
vmml::Matrix4d zoomMatrix
Definition: ArcBallCamera.h:65
void setClicked(bool _in)
Definition: ArcBallCamera.cpp:149
vmml::Vector2d lastPan
Definition: ArcBallCamera.h:67
float zoomFactorLimit
Definition: ArcBallCamera.h:85
Definition: ArcBallCamera.h:19
vmml::Matrix4d lastRot
Definition: ArcBallCamera.h:64
bool isRotating
Definition: ArcBallCamera.h:75
vmml::Vector3d initPos
Definition: ArcBallCamera.h:83
vmml::Vector3d lastVec
Definition: ArcBallCamera.h:60
void setZoomFactorLimit(double _radius)
Definition: ArcBallCamera.cpp:226
vmml::Vector3d getCenter()
Definition: ArcBallCamera.cpp:290
vmml::Vector3d center
Definition: ArcBallCamera.h:70
void resetPanning()
Definition: ArcBallCamera.cpp:281
Definition: Camera.h:18
void setZooming(bool _in)
Definition: ArcBallCamera.cpp:238
vmml::Matrix4d trans
Definition: ArcBallCamera.h:69
vmml::Quaterniond calculateRotationQuat()
Definition: ArcBallCamera.cpp:120
vmml::Vector2d MousePt
Definition: ArcBallCamera.h:81
bool isPanning
Definition: ArcBallCamera.h:77
double adjustWidth
Definition: ArcBallCamera.h:72
bool isDragging
Definition: ArcBallCamera.h:76
vmml::Vector3d activeVec
Definition: ArcBallCamera.h:61
void create()
Definition: ArcBallCamera.h:25
vmml::Quaterniond rot_quat
Definition: ArcBallCamera.h:59
void setBounds(vmml::Vector2d _viewport)
Definition: ArcBallCamera.h:29
double zoomfactor
Definition: ArcBallCamera.h:79
Definition: ViewFrustum.h:18
Definition: AvalancheTrainingSimulationEngine.h:28
void calculateViewMatrix()
Definition: ArcBallCamera.cpp:294
ArcBallCamera()
Definition: ArcBallCamera.cpp:18
vmml::Vector3d mapToSphere(const vmml::Vector2d NewPt)
Definition: ArcBallCamera.cpp:89
void resetZoom()
Definition: ArcBallCamera.cpp:269
vmml::Matrix4d setRotationFromQuaternion(vmml::Quaterniond q1)
Definition: ArcBallCamera.cpp:202
double adjustHeight
Definition: ArcBallCamera.h:73