ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
FilamentView.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.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 cloudViewer {
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 =
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 
54  void SetViewport(std::int32_t x,
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 cloudViewer
char type
void SetAmbientOcclusion(bool enabled, bool ssct_enabled=false) override
void SetColorGrading(const ColorGradingParams &color_grading) override
void SetViewport(std::int32_t x, std::int32_t y, std::uint32_t w, std::uint32_t h) override
FilamentView(filament::Engine &engine, FilamentResourceManager &resource_mgr)
void CopySettingsFrom(const FilamentView &other)
void SetAntiAliasing(bool enabled, bool temporal=false) override
std::array< int, 4 > GetViewport() const override
static constexpr std::uint8_t kAllLayersMask
Definition: FilamentView.h:35
void SetShadowing(bool enabled, ShadowType type) override
void SetDiscardBuffers(const TargetBuffers &buffers) override
void SetBloom(bool enabled, float strength=0.5f, int spread=6) override
int max(int a, int b)
Definition: cutil_math.h:48
Generic file read and write utility for python interface.