draw_mesh.h 3.9 KB

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