ViewerCore.h 2.9 KB

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