ViewerCore.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef IGL_VIEWER_CORE_H
  2. #define IGL_VIEWER_CORE_H
  3. #include <igl/igl_inline.h>
  4. #include <igl/viewer/TextRenderer.h>
  5. #include <igl/viewer/ViewerData.h>
  6. #include <igl/viewer/OpenGL_state.h>
  7. namespace igl
  8. {
  9. class ViewerCore
  10. #ifdef ENABLE_XML_SERIALIZATION
  11. : public ::igl::XMLSerialization
  12. #endif
  13. {
  14. public:
  15. IGL_INLINE ViewerCore();
  16. IGL_INLINE void init();
  17. IGL_INLINE void shut();
  18. IGL_INLINE void InitSerialization();
  19. IGL_INLINE void align_camera_center(const Eigen::MatrixXd& V); // Adjust the view to see the entire model
  20. // Determines how much to zoom and shift such that the mesh fills the unit
  21. // box (centered at the origin)
  22. IGL_INLINE void get_scale_and_shift_to_fit_mesh(
  23. const Eigen::MatrixXd& V,
  24. float & zoom,
  25. Eigen::Vector3f& shift);
  26. IGL_INLINE void clear_framebuffers();
  27. // Draw everything
  28. IGL_INLINE void draw(ViewerData& data, OpenGL_state& opengl);
  29. TextRenderer textrenderer;
  30. // Shape material
  31. float shininess;
  32. // Colors
  33. Eigen::Vector3f background_color;
  34. Eigen::Vector3f line_color;
  35. // Lighting
  36. Eigen::Vector3f light_position;
  37. float lighting_factor;
  38. // Trackball angle (quaternion)
  39. Eigen::Vector4f trackball_angle;
  40. // Model viewing parameters
  41. float model_zoom;
  42. Eigen::Vector3f model_translation;
  43. // Model viewing paramters (uv coordinates)
  44. float model_zoom_uv;
  45. Eigen::Vector3f model_translation_uv;
  46. // Camera parameters
  47. float camera_zoom;
  48. bool orthographic;
  49. Eigen::Vector3f camera_eye;
  50. Eigen::Vector3f camera_up;
  51. Eigen::Vector3f camera_center;
  52. float camera_view_angle;
  53. float camera_dnear;
  54. float camera_dfar;
  55. // Visualization options
  56. bool show_overlay;
  57. bool show_overlay_depth;
  58. bool show_texture;
  59. bool show_faces;
  60. bool show_lines;
  61. bool show_vertid;
  62. bool show_faceid;
  63. bool invert_normals;
  64. // Point size / line width
  65. float point_size;
  66. float line_width;
  67. // Animation
  68. bool is_animating;
  69. double animation_max_fps;
  70. // Caches the two-norm between the min/max point of the bounding box
  71. float object_scale;
  72. // Window size
  73. Eigen::Vector4f viewport;
  74. // Save the OpenGL transformation matrices used for the previous rendering pass
  75. Eigen::Matrix4f view;
  76. Eigen::Matrix4f model;
  77. Eigen::Matrix4f proj;
  78. };
  79. }
  80. #ifndef IGL_STATIC_LIBRARY
  81. # include "ViewerCore.cpp"
  82. #endif
  83. #endif