quaternion_demo.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 //
00006 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #ifndef EIGEN_QUATERNION_DEMO_H
00026 #define EIGEN_QUATERNION_DEMO_H
00027 
00028 #include "gpuhelper.h"
00029 #include "camera.h"
00030 #include "trackball.h"
00031 #include <map>
00032 #include <QTimer>
00033 #include <QtGui/QApplication>
00034 #include <QtOpenGL/QGLWidget>
00035 #include <QtGui/QMainWindow>
00036 
00037 class RenderingWidget : public QGLWidget
00038 {
00039   Q_OBJECT
00040 
00041     typedef std::map<float,Frame> TimeLine;
00042     TimeLine m_timeline;
00043     Frame lerpFrame(float t);
00044 
00045     Frame mInitFrame;
00046     bool mAnimate;
00047     float m_alpha;
00048 
00049     enum TrackMode {
00050       TM_NO_TRACK=0, TM_ROTATE_AROUND, TM_ZOOM,
00051       TM_LOCAL_ROTATE, TM_FLY_Z, TM_FLY_PAN
00052     };
00053 
00054     enum NavMode {
00055       NavTurnAround,
00056       NavFly
00057     };
00058 
00059     enum LerpMode {
00060       LerpQuaternion,
00061       LerpEulerAngles
00062     };
00063 
00064     enum RotationMode {
00065       RotationStable,
00066       RotationStandard
00067     };
00068 
00069     Camera mCamera;
00070     TrackMode mCurrentTrackingMode;
00071     NavMode mNavMode;
00072     LerpMode mLerpMode;
00073     RotationMode mRotationMode;
00074     Vector2i mMouseCoords;
00075     Trackball mTrackball;
00076 
00077     QTimer m_timer;
00078 
00079     void setupCamera();
00080 
00081     std::vector<Vector3f> mVertices;
00082     std::vector<Vector3f> mNormals;
00083     std::vector<int> mIndices;
00084 
00085   protected slots:
00086 
00087     virtual void animate(void);
00088     virtual void drawScene(void);
00089 
00090     virtual void grabFrame(void);
00091     virtual void stopAnimation();
00092 
00093     virtual void setNavMode(int);
00094     virtual void setLerpMode(int);
00095     virtual void setRotationMode(int);
00096     virtual void resetCamera();
00097 
00098   protected:
00099 
00100     virtual void initializeGL();
00101     virtual void resizeGL(int width, int height);
00102     virtual void paintGL();
00103     
00104     //--------------------------------------------------------------------------------
00105     virtual void mousePressEvent(QMouseEvent * e);
00106     virtual void mouseReleaseEvent(QMouseEvent * e);
00107     virtual void mouseMoveEvent(QMouseEvent * e);
00108     virtual void keyPressEvent(QKeyEvent * e);
00109     //--------------------------------------------------------------------------------
00110 
00111   public: 
00112     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00113     
00114     RenderingWidget();
00115     ~RenderingWidget() { }
00116 
00117     QWidget* createNavigationControlWidget();
00118 };
00119 
00120 class QuaternionDemo : public QMainWindow
00121 {
00122   Q_OBJECT
00123   public:
00124     QuaternionDemo();
00125   protected:
00126     RenderingWidget* mRenderingWidget;
00127 };
00128 
00129 #endif // EIGEN_QUATERNION_DEMO_H


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:32:17