Open3D (C++ API)  0.18.0+252c867
FilamentView.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <memory>
11 #include <numeric>
12 
14 
16 namespace filament {
17 class Engine;
18 class Scene;
19 class View;
20 class Viewport;
21 class ColorGrading;
22 } // namespace filament
24 
25 namespace open3d {
26 namespace visualization {
27 namespace rendering {
28 
29 class FilamentCamera;
30 class FilamentResourceManager;
31 class FilamentScene;
32 
33 class FilamentView : public View {
34 public:
35  static constexpr std::uint8_t kAllLayersMask =
36  std::numeric_limits<std::uint8_t>::max();
37  static constexpr std::uint8_t kMainLayer = 1; // Default layer for objects
38 
39  FilamentView(filament::Engine& engine,
40  FilamentResourceManager& resource_mgr);
41  FilamentView(filament::Engine& engine,
42  FilamentScene& scene,
43  FilamentResourceManager& resource_mgr);
44  ~FilamentView() override;
45 
46  void SetDiscardBuffers(const TargetBuffers& buffers) override;
47  Mode GetMode() const override;
48  void SetMode(Mode mode) override;
49  void SetWireframe(bool enable) override;
50 
51  void SetSampleCount(int n) override;
52  int GetSampleCount() const override;
53 
55  std::int32_t y,
56  std::uint32_t w,
57  std::uint32_t h) override;
58  std::array<int, 4> GetViewport() const override;
59 
60  void SetPostProcessing(bool enabled) override;
61  void SetAmbientOcclusion(bool enabled, bool ssct_enabled = false) override;
62  void SetBloom(bool enabled, float strength = 0.5f, int spread = 6) override;
63  void SetAntiAliasing(bool enabled, bool temporal = false) override;
64  void SetShadowing(bool enabled, ShadowType type) override;
65 
66  void SetColorGrading(const ColorGradingParams& color_grading) override;
67 
68  void ConfigureForColorPicking() override;
69 
70  void EnableViewCaching(bool enable) override;
71  bool IsCached() const override;
72  TextureHandle GetColorBuffer() override;
73 
74  Camera* GetCamera() const override;
75 
76  // Copies available settings for view and camera
77  void CopySettingsFrom(const FilamentView& other);
78 
79  void SetScene(FilamentScene& scene);
80 
81  filament::View* GetNativeView() const { return view_; }
82 
83  void PreRender();
84  void PostRender();
85 
86 private:
87  void SetRenderTarget(const RenderTargetHandle render_target);
88 
89  std::unique_ptr<FilamentCamera> camera_;
90  Mode mode_ = Mode::Color;
91  TargetBuffers discard_buffers_;
92  bool caching_enabled_ = false;
93  bool configured_for_picking_ = false;
94  TextureHandle color_buffer_;
95  TextureHandle depth_buffer_;
96  RenderTargetHandle render_target_;
97 
98  filament::Engine& engine_;
99  FilamentScene* scene_ = nullptr;
100  FilamentResourceManager& resource_mgr_;
101  filament::View* view_ = nullptr;
102  filament::ColorGrading* color_grading_ = nullptr;
103 };
104 
105 } // namespace rendering
106 } // namespace visualization
107 } // namespace open3d
Manages.
Definition: ColorGrading.h:18
Definition: FilamentResourceManager.h:50
void CopySettingsFrom(const FilamentView &other)
Definition: FilamentView.cpp:346
int GetSampleCount() const override
Definition: FilamentView.cpp:145
TextureHandle GetColorBuffer() override
Definition: FilamentView.cpp:326
void SetSampleCount(int n) override
Definition: FilamentView.cpp:143
bool IsCached() const override
Definition: FilamentView.cpp:324
void PreRender()
Definition: FilamentView.cpp:373
void SetShadowing(bool enabled, ShadowType type) override
Definition: FilamentView.cpp:193
Mode GetMode() const override
Definition: FilamentView.cpp:97
filament::View * GetNativeView() const
Definition: FilamentView.h:81
void PostRender()
Definition: FilamentView.cpp:461
void ConfigureForColorPicking() override
Definition: FilamentView.cpp:287
void SetPostProcessing(bool enabled) override
Definition: FilamentView.cpp:159
void SetMode(Mode mode) override
Definition: FilamentView.cpp:99
~FilamentView() override
Definition: FilamentView.cpp:88
void SetViewport(std::int32_t x, std::int32_t y, std::uint32_t w, std::uint32_t h) override
Definition: FilamentView.cpp:147
FilamentView(filament::Engine &engine, FilamentResourceManager &resource_mgr)
Definition: FilamentView.cpp:56
std::array< int, 4 > GetViewport() const override
Definition: FilamentView.cpp:154
static constexpr std::uint8_t kMainLayer
Definition: FilamentView.h:37
void SetDiscardBuffers(const TargetBuffers &buffers) override
Definition: FilamentView.cpp:129
void SetColorGrading(const ColorGradingParams &color_grading) override
Definition: FilamentView.cpp:213
static constexpr std::uint8_t kAllLayersMask
Definition: FilamentView.h:35
void SetAntiAliasing(bool enabled, bool temporal=false) override
Definition: FilamentView.cpp:182
void SetAmbientOcclusion(bool enabled, bool ssct_enabled=false) override
Definition: FilamentView.cpp:163
void SetScene(FilamentScene &scene)
Definition: FilamentView.cpp:368
void EnableViewCaching(bool enable) override
Definition: FilamentView.cpp:295
void SetBloom(bool enabled, float strength=0.5f, int spread=6) override
Definition: FilamentView.cpp:171
void SetWireframe(bool enable) override
Definition: FilamentView.cpp:134
Camera * GetCamera() const override
Definition: FilamentView.cpp:344
char type
Definition: FilePCD.cpp:41
Definition: FilamentEngine.h:12
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle uint32_t
Definition: K4aPlugin.cpp:548
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle image_handle timestamp_usec white_balance image_handle k4a_device_configuration_t config device_handle char size_t serial_number_size bool int32_t int32_t int32_t int32_t k4a_color_control_mode_t default_mode mode
Definition: K4aPlugin.cpp:678
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t int32_t
Definition: K4aPlugin.cpp:395
Definition: PinholeCameraIntrinsic.cpp:16