BeachBall.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef BEACHBALL_H
  2. #define BEACHBALL_H
  3. class BeachBall
  4. {
  5. public:
  6. static double * scene_rot;
  7. public:
  8. // Rigid transformation: rotation as quaternion
  9. double r[4];
  10. // Rigid transformation: translation as quaternion
  11. double t[4];
  12. double radius;
  13. protected:
  14. bool is_hover;
  15. bool is_down;
  16. // trackball
  17. bool trackball_on;
  18. // Rigid transformation at down
  19. double down_r[4];
  20. double down_t[4];
  21. // query position at down
  22. int down_x;
  23. int down_y;
  24. // modelview matrix at draw
  25. double mv[16];
  26. public:
  27. BeachBall();
  28. // Push the latest modelview matrix seen at draw time onto the stack
  29. void pushmv() const;
  30. // Pop the stack
  31. void popmv() const;
  32. // Push rigid transformation onto the stack
  33. void push() const;
  34. // Pop the stack
  35. void pop() const;
  36. // Draw and cache the modelview matrix
  37. void draw();
  38. // Return whether (x,y) in screenspace is "inside" (hitting)
  39. bool in(const int x,const int y) const;
  40. // Called on passive mouse move to (x,y)
  41. //
  42. // Return whether (x,y) is hovering over, set is_hover accordingly
  43. bool hover(const int x,const int y);
  44. // Called on mouse down at (x,y)
  45. //
  46. // Return whether (x,y) is down, set is_down accordingly
  47. bool down(const int x,const int y);
  48. // Called on mouse drag to (x,y)
  49. //
  50. // Returns whether still is_down
  51. bool drag(const int x,const int y);
  52. // Called on right mouse down at (x,y)
  53. //
  54. // Return whether (x,y) is down, set is_down accordingly
  55. bool right_down(const int x,const int y);
  56. // Called on mouse up at (x,y)
  57. //
  58. // Returns whether still is_down
  59. bool up(const int x,const int y);
  60. };
  61. #endif