Open3D (C++ API)  0.15.1
GuiSettingsModel.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// The MIT License (MIT)
5//
6// Copyright (c) 2018-2021 www.open3d.org
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to deal
10// in the Software without restriction, including without limitation the rights
11// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12// copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25// ----------------------------------------------------------------------------
26
27#pragma once
28
29#include <map>
30
32
33namespace open3d {
34namespace visualization {
35
37public:
38 static constexpr const char* DEFAULT_IBL = "default";
39 static constexpr const char* CUSTOM_IBL = "Custom KTX file...";
40 static constexpr const char* DEFAULT_MATERIAL_NAME = "Polished ceramic";
41 static constexpr const char* MATERIAL_FROM_FILE_NAME =
42 "Material from file [default]";
43 static constexpr const char* POINT_CLOUD_PROFILE_NAME =
44 "Cloudy day (no direct sun)";
45
47 std::string name;
50 Eigen::Vector3f sun_dir;
51 Eigen::Vector3f sun_color = {1.0f, 1.0f, 1.0f};
53 rendering::Scene::Transform::Identity();
54 bool ibl_enabled = true;
55 bool use_default_ibl = false;
56 bool sun_enabled = true;
57 };
58
60 LIT = 0,
64 };
65
66 struct LitMaterial {
67 Eigen::Vector3f base_color = {0.9f, 0.9f, 0.9f};
68 float metallic = 0.f;
69 float roughness = 0.7f;
70 float reflectance = 0.5f;
71 float clear_coat = 0.2f;
73 float anisotropy = 0.f;
74 };
75
77 // The base color should NOT be {1, 1, 1}, because then the
78 // model will be invisible against the default white background.
79 Eigen::Vector3f base_color = {0.9f, 0.9f, 0.9f};
80 };
81
82 struct Materials {
85 float point_size = 3.0f;
86 // 'name' is only used to keep the UI in sync. It is set by
87 // Set...Material[s]() and should not be set manually.
88 std::string lit_name;
89 };
90
91 static const std::vector<LightingProfile> lighting_profiles_;
92 static const std::map<std::string, const LitMaterial> prefab_materials_;
95 static const LitMaterial& GetDefaultLitMaterial();
96
98
99 bool GetShowSkybox() const;
100 void SetShowSkybox(bool show);
101
102 bool GetShowAxes() const;
103 void SetShowAxes(bool show);
104
105 bool GetShowGround() const;
106 void SetShowGround(bool show);
107
108 bool GetSunFollowsCamera() const;
109 void SetSunFollowsCamera(bool follow);
110
111 const Eigen::Vector3f& GetBackgroundColor() const;
112 void SetBackgroundColor(const Eigen::Vector3f& color);
113
114 const LightingProfile& GetLighting() const;
115 // Should be from lighting_profiles_
118
121
122 // TODO: Get/SetMaterial
123 const Materials& GetCurrentMaterials() const;
125 void SetLitMaterial(const LitMaterial& material, const std::string& name);
126 void SetCurrentMaterials(const Materials& materials,
127 const std::string& name);
128 void SetCurrentMaterials(const std::string& name);
130
131 const Eigen::Vector3f& GetCurrentMaterialColor() const;
132 void SetCurrentMaterialColor(const Eigen::Vector3f& color);
133 void ResetColors();
134 void SetCustomDefaultColor(const Eigen::Vector3f color);
136
137 int GetPointSize() const;
138 void SetPointSize(int size);
139
140 bool GetBasicMode() const;
141 void SetBasicMode(bool enable);
142
145
146 bool GetDisplayingPointClouds() const;
148 void SetDisplayingPointClouds(bool displaying);
149
151 bool GetUserHasCustomizedLighting() const;
152
153 bool GetUserHasChangedColor() const;
154
155 void SetOnChanged(std::function<void(bool)> on_changed);
156
157private:
158 Eigen::Vector3f bg_color_ = {1.0f, 1.0f, 1.0f};
159 bool show_skybox_ = false;
160 bool show_axes_ = false;
161 bool show_ground_ = false;
162 bool sun_follows_cam_ = true;
163 LightingProfile lighting_;
164 MaterialType current_type_ = LIT;
165 Materials current_materials_;
166 Eigen::Vector3f custom_default_color = {-1.0f, -1.0f, 1.0f};
167 bool user_has_changed_color_ = false;
168 bool user_has_changed_lighting_profile_ = false;
169 bool user_has_customized_lighting_ = false;
170 bool displaying_point_clouds_ = false;
171 bool user_wants_estimate_normals_ = false;
172 bool basic_mode_enabled_ = false;
173
174 std::function<void(bool)> on_changed_;
175
176 void NotifyChanged(bool material_changed = false);
177};
178
179} // namespace visualization
180} // namespace open3d
math::float4 color
Definition: LineSetBuffers.cpp:64
Open3DScene::LightingProfile profile
Definition: O3DVisualizer.cpp:288
Definition: GuiSettingsModel.h:36
void SetBasicMode(bool enable)
Definition: GuiSettingsModel.cpp:225
bool GetUserHasChangedLightingProfile() const
Definition: GuiSettingsModel.cpp:387
bool GetShowSkybox() const
Definition: GuiSettingsModel.cpp:200
void SetShowAxes(bool show)
Definition: GuiSettingsModel.cpp:207
const Eigen::Vector3f & GetBackgroundColor() const
Definition: GuiSettingsModel.cpp:230
void SetShowSkybox(bool show)
Definition: GuiSettingsModel.cpp:201
int GetPointSize() const
Definition: GuiSettingsModel.cpp:356
static constexpr const char * DEFAULT_IBL
Definition: GuiSettingsModel.h:38
void SetCurrentMaterialColor(const Eigen::Vector3f &color)
Definition: GuiSettingsModel.cpp:321
static const std::map< std::string, const LitMaterial > prefab_materials_
Definition: GuiSettingsModel.h:92
bool GetSunFollowsCamera() const
Definition: GuiSettingsModel.cpp:218
void UnsetCustomDefaultColor()
Definition: GuiSettingsModel.cpp:352
bool GetShowGround() const
Definition: GuiSettingsModel.cpp:212
void SetBackgroundColor(const Eigen::Vector3f &color)
Definition: GuiSettingsModel.cpp:233
bool GetDisplayingPointClouds() const
Definition: GuiSettingsModel.cpp:379
void SetCurrentMaterials(const Materials &materials, const std::string &name)
Definition: GuiSettingsModel.cpp:282
bool GetShowAxes() const
Definition: GuiSettingsModel.cpp:206
void SetMaterialsToDefault()
Definition: GuiSettingsModel.cpp:294
void SetCustomDefaultColor(const Eigen::Vector3f color)
Definition: GuiSettingsModel.cpp:348
MaterialType GetMaterialType() const
Definition: GuiSettingsModel.cpp:254
static const LightingProfile & GetDefaultLightingProfile()
Definition: GuiSettingsModel.cpp:171
void SetPointSize(int size)
Definition: GuiSettingsModel.cpp:360
bool GetUserHasCustomizedLighting() const
Definition: GuiSettingsModel.cpp:391
static constexpr const char * MATERIAL_FROM_FILE_NAME
Definition: GuiSettingsModel.h:41
void SetMaterialType(MaterialType type)
Definition: GuiSettingsModel.cpp:257
void SetOnChanged(std::function< void(bool)> on_changed)
Definition: GuiSettingsModel.cpp:399
static constexpr const char * DEFAULT_MATERIAL_NAME
Definition: GuiSettingsModel.h:40
void SetSunFollowsCamera(bool follow)
Definition: GuiSettingsModel.cpp:219
static const std::vector< LightingProfile > lighting_profiles_
Definition: GuiSettingsModel.h:91
bool GetBasicMode() const
Definition: GuiSettingsModel.cpp:224
const LightingProfile & GetLighting() const
Definition: GuiSettingsModel.cpp:238
void ResetColors()
Definition: GuiSettingsModel.cpp:335
void SetLightingProfile(const LightingProfile &profile)
Definition: GuiSettingsModel.cpp:242
static constexpr const char * CUSTOM_IBL
Definition: GuiSettingsModel.h:39
static constexpr const char * POINT_CLOUD_PROFILE_NAME
Definition: GuiSettingsModel.h:43
const Materials & GetCurrentMaterials() const
Definition: GuiSettingsModel.cpp:262
const Eigen::Vector3f & GetCurrentMaterialColor() const
Definition: GuiSettingsModel.cpp:306
void SetLitMaterial(const LitMaterial &material, const std::string &name)
Definition: GuiSettingsModel.cpp:271
static const LitMaterial & GetDefaultLitMaterial()
Definition: GuiSettingsModel.cpp:181
MaterialType
Definition: GuiSettingsModel.h:59
@ LIT
Definition: GuiSettingsModel.h:60
@ DEPTH
Definition: GuiSettingsModel.h:63
@ NORMAL_MAP
Definition: GuiSettingsModel.h:62
@ UNLIT
Definition: GuiSettingsModel.h:61
GuiSettingsModel()
Definition: GuiSettingsModel.cpp:194
bool GetUserWantsEstimateNormals()
Definition: GuiSettingsModel.cpp:365
void EstimateNormalsClicked()
Definition: GuiSettingsModel.cpp:374
void SetShowGround(bool show)
Definition: GuiSettingsModel.cpp:213
static const LightingProfile & GetDefaultPointCloudLightingProfile()
Definition: GuiSettingsModel.cpp:176
void SetCustomLighting(const LightingProfile &profile)
Definition: GuiSettingsModel.cpp:248
void SetDisplayingPointClouds(bool displaying)
If true, enables point size.
Definition: GuiSettingsModel.cpp:382
bool GetUserHasChangedColor() const
Definition: GuiSettingsModel.cpp:395
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Scene.h:68
int size
Definition: FilePCD.cpp:59
std::string name
Definition: FilePCD.cpp:58
char type
Definition: FilePCD.cpp:60
const char const char value recording_handle imu_sample void
Definition: K4aPlugin.cpp:269
Definition: PinholeCameraIntrinsic.cpp:35
bool use_default_ibl
Definition: GuiSettingsModel.h:55
rendering::Scene::Transform ibl_rotation
Definition: GuiSettingsModel.h:52
Eigen::Vector3f sun_dir
Definition: GuiSettingsModel.h:50
double ibl_intensity
Definition: GuiSettingsModel.h:48
double sun_intensity
Definition: GuiSettingsModel.h:49
bool ibl_enabled
Definition: GuiSettingsModel.h:54
Eigen::Vector3f sun_color
Definition: GuiSettingsModel.h:51
bool sun_enabled
Definition: GuiSettingsModel.h:56
std::string name
Definition: GuiSettingsModel.h:47
float reflectance
Definition: GuiSettingsModel.h:70
float clear_coat_roughness
Definition: GuiSettingsModel.h:72
float anisotropy
Definition: GuiSettingsModel.h:73
float metallic
Definition: GuiSettingsModel.h:68
Eigen::Vector3f base_color
Definition: GuiSettingsModel.h:67
float roughness
Definition: GuiSettingsModel.h:69
float clear_coat
Definition: GuiSettingsModel.h:71
float point_size
Definition: GuiSettingsModel.h:85
UnlitMaterial unlit
Definition: GuiSettingsModel.h:84
std::string lit_name
Definition: GuiSettingsModel.h:88
LitMaterial lit
Definition: GuiSettingsModel.h:83
Eigen::Vector3f base_color
Definition: GuiSettingsModel.h:79