unproject_onto_mesh.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 hit on a mesh.
  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. // bc barycentric coordinates of 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. Eigen::Vector3f& bc);
  41. // Unproject a screen location (using the given model, proj and viewport) to find
  42. // the first face on the mesh and the closest vertex
  43. //
  44. // Inputs:
  45. // pos screen space coordinates
  46. // F #F by 3 face matrix
  47. // model model matrix
  48. // proj projection matrix
  49. // viewport vieweport vector
  50. // ei EmbreeIntersector containing (V,F)
  51. // Outputs:
  52. // fid id of the first face hit
  53. // vid vertex id of the closest vertex hit
  54. // Returns true if there is a hit
  55. IGL_INLINE bool unproject_onto_mesh(
  56. const Eigen::Vector2f& pos,
  57. const Eigen::MatrixXi& F,
  58. const Eigen::Matrix4f& model,
  59. const Eigen::Matrix4f& proj,
  60. const Eigen::Vector4f& viewport,
  61. const igl::EmbreeIntersector & ei,
  62. int& fid,
  63. int& vid);
  64. }
  65. #ifndef IGL_STATIC_LIBRARY
  66. # include "unproject_onto_mesh.cpp"
  67. #endif
  68. #endif