aboutsummaryrefslogtreecommitdiffhomepage
path: root/demos/opengl/trackball.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2008-09-07 23:15:11 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2008-09-07 23:15:11 +0000
commit31c33b9ed44b351127b7b4da317dc5ab69670b6f (patch)
tree25801b4829a548485e51124cdebe11deb6f58595 /demos/opengl/trackball.h
parent12e9de4abbe9a4cf9b2812e700ce41bdd0351cb3 (diff)
started a small OpenGL demo making use of Eigen's geometry features
Diffstat (limited to 'demos/opengl/trackball.h')
-rw-r--r--demos/opengl/trackball.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/demos/opengl/trackball.h b/demos/opengl/trackball.h
new file mode 100644
index 000000000..29413becd
--- /dev/null
+++ b/demos/opengl/trackball.h
@@ -0,0 +1,55 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra. Eigen itself is part of the KDE project.
+//
+// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_TRACKBALL_H
+#define EIGEN_TRACKBALL_H
+
+#include <Eigen/Geometry>
+
+class Camera;
+
+class Trackball
+{
+ public:
+
+ Trackball() : mpCamera(0) {}
+
+ void reset() { mLastPointOk = false; }
+
+ void setCamera(Camera* pCam) { mpCamera = pCam; }
+
+ void track(const Eigen::Vector2i& newPoint2D);
+
+ protected:
+
+ bool mapToSphere( const Eigen::Vector2i& p2, Eigen::Vector3f& v3);
+
+ Camera* mpCamera;
+ Eigen::Vector2i mLastPoint2D;
+ Eigen::Vector3f mLastPoint3D;
+ bool mLastPointOk;
+
+};
+
+#endif // EIGEN_TRACKBALL_H