draw_mesh.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef IGL_DRAW_MESH_H
  2. #define IGL_DRAW_MESH_H
  3. #include "igl_inline.h"
  4. #include <Eigen/Dense>
  5. #if __APPLE__
  6. # include <OpenGL/gl.h>
  7. #else
  8. # ifdef _WIN32
  9. # define NOMINMAX
  10. # include <Windows.h>
  11. # undef NOMINMAX
  12. # endif
  13. # define GL_GLEXT_PROTOTYPES
  14. # include <GL/gl.h>
  15. # include <GL/glext.h>
  16. #endif
  17. namespace igl
  18. {
  19. // Draw OpenGL commands needed to display a mesh with normals
  20. //
  21. // Inputs:
  22. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  23. // F #F by 3 eigne Matrix of face (triangle) indices
  24. // N #V by 3 eigen Matrix of mesh vertex 3D normals
  25. IGL_INLINE void draw_mesh(
  26. const Eigen::MatrixXd & V,
  27. const Eigen::MatrixXi & F,
  28. const Eigen::MatrixXd & N);
  29. // Draw OpenGL commands needed to display a mesh with normals and per-vertex
  30. // colors
  31. //
  32. // Inputs:
  33. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  34. // F #F by 3 eigne Matrix of face (triangle) indices
  35. // N #V by 3 eigen Matrix of mesh vertex 3D normals
  36. // C #V by 3 eigen Matrix of mesh vertex RGB colors
  37. IGL_INLINE void draw_mesh(
  38. const Eigen::MatrixXd & V,
  39. const Eigen::MatrixXi & F,
  40. const Eigen::MatrixXd & N,
  41. const Eigen::MatrixXd & C);
  42. // Draw OpenGL commands needed to display a mesh with normals, per-vertex
  43. // colors and LBS weights
  44. //
  45. // Inputs:
  46. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  47. // F #F by 3 eigne Matrix of face (triangle) indices
  48. // N #V by 3 eigen Matrix of mesh vertex 3D normals
  49. // C #V by 3 eigen Matrix of mesh vertex RGB colors
  50. // TC #V by 3 eigen Matrix of mesh vertex UC coorindates between 0 and 1
  51. // W #V by #H eigen Matrix of per mesh vertex, per handle weights
  52. // W_index Specifies the index of the "weight" vertex attribute: see
  53. // glBindAttribLocation, if W_index is 0 then weights are ignored
  54. // WI #V by #H eigen Matrix of per mesh vertex, per handle weight ids
  55. // WI_index Specifies the index of the "weight" vertex attribute: see
  56. // glBindAttribLocation, if WI_index is 0 then weight indices are ignored
  57. IGL_INLINE void draw_mesh(
  58. const Eigen::MatrixXd & V,
  59. const Eigen::MatrixXi & F,
  60. const Eigen::MatrixXd & N,
  61. const Eigen::MatrixXd & C,
  62. const Eigen::MatrixXd & TC,
  63. const Eigen::MatrixXd & W,
  64. const GLuint W_index,
  65. const Eigen::MatrixXi & WI,
  66. const GLuint WI_index);
  67. // Draw OpenGL commands needed to display a mesh with normals, per-vertex
  68. // colors and LBS weights
  69. //
  70. // Inputs:
  71. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  72. // F #F by 3 eigne Matrix of face (triangle) indices
  73. // N #V by 3 eigen Matrix of mesh vertex 3D normals
  74. // NF #F by 3 eigen Matrix of face (triangle) normal indices, <0 means no
  75. // normal
  76. // C #V by 3 eigen Matrix of mesh vertex RGB colors
  77. // TC #V by 3 eigen Matrix of mesh vertex UC coorindates between 0 and 1
  78. // TF #F by 3 eigen Matrix of face (triangle) texture indices, <0 means no
  79. // texture
  80. // W #V by #H eigen Matrix of per mesh vertex, per handle weights
  81. // W_index Specifies the index of the "weight" vertex attribute: see
  82. // glBindAttribLocation, if W_index is 0 then weights are ignored
  83. // WI #V by #H eigen Matrix of per mesh vertex, per handle weight ids
  84. // WI_index Specifies the index of the "weight" vertex attribute: see
  85. // glBindAttribLocation, if WI_index is 0 then weight indices are ignored
  86. IGL_INLINE void draw_mesh(
  87. const Eigen::MatrixXd & V,
  88. const Eigen::MatrixXi & F,
  89. const Eigen::MatrixXd & N,
  90. const Eigen::MatrixXi & NF,
  91. const Eigen::MatrixXd & C,
  92. const Eigen::MatrixXd & TC,
  93. const Eigen::MatrixXi & TF,
  94. const Eigen::MatrixXd & W,
  95. const GLuint W_index,
  96. const Eigen::MatrixXi & WI,
  97. const GLuint WI_index);
  98. }
  99. #ifdef IGL_HEADER_ONLY
  100. # include "draw_mesh.cpp"
  101. #endif
  102. #endif