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.

42 lines
943 B

  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_TRACKBALL_H
  10. #define EIGEN_TRACKBALL_H
  11. #include <Eigen/Geometry>
  12. class Camera;
  13. class Trackball
  14. {
  15. public:
  16. enum Mode {Around, Local};
  17. Trackball() : mpCamera(0) {}
  18. void start(Mode m = Around) { mMode = m; mLastPointOk = false; }
  19. void setCamera(Camera* pCam) { mpCamera = pCam; }
  20. void track(const Eigen::Vector2i& newPoint2D);
  21. protected:
  22. bool mapToSphere( const Eigen::Vector2i& p2, Eigen::Vector3f& v3);
  23. Camera* mpCamera;
  24. Eigen::Vector3f mLastPoint3D;
  25. Mode mMode;
  26. bool mLastPointOk;
  27. };
  28. #endif // EIGEN_TRACKBALL_H