unproject.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_OPENGL2_UNPROJECT_H
  9. #define IGL_OPENGL2_UNPROJECT_H
  10. #include "../igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. namespace opengl2
  15. {
  16. // Wrapper for gluUnproject that uses the current GL_MODELVIEW_MATRIX,
  17. // GL_PROJECTION_MATRIX, and GL_VIEWPORT
  18. // Inputs:
  19. // win* screen space x, y, and z coordinates respectively
  20. // Outputs:
  21. // obj* pointers to 3D objects' x, y, and z coordinates respectively
  22. // Returns return value of gluUnProject call
  23. IGL_INLINE void unproject(
  24. const double winX,
  25. const double winY,
  26. const double winZ,
  27. double* objX,
  28. double* objY,
  29. double* objZ);
  30. template <typename Derivedwin, typename Derivedobj>
  31. IGL_INLINE void unproject(
  32. const Eigen::PlainObjectBase<Derivedwin> & win,
  33. Eigen::PlainObjectBase<Derivedobj> & obj);
  34. template <typename Derivedwin>
  35. IGL_INLINE Eigen::PlainObjectBase<Derivedwin> unproject(
  36. const Eigen::PlainObjectBase<Derivedwin> & win);
  37. }
  38. }
  39. #ifndef IGL_STATIC_LIBRARY
  40. # include "unproject.cpp"
  41. #endif
  42. #endif