unproject_onto_mesh.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. //
  33. // Known bugs: This should return the barycentric coordinates in F(fid,:)
  34. // rather than vid.
  35. IGL_INLINE bool unproject_onto_mesh(
  36. const Eigen::Vector2f& pos,
  37. const Eigen::MatrixXi& F,
  38. const Eigen::Matrix4f& model,
  39. const Eigen::Matrix4f& proj,
  40. const Eigen::Vector4f& viewport,
  41. const igl::EmbreeIntersector & ei,
  42. int& fid,
  43. int& vid);
  44. }
  45. #ifndef IGL_STATIC_LIBRARY
  46. # include "unproject_onto_mesh.cpp"
  47. #endif
  48. #endif