Open3D (C++ API)  0.18.0+252c867
GuiSettingsModel.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 <map>
11 
13 
14 namespace open3d {
15 namespace visualization {
16 
18 public:
19  static constexpr const char* DEFAULT_IBL = "default";
20  static constexpr const char* CUSTOM_IBL = "Custom KTX file...";
21  static constexpr const char* DEFAULT_MATERIAL_NAME = "Polished ceramic";
22  static constexpr const char* MATERIAL_FROM_FILE_NAME =
23  "Material from file [default]";
24  static constexpr const char* POINT_CLOUD_PROFILE_NAME =
25  "Cloudy day (no direct sun)";
26 
27  struct LightingProfile {
28  std::string name;
29  double ibl_intensity;
30  double sun_intensity;
31  Eigen::Vector3f sun_dir;
32  Eigen::Vector3f sun_color = {1.0f, 1.0f, 1.0f};
34  rendering::Scene::Transform::Identity();
35  bool ibl_enabled = true;
36  bool use_default_ibl = false;
37  bool sun_enabled = true;
38  };
39 
40  enum MaterialType {
41  LIT = 0,
45  };
46 
47  struct LitMaterial {
48  Eigen::Vector3f base_color = {0.9f, 0.9f, 0.9f};
49  float metallic = 0.f;
50  float roughness = 0.7f;
51  float reflectance = 0.5f;
52  float clear_coat = 0.2f;
53  float clear_coat_roughness = 0.2f;
54  float anisotropy = 0.f;
55  };
56 
57  struct UnlitMaterial {
58  // The base color should NOT be {1, 1, 1}, because then the
59  // model will be invisible against the default white background.
60  Eigen::Vector3f base_color = {0.9f, 0.9f, 0.9f};
61  };
62 
63  struct Materials {
66  float point_size = 3.0f;
67  // 'name' is only used to keep the UI in sync. It is set by
68  // Set...Material[s]() and should not be set manually.
69  std::string lit_name;
70  };
71 
72  static const std::vector<LightingProfile> lighting_profiles_;
73  static const std::map<std::string, const LitMaterial> prefab_materials_;
76  static const LitMaterial& GetDefaultLitMaterial();
77 
79 
80  bool GetShowSkybox() const;
81  void SetShowSkybox(bool show);
82 
83  bool GetShowAxes() const;
84  void SetShowAxes(bool show);
85 
86  bool GetShowGround() const;
87  void SetShowGround(bool show);
88 
89  bool GetSunFollowsCamera() const;
90  void SetSunFollowsCamera(bool follow);
91 
92  const Eigen::Vector3f& GetBackgroundColor() const;
93  void SetBackgroundColor(const Eigen::Vector3f& color);
94 
95  const LightingProfile& GetLighting() const;
96  // Should be from lighting_profiles_
99 
102 
103  // TODO: Get/SetMaterial
104  const Materials& GetCurrentMaterials() const;
106  void SetLitMaterial(const LitMaterial& material, const std::string& name);
107  void SetCurrentMaterials(const Materials& materials,
108  const std::string& name);
109  void SetCurrentMaterials(const std::string& name);
110  void SetMaterialsToDefault();
111 
112  const Eigen::Vector3f& GetCurrentMaterialColor() const;
113  void SetCurrentMaterialColor(const Eigen::Vector3f& color);
114  void ResetColors();
115  void SetCustomDefaultColor(const Eigen::Vector3f color);
117 
118  int GetPointSize() const;
119  void SetPointSize(int size);
120 
121  bool GetBasicMode() const;
122  void SetBasicMode(bool enable);
123 
124  bool GetWireframeMode() const;
125  void SetWireframeMode(bool enable);
126 
128  void EstimateNormalsClicked();
129 
130  bool GetDisplayingPointClouds() const;
132  void SetDisplayingPointClouds(bool displaying);
133 
135  bool GetUserHasCustomizedLighting() const;
136 
137  bool GetUserHasChangedColor() const;
138 
139  void SetOnChanged(std::function<void(bool)> on_changed);
140 
141 private:
142  Eigen::Vector3f bg_color_ = {1.0f, 1.0f, 1.0f};
143  bool show_skybox_ = false;
144  bool show_axes_ = false;
145  bool show_ground_ = false;
146  bool sun_follows_cam_ = true;
147  LightingProfile lighting_;
148  MaterialType current_type_ = LIT;
149  Materials current_materials_;
150  Eigen::Vector3f custom_default_color = {-1.0f, -1.0f, 1.0f};
151  bool user_has_changed_color_ = false;
152  bool user_has_changed_lighting_profile_ = false;
153  bool user_has_customized_lighting_ = false;
154  bool displaying_point_clouds_ = false;
155  bool user_wants_estimate_normals_ = false;
156  bool basic_mode_enabled_ = false;
157  bool wireframe_mode_enabled_ = false;
158 
159  std::function<void(bool)> on_changed_;
160 
161  void NotifyChanged(bool material_changed = false);
162 };
163 
164 } // namespace visualization
165 } // namespace open3d
math::float4 color
Definition: LineSetBuffers.cpp:45
Open3DScene::LightingProfile profile
Definition: O3DVisualizer.cpp:269
Definition: GuiSettingsModel.h:17
void SetBasicMode(bool enable)
Definition: GuiSettingsModel.cpp:206
bool GetUserHasChangedLightingProfile() const
Definition: GuiSettingsModel.cpp:376
bool GetShowSkybox() const
Definition: GuiSettingsModel.cpp:181
void SetShowAxes(bool show)
Definition: GuiSettingsModel.cpp:188
const Eigen::Vector3f & GetBackgroundColor() const
Definition: GuiSettingsModel.cpp:219
void SetShowSkybox(bool show)
Definition: GuiSettingsModel.cpp:182
int GetPointSize() const
Definition: GuiSettingsModel.cpp:345
static constexpr const char * DEFAULT_IBL
Definition: GuiSettingsModel.h:19
void SetCurrentMaterialColor(const Eigen::Vector3f &color)
Definition: GuiSettingsModel.cpp:310
static const std::map< std::string, const LitMaterial > prefab_materials_
Definition: GuiSettingsModel.h:73
bool GetSunFollowsCamera() const
Definition: GuiSettingsModel.cpp:199
void UnsetCustomDefaultColor()
Definition: GuiSettingsModel.cpp:341
bool GetShowGround() const
Definition: GuiSettingsModel.cpp:193
void SetBackgroundColor(const Eigen::Vector3f &color)
Definition: GuiSettingsModel.cpp:222
bool GetDisplayingPointClouds() const
Definition: GuiSettingsModel.cpp:368
void SetCurrentMaterials(const Materials &materials, const std::string &name)
Definition: GuiSettingsModel.cpp:271
bool GetShowAxes() const
Definition: GuiSettingsModel.cpp:187
void SetMaterialsToDefault()
Definition: GuiSettingsModel.cpp:283
void SetCustomDefaultColor(const Eigen::Vector3f color)
Definition: GuiSettingsModel.cpp:337
MaterialType GetMaterialType() const
Definition: GuiSettingsModel.cpp:243
static const LightingProfile & GetDefaultLightingProfile()
Definition: GuiSettingsModel.cpp:152
void SetPointSize(int size)
Definition: GuiSettingsModel.cpp:349
bool GetUserHasCustomizedLighting() const
Definition: GuiSettingsModel.cpp:380
static constexpr const char * MATERIAL_FROM_FILE_NAME
Definition: GuiSettingsModel.h:22
void SetMaterialType(MaterialType type)
Definition: GuiSettingsModel.cpp:246
void SetOnChanged(std::function< void(bool)> on_changed)
Definition: GuiSettingsModel.cpp:388
static constexpr const char * DEFAULT_MATERIAL_NAME
Definition: GuiSettingsModel.h:21
void SetSunFollowsCamera(bool follow)
Definition: GuiSettingsModel.cpp:200
static const std::vector< LightingProfile > lighting_profiles_
Definition: GuiSettingsModel.h:72
bool GetBasicMode() const
Definition: GuiSettingsModel.cpp:205
const LightingProfile & GetLighting() const
Definition: GuiSettingsModel.cpp:227
void ResetColors()
Definition: GuiSettingsModel.cpp:324
void SetLightingProfile(const LightingProfile &profile)
Definition: GuiSettingsModel.cpp:231
static constexpr const char * CUSTOM_IBL
Definition: GuiSettingsModel.h:20
static constexpr const char * POINT_CLOUD_PROFILE_NAME
Definition: GuiSettingsModel.h:24
const Materials & GetCurrentMaterials() const
Definition: GuiSettingsModel.cpp:251
const Eigen::Vector3f & GetCurrentMaterialColor() const
Definition: GuiSettingsModel.cpp:295
void SetLitMaterial(const LitMaterial &material, const std::string &name)
Definition: GuiSettingsModel.cpp:260
static const LitMaterial & GetDefaultLitMaterial()
Definition: GuiSettingsModel.cpp:162
MaterialType
Definition: GuiSettingsModel.h:40
@ LIT
Definition: GuiSettingsModel.h:41
@ DEPTH
Definition: GuiSettingsModel.h:44
@ NORMAL_MAP
Definition: GuiSettingsModel.h:43
@ UNLIT
Definition: GuiSettingsModel.h:42
GuiSettingsModel()
Definition: GuiSettingsModel.cpp:175
bool GetUserWantsEstimateNormals()
Definition: GuiSettingsModel.cpp:354
void EstimateNormalsClicked()
Definition: GuiSettingsModel.cpp:363
void SetShowGround(bool show)
Definition: GuiSettingsModel.cpp:194
static const LightingProfile & GetDefaultPointCloudLightingProfile()
Definition: GuiSettingsModel.cpp:157
void SetCustomLighting(const LightingProfile &profile)
Definition: GuiSettingsModel.cpp:237
void SetWireframeMode(bool enable)
Definition: GuiSettingsModel.cpp:214
void SetDisplayingPointClouds(bool displaying)
If true, enables point size.
Definition: GuiSettingsModel.cpp:371
bool GetWireframeMode() const
Definition: GuiSettingsModel.cpp:211
bool GetUserHasChangedColor() const
Definition: GuiSettingsModel.cpp:384
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Scene.h:49
int size
Definition: FilePCD.cpp:40
std::string name
Definition: FilePCD.cpp:39
char type
Definition: FilePCD.cpp:41
const char const char value recording_handle imu_sample void
Definition: K4aPlugin.cpp:250
Definition: PinholeCameraIntrinsic.cpp:16
bool use_default_ibl
Definition: GuiSettingsModel.h:36
rendering::Scene::Transform ibl_rotation
Definition: GuiSettingsModel.h:33
Eigen::Vector3f sun_dir
Definition: GuiSettingsModel.h:31
double ibl_intensity
Definition: GuiSettingsModel.h:29
double sun_intensity
Definition: GuiSettingsModel.h:30
bool ibl_enabled
Definition: GuiSettingsModel.h:35
Eigen::Vector3f sun_color
Definition: GuiSettingsModel.h:32
bool sun_enabled
Definition: GuiSettingsModel.h:37
std::string name
Definition: GuiSettingsModel.h:28
float reflectance
Definition: GuiSettingsModel.h:51
float clear_coat_roughness
Definition: GuiSettingsModel.h:53
float anisotropy
Definition: GuiSettingsModel.h:54
float metallic
Definition: GuiSettingsModel.h:49
Eigen::Vector3f base_color
Definition: GuiSettingsModel.h:48
float roughness
Definition: GuiSettingsModel.h:50
float clear_coat
Definition: GuiSettingsModel.h:52
float point_size
Definition: GuiSettingsModel.h:66
UnlitMaterial unlit
Definition: GuiSettingsModel.h:65
std::string lit_name
Definition: GuiSettingsModel.h:69
LitMaterial lit
Definition: GuiSettingsModel.h:64
Eigen::Vector3f base_color
Definition: GuiSettingsModel.h:60