unproject_onto_mesh.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@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_UNPROJECT_ONTO_MESH
  9. #define IGL_UNPROJECT_ONTO_MESH
  10. #include <igl/igl_inline.h>
  11. #include <Eigen/Core>
  12. #include <vector>
  13. #include "Hit.h"
  14. namespace igl
  15. {
  16. // Forward define
  17. class EmbreeIntersector;
  18. // Unproject a screen location (using the given model, proj and viewport) to find
  19. // the first face on the mesh and the closest vertex
  20. //
  21. // Inputs:
  22. // pos screen space coordinates
  23. // F #F by 3 face matrix
  24. // model model matrix
  25. // proj projection matrix
  26. // viewport vieweport vector
  27. // ei EmbreeIntersector containing (V,F)
  28. // Outputs:
  29. // fid id of the first face hit
  30. // vid vertex id of the closest vertex hit
  31. // Returns true if there is a hit
  32. IGL_INLINE bool unproject_onto_mesh(
  33. const Eigen::Vector2f& pos,
  34. const Eigen::MatrixXi& F,
  35. const Eigen::Matrix4f& model,
  36. const Eigen::Matrix4f& proj,
  37. const Eigen::Vector4f& viewport,
  38. const igl::EmbreeIntersector & ei,
  39. int& fid,
  40. int& vid);
  41. }
  42. #ifndef IGL_STATIC_LIBRARY
  43. # include "unproject_onto_mesh.cpp"
  44. #endif
  45. #endif