unproject_onto_mesh.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_EMBREE_UNPROJECT_ONTO_MESH_H
  9. #define IGL_EMBREE_UNPROJECT_ONTO_MESH_H
  10. #include <igl/igl_inline.h>
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl
  14. {
  15. namespace embree
  16. {
  17. // Forward define
  18. class EmbreeIntersector;
  19. // Unproject a screen location (using the given model, proj and viewport) to find
  20. // the first hit on a mesh.
  21. //
  22. // Inputs:
  23. // pos screen space coordinates
  24. // F #F by 3 face matrix
  25. // model model matrix
  26. // proj projection matrix
  27. // viewport vieweport vector
  28. // ei EmbreeIntersector containing (V,F)
  29. // Outputs:
  30. // fid id of the first face hit
  31. // bc barycentric coordinates of hit
  32. // Returns true if there is a hit
  33. IGL_INLINE bool unproject_onto_mesh(
  34. const Eigen::Vector2f& pos,
  35. const Eigen::MatrixXi& F,
  36. const Eigen::Matrix4f& model,
  37. const Eigen::Matrix4f& proj,
  38. const Eigen::Vector4f& viewport,
  39. const EmbreeIntersector & ei,
  40. int& fid,
  41. Eigen::Vector3f& bc);
  42. // Unproject a screen location (using the given model, proj and viewport) to find
  43. // the first face on the mesh and the closest vertex
  44. //
  45. // Inputs:
  46. // pos screen space coordinates
  47. // F #F by 3 face matrix
  48. // model model matrix
  49. // proj projection matrix
  50. // viewport vieweport vector
  51. // ei EmbreeIntersector containing (V,F)
  52. // Outputs:
  53. // fid id of the first face hit
  54. // vid vertex id of the closest vertex hit
  55. // Returns true if there is a hit
  56. IGL_INLINE bool unproject_onto_mesh(
  57. const Eigen::Vector2f& pos,
  58. const Eigen::MatrixXi& F,
  59. const Eigen::Matrix4f& model,
  60. const Eigen::Matrix4f& proj,
  61. const Eigen::Vector4f& viewport,
  62. const EmbreeIntersector & ei,
  63. int& fid,
  64. int& vid);
  65. }
  66. }
  67. #ifndef IGL_STATIC_LIBRARY
  68. # include "unproject_onto_mesh.cpp"
  69. #endif
  70. #endif