draw_mesh.h 4.5 KB

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