render_scene.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef DEPTHGUIDE_RENDER_SCENE_H
  2. #define DEPTHGUIDE_RENDER_SCENE_H
  3. #include "core/image_utility_v2.h"
  4. #include "render_mesh.h"
  5. #include <variant>
  6. struct camera_info {
  7. glm::mat4 transform; // standard camera transform
  8. GLfloat fov = 60.0f; // field of view (degree)
  9. GLfloat near = 10.0f;
  10. GLfloat far = 1000.0f; // clip range (mm)
  11. glm::mat4 projection(float aspect) const;
  12. };
  13. struct scene_render_info {
  14. struct image_info {
  15. image_ptr img = nullptr;
  16. image_ptr depth = nullptr;
  17. bool flip_y = false;
  18. };
  19. struct mesh_info {
  20. mesh_ptr mesh = nullptr;
  21. material_type material = {};
  22. bool enable_depth_alpha = false;
  23. float alpha_factor = 0.1;
  24. };
  25. struct pc_info {
  26. pc_ptr pc = nullptr;
  27. GLfloat point_size = 1.0f;
  28. glm::vec3 color = glm::vec3(0.5f);
  29. };
  30. struct custom_info {
  31. std::function<void()> func;
  32. };
  33. struct line_info {
  34. glm::vec3 p1, p2; // in world coordinate
  35. glm::vec3 color;
  36. float line_width;
  37. };
  38. struct item_type {
  39. using item_store_type = std::variant<std::monostate,
  40. image_info, mesh_info, pc_info, custom_info, line_info>;
  41. item_store_type info;
  42. GLfloat alpha = 1.0f;
  43. glm::mat4 transform = glm::mat4(1.0f); // ignored with ITEM_IMAGE
  44. };
  45. using item_list_type =
  46. std::vector<item_type>;
  47. item_list_type items;
  48. camera_info camera;
  49. struct light_info {
  50. bool follow_camera = false;
  51. glm::vec3 direction = glm::vec3(0.0f, 0.0f, -1.0f);
  52. } light;
  53. smart_cuda_stream *stream = nullptr;
  54. };
  55. using scene_ptr = std::shared_ptr<scene_render_info>;
  56. void render_scene(const scene_ptr &info);
  57. #endif //DEPTHGUIDE_RENDER_SCENE_H