You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
2.6 KiB

  1. // This file is part of Eigen, a lightweight C++ template library
  2. // for linear algebra.
  3. //
  4. // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
  5. //
  6. // This Source Code Form is subject to the terms of the Mozilla
  7. // Public License v. 2.0. If a copy of the MPL was not distributed
  8. // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. #ifndef EIGEN_QUATERNION_DEMO_H
  10. #define EIGEN_QUATERNION_DEMO_H
  11. #include "gpuhelper.h"
  12. #include "camera.h"
  13. #include "trackball.h"
  14. #include <map>
  15. #include <QTimer>
  16. #include <QtGui/QApplication>
  17. #include <QtOpenGL/QGLWidget>
  18. #include <QtGui/QMainWindow>
  19. class RenderingWidget : public QGLWidget
  20. {
  21. Q_OBJECT
  22. typedef std::map<float,Frame> TimeLine;
  23. TimeLine m_timeline;
  24. Frame lerpFrame(float t);
  25. Frame mInitFrame;
  26. bool mAnimate;
  27. float m_alpha;
  28. enum TrackMode {
  29. TM_NO_TRACK=0, TM_ROTATE_AROUND, TM_ZOOM,
  30. TM_LOCAL_ROTATE, TM_FLY_Z, TM_FLY_PAN
  31. };
  32. enum NavMode {
  33. NavTurnAround,
  34. NavFly
  35. };
  36. enum LerpMode {
  37. LerpQuaternion,
  38. LerpEulerAngles
  39. };
  40. enum RotationMode {
  41. RotationStable,
  42. RotationStandard
  43. };
  44. Camera mCamera;
  45. TrackMode mCurrentTrackingMode;
  46. NavMode mNavMode;
  47. LerpMode mLerpMode;
  48. RotationMode mRotationMode;
  49. Vector2i mMouseCoords;
  50. Trackball mTrackball;
  51. QTimer m_timer;
  52. void setupCamera();
  53. std::vector<Vector3f> mVertices;
  54. std::vector<Vector3f> mNormals;
  55. std::vector<int> mIndices;
  56. protected slots:
  57. virtual void animate(void);
  58. virtual void drawScene(void);
  59. virtual void grabFrame(void);
  60. virtual void stopAnimation();
  61. virtual void setNavMode(int);
  62. virtual void setLerpMode(int);
  63. virtual void setRotationMode(int);
  64. virtual void resetCamera();
  65. protected:
  66. virtual void initializeGL();
  67. virtual void resizeGL(int width, int height);
  68. virtual void paintGL();
  69. //--------------------------------------------------------------------------------
  70. virtual void mousePressEvent(QMouseEvent * e);
  71. virtual void mouseReleaseEvent(QMouseEvent * e);
  72. virtual void mouseMoveEvent(QMouseEvent * e);
  73. virtual void keyPressEvent(QKeyEvent * e);
  74. //--------------------------------------------------------------------------------
  75. public:
  76. EIGEN_MAKE_ALIGNED_OPERATOR_NEW
  77. RenderingWidget();
  78. ~RenderingWidget() { }
  79. QWidget* createNavigationControlWidget();
  80. };
  81. class QuaternionDemo : public QMainWindow
  82. {
  83. Q_OBJECT
  84. public:
  85. QuaternionDemo();
  86. protected:
  87. RenderingWidget* mRenderingWidget;
  88. };
  89. #endif // EIGEN_QUATERNION_DEMO_H