Arc Ball
Arc ball 3D transformation
|
00001 #ifndef IAUNS_ARC_BALL_H 00002 #define IAUNS_ARC_BALL_H 00003 00004 #include <stdint.h> 00005 00006 #include <glm/glm.hpp> 00007 #include <glm/gtc/quaternion.hpp> 00008 #include <glm/gtc/type_ptr.hpp> 00009 #include <glm/gtc/matrix_inverse.hpp> 00010 #include <glm/gtc/matrix_transform.hpp> 00011 00012 namespace CPM_ARC_BALL_NS { 00013 00025 class ArcBall 00026 { 00027 public: 00036 ArcBall(const glm::vec3& center, glm::float_t radius, 00037 const glm::mat4& screenToTCS = glm::mat4()); 00038 virtual ~ArcBall(); 00039 00042 void beginDrag(const glm::vec2& mouseScreenCoords); 00043 00046 void drag(const glm::vec2& mouseScreenCoords); 00047 00054 glm::mat4 getTransformation() const; 00055 00056 private: 00057 00060 glm::vec3 mouseOnSphere(const glm::vec3& tscMouse); 00061 00063 static glm::quat quatFromUnitSphere(const glm::vec3& from, const glm::vec3& to); 00064 00065 glm::vec3 mCenter; 00066 glm::float_t mRadius; 00067 00068 glm::quat mQNow; 00069 00070 00071 glm::quat mQDown; 00072 glm::quat mQDrag; 00073 00074 00075 glm::vec3 mVNow; 00076 glm::vec3 mVDown; 00077 glm::vec3 mVSphereFrom; 00078 glm::vec3 mVSphereTo; 00079 00080 glm::mat4 mMatNow; 00081 00083 glm::mat4 mScreenToTCS; 00084 }; 00085 00086 } // namespace CPM_ARC_BALL_NS 00087 00088 #endif