view_axis.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include "view_axis.h"
  9. #include "../opengl/OpenGL_convenience.h"
  10. IGL_INLINE void igl::opengl2::view_axis(double * x, double * y, double * z)
  11. {
  12. double mv[16];
  13. glGetDoublev(GL_MODELVIEW_MATRIX, mv);
  14. igl::opengl2::view_axis(mv,x,y,z);
  15. }
  16. IGL_INLINE void igl::opengl2::view_axis(const double * mv, double * x, double * y, double * z)
  17. {
  18. *x = -mv[0*4+2];
  19. *y = -mv[1*4+2];
  20. *z = -mv[2*4+2];
  21. }
  22. template <typename DerivedV>
  23. IGL_INLINE void igl::opengl2::view_axis(Eigen::PlainObjectBase<DerivedV> & V)
  24. {
  25. double x,y,z;
  26. view_axis(&x,&y,&z);
  27. V(0) = x;
  28. V(1) = y;
  29. V(2) = z;
  30. }
  31. #ifdef IGL_STATIC_LIBRARY
  32. // Explicit template specialization
  33. // generated by autoexplicit.sh
  34. template void igl::opengl2::view_axis<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
  35. template void igl::opengl2::view_axis<Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&);
  36. #endif