ViewerCore.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@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_VIEWER_CORE_H
  9. #define IGL_VIEWER_CORE_H
  10. #include <vector>
  11. #include <igl/igl_inline.h>
  12. #include <igl/viewer/TextRenderer.h>
  13. #include <igl/viewer/ViewerData.h>
  14. #include <igl/viewer/OpenGL_state.h>
  15. namespace igl
  16. {
  17. // Basic class of the 3D mesh viewer
  18. // TODO: write documentation
  19. class ViewerCore
  20. #ifdef ENABLE_XML_SERIALIZATION
  21. : public ::igl::XMLSerialization
  22. #endif
  23. {
  24. public:
  25. IGL_INLINE ViewerCore();
  26. // Initialization
  27. IGL_INLINE void init();
  28. // Shutdown
  29. IGL_INLINE void shut();
  30. // Serialization code
  31. IGL_INLINE void InitSerialization();
  32. // ------------------- Camera control functions
  33. // Adjust the view to see the entire model
  34. IGL_INLINE void align_camera_center(
  35. const Eigen::MatrixXd& V,
  36. const Eigen::MatrixXi& F);
  37. // Determines how much to zoom and shift such that the mesh fills the unit
  38. // box (centered at the origin)
  39. IGL_INLINE void get_scale_and_shift_to_fit_mesh(
  40. const Eigen::MatrixXd& V,
  41. const Eigen::MatrixXi& F,
  42. float & zoom,
  43. Eigen::Vector3f& shift);
  44. // ------------------- Drawing functions
  45. // Clear the frame buffers
  46. IGL_INLINE void clear_framebuffers();
  47. // Draw everything
  48. IGL_INLINE void draw(ViewerData& data, OpenGL_state& opengl);
  49. // ------------------- Properties
  50. // Text rendering helper
  51. TextRenderer textrenderer;
  52. // Shape material
  53. float shininess;
  54. // Colors
  55. Eigen::Vector3f background_color;
  56. Eigen::Vector3f line_color;
  57. // Lighting
  58. Eigen::Vector3f light_position;
  59. float lighting_factor;
  60. // Trackball angle (quaternion)
  61. Eigen::Vector4f trackball_angle;
  62. // Model viewing parameters
  63. float model_zoom;
  64. Eigen::Vector3f model_translation;
  65. // Model viewing paramters (uv coordinates)
  66. float model_zoom_uv;
  67. Eigen::Vector3f model_translation_uv;
  68. // Camera parameters
  69. float camera_zoom;
  70. bool orthographic;
  71. Eigen::Vector3f camera_eye;
  72. Eigen::Vector3f camera_up;
  73. Eigen::Vector3f camera_center;
  74. float camera_view_angle;
  75. float camera_dnear;
  76. float camera_dfar;
  77. // Visualization options
  78. bool show_overlay;
  79. bool show_overlay_depth;
  80. bool show_texture;
  81. bool show_faces;
  82. bool show_lines;
  83. bool show_vertid;
  84. bool show_faceid;
  85. bool invert_normals;
  86. // Point size / line width
  87. float point_size;
  88. float line_width;
  89. // Animation
  90. bool is_animating;
  91. double animation_max_fps;
  92. // Caches the two-norm between the min/max point of the bounding box
  93. float object_scale;
  94. // Viewport size
  95. Eigen::Vector4f viewport;
  96. // Save the OpenGL transformation matrices used for the previous rendering pass
  97. Eigen::Matrix4f view;
  98. Eigen::Matrix4f model;
  99. Eigen::Matrix4f proj;
  100. };
  101. }
  102. #ifndef IGL_STATIC_LIBRARY
  103. # include "ViewerCore.cpp"
  104. #endif
  105. #endif