map_texture.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef IGL_OPENGL_GLFW_MAP_TEXTURE_H
  2. #define IGL_OPENGL_GLFW_MAP_TEXTURE_H
  3. #include "../../igl_inline.h"
  4. #include <Eigen/Core>
  5. #include <vector>
  6. namespace igl
  7. {
  8. namespace opengl
  9. {
  10. namespace glfw
  11. {
  12. // Given a mesh (V,F) in [0,1]² and new positions (U) and a texture image
  13. // (in_data), _render_ a new image (out_data) of the same size.
  14. // Inputs:
  15. // V #V by 2 list of undeformed mesh vertex positions (matching texture)
  16. // F #F by 3 list of mesh triangle indices into V
  17. // U #U by 2 list of deformed vertex positions
  18. // in_data w*h*nc array of color values, channels, then columns, then
  19. // rows (e.g., what stbi_image returns and expects)
  20. // w width
  21. // h height
  22. // nc number of channels
  23. // Outputs:
  24. // out_data h*w*nc list of output colors in same order as input
  25. //
  26. template <typename DerivedV, typename DerivedF, typename DerivedU>
  27. IGL_INLINE bool map_texture(
  28. const Eigen::MatrixBase<DerivedV> & V,
  29. const Eigen::MatrixBase<DerivedF> & F,
  30. const Eigen::MatrixBase<DerivedU> & U,
  31. const unsigned char * in_data,
  32. const int w,
  33. const int h,
  34. const int nc,
  35. std::vector<unsigned char> & out_data);
  36. template <typename DerivedV, typename DerivedF, typename DerivedU>
  37. IGL_INLINE bool map_texture(
  38. const Eigen::MatrixBase<DerivedV> & _V,
  39. const Eigen::MatrixBase<DerivedF> & _F,
  40. const Eigen::MatrixBase<DerivedU> & _U,
  41. const unsigned char * in_data,
  42. const int w,
  43. const int h,
  44. const int nc,
  45. std::vector<unsigned char> & out_data,
  46. int & out_w,
  47. int & out_h,
  48. int & out_nc);
  49. }
  50. }
  51. }
  52. #ifndef IGL_STATIC_LIBRARY
  53. # include "map_texture.cpp"
  54. #endif
  55. #endif