draw_mesh.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@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_OPENGL2_DRAW_MESH_H
  9. #define IGL_OPENGL2_DRAW_MESH_H
  10. #include "../igl_inline.h"
  11. #include <Eigen/Dense>
  12. #include "../opengl/OpenGL_convenience.h"
  13. namespace igl
  14. {
  15. namespace opengl2
  16. {
  17. // Draw ../opengl/OpenGL_ commands needed to display a mesh with normals
  18. //
  19. // Inputs:
  20. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  21. // F #F by 3|4 eigen Matrix of face (triangle/quad) indices
  22. // N #V|#F by 3 eigen Matrix of 3D normals
  23. IGL_INLINE void draw_mesh(
  24. const Eigen::MatrixXd & V,
  25. const Eigen::MatrixXi & F,
  26. const Eigen::MatrixXd & N);
  27. // Draw ../opengl/OpenGL_ commands needed to display a mesh with normals and per-vertex
  28. // colors
  29. //
  30. // Inputs:
  31. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  32. // F #F by 3|4 eigen Matrix of face (triangle/quad) indices
  33. // N #V|#F by 3 eigen Matrix of 3D normals
  34. // C #V|#F|1 by 3 eigen Matrix of RGB colors
  35. IGL_INLINE void draw_mesh(
  36. const Eigen::MatrixXd & V,
  37. const Eigen::MatrixXi & F,
  38. const Eigen::MatrixXd & N,
  39. const Eigen::MatrixXd & C);
  40. // Inputs:
  41. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  42. // F #F by 3|4 eigen Matrix of face (triangle/quad) indices
  43. // N #V|#F by 3 eigen Matrix of 3D normals
  44. // C #V|#F|1 by 3 eigen Matrix of RGB colors
  45. // TC #V|#F|1 by 3 eigen Matrix of Texture Coordinates
  46. IGL_INLINE void draw_mesh(
  47. const Eigen::MatrixXd & V,
  48. const Eigen::MatrixXi & F,
  49. const Eigen::MatrixXd & N,
  50. const Eigen::MatrixXd & C,
  51. const Eigen::MatrixXd & TC);
  52. // Draw ../opengl/OpenGL_ commands needed to display a mesh with normals, per-vertex
  53. // colors and LBS weights
  54. //
  55. // Inputs:
  56. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  57. // F #F by 3|4 eigen Matrix of face (triangle/quad) indices
  58. // N #V by 3 eigen Matrix of mesh vertex 3D normals
  59. // C #V by 3 eigen Matrix of mesh vertex RGB colors
  60. // TC #V by 3 eigen Matrix of mesh vertex UC coorindates between 0 and 1
  61. // W #V by #H eigen Matrix of per mesh vertex, per handle weights
  62. // W_index Specifies the index of the "weight" vertex attribute: see
  63. // glBindAttribLocation, if W_index is 0 then weights are ignored
  64. // WI #V by #H eigen Matrix of per mesh vertex, per handle weight ids
  65. // WI_index Specifies the index of the "weight" vertex attribute: see
  66. // glBindAttribLocation, if WI_index is 0 then weight indices are ignored
  67. IGL_INLINE void draw_mesh(
  68. const Eigen::MatrixXd & V,
  69. const Eigen::MatrixXi & F,
  70. const Eigen::MatrixXd & N,
  71. const Eigen::MatrixXd & C,
  72. const Eigen::MatrixXd & TC,
  73. const Eigen::MatrixXd & W,
  74. const GLuint W_index,
  75. const Eigen::MatrixXi & WI,
  76. const GLuint WI_index);
  77. // Draw ../opengl/OpenGL_ commands needed to display a mesh with normals, per-vertex
  78. // colors and LBS weights
  79. //
  80. // Inputs:
  81. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  82. // F #F by 3|4 eigen Matrix of face (triangle/quad) indices
  83. // N #V by 3 eigen Matrix of mesh vertex 3D normals
  84. // NF #F by 3 eigen Matrix of face (triangle/quad) normal indices, <0
  85. // means no normal
  86. // C #V by 3 eigen Matrix of mesh vertex RGB colors
  87. // TC #V by 3 eigen Matrix of mesh vertex UC coorindates between 0 and 1
  88. // TF #F by 3 eigen Matrix of face (triangle/quad) texture indices, <0
  89. // means no texture
  90. // W #V by #H eigen Matrix of per mesh vertex, per handle weights
  91. // W_index Specifies the index of the "weight" vertex attribute: see
  92. // glBindAttribLocation, if W_index is 0 then weights are ignored
  93. // WI #V by #H eigen Matrix of per mesh vertex, per handle weight ids
  94. // WI_index Specifies the index of the "weight" vertex attribute: see
  95. // glBindAttribLocation, if WI_index is 0 then weight indices are ignored
  96. IGL_INLINE void draw_mesh(
  97. const Eigen::MatrixXd & V,
  98. const Eigen::MatrixXi & F,
  99. const Eigen::MatrixXd & N,
  100. const Eigen::MatrixXi & NF,
  101. const Eigen::MatrixXd & C,
  102. const Eigen::MatrixXd & TC,
  103. const Eigen::MatrixXi & TF,
  104. const Eigen::MatrixXd & W,
  105. const GLuint W_index,
  106. const Eigen::MatrixXi & WI,
  107. const GLuint WI_index);
  108. }
  109. }
  110. #ifndef IGL_STATIC_LIBRARY
  111. # include "draw_mesh.cpp"
  112. #endif
  113. #endif