123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- // This file is part of libigl, a simple c++ geometry processing library.
- //
- // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
- //
- // This Source Code Form is subject to the terms of the Mozilla Public License
- // v. 2.0. If a copy of the MPL was not distributed with this file, You can
- // obtain one at http://mozilla.org/MPL/2.0/.
- #ifndef IGL_UNPROJECT_IN_MESH
- #define IGL_UNPROJECT_IN_MESH
- #include <igl/igl_inline.h>
- #include <Eigen/Core>
- #include <vector>
- #include "Hit.h"
- namespace igl
- {
- // Forward define
- class EmbreeIntersector;
- #ifndef IGL_OPENGL_4
- // Unproject a screen location (using current opengl viewport, projection, and
- // model view) to a 3D position
- //
- // Inputs:
- // x x-coordinate of mouse location
- // y y-coordinate of mouse location
- // ei EmbreeIntersector containing (V,F)
- // Outputs:
- // obj 3d unprojected mouse point in mesh
- // Returns number of hits
- //
- template <
- typename Derivedobj>
- IGL_INLINE int unproject_in_mesh(
- const int x,
- const int y,
- const igl::EmbreeIntersector & ei,
- Eigen::PlainObjectBase<Derivedobj> & obj);
- template <
- typename Derivedobj>
- IGL_INLINE int unproject_in_mesh(
- const int x,
- const int y,
- const igl::EmbreeIntersector & ei,
- Eigen::PlainObjectBase<Derivedobj> & obj,
- std::vector<igl::Hit > & hits);
- #endif
- // Unproject a screen location (using the given model, proj and viewewport) to a 3D position
- // and a set of hits
- //
- // Inputs:
- // pos screen space coordinates
- // model model matrix
- // proj projection matrix
- // viewport vieweport vector
- // ei EmbreeIntersector containing (V,F)
- // Outputs:
- // obj 3d unprojected mouse point in mesh
- // hits vector of embree hits
- // Returns number of hits
- template <
- typename Derivedobj>
- IGL_INLINE int unproject_in_mesh(
- const Eigen::Vector2f& pos,
- const Eigen::Matrix4f& model,
- const Eigen::Matrix4f& proj,
- const Eigen::Vector4f& viewport,
- const igl::EmbreeIntersector & ei,
- Eigen::PlainObjectBase<Derivedobj> & obj,
- std::vector<igl::Hit > & hits);
- // Unproject a screen location (using the given model, proj and viewewport) to a 3D position
- // and a set of hits
- //
- // Inputs:
- // pos screen space coordinates
- // F #F by 3 face matrix
- // model model matrix
- // proj projection matrix
- // viewport vieweport vector
- // ei EmbreeIntersector containing (V,F)
- // Outputs:
- // fid id of the first face hit
- // vid vertex id of the closest vertex hit
- // Returns true if there is a hit
- IGL_INLINE bool unproject_in_mesh(
- const Eigen::Vector2f& pos,
- const Eigen::MatrixXi& F,
- const Eigen::Matrix4f& model,
- const Eigen::Matrix4f& proj,
- const Eigen::Vector4f& viewport,
- const igl::EmbreeIntersector & ei,
- int& fid,
- int& vid);
- }
- #ifndef IGL_STATIC_LIBRARY
- # include "unproject_in_mesh.cpp"
- #endif
- #endif
|