13 namespace visualization {
18 class LightingProfileBuilder {
20 LightingProfileBuilder&
name(
const std::string&
name) {
24 LightingProfileBuilder& ibl_intensity(
float x) {
25 profile_.ibl_intensity = x;
28 LightingProfileBuilder& sun_intensity(
float x) {
29 profile_.sun_intensity = x;
32 LightingProfileBuilder& sun_dir(
const Eigen::Vector3f& dir) {
33 profile_.sun_dir = dir;
36 LightingProfileBuilder& sun_color(
const Eigen::Vector3f& c) {
37 profile_.sun_color = c;
41 profile_.ibl_rotation = t;
44 LightingProfileBuilder& ibl_enabled(
bool enabled) {
45 profile_.ibl_enabled = enabled;
48 LightingProfileBuilder& use_default_ibl(
bool use) {
49 profile_.use_default_ibl = use;
52 LightingProfileBuilder& sun_enabled(
bool enabled) {
53 profile_.sun_enabled = enabled;
57 GuiSettingsModel::LightingProfile build() {
return profile_; }
60 GuiSettingsModel::LightingProfile profile_;
74 const std::vector<GuiSettingsModel::LightingProfile>
76 LightingProfileBuilder()
77 .name(
"Bright day with sun at +Y [default]")
80 .sun_dir({0.577f, -0.577f, -0.577f})
82 LightingProfileBuilder()
83 .name(
"Bright day with sun at -Y")
86 .sun_dir({0.577f, 0.577f, 0.577f})
87 .sun_color({1.0f, 1.0f, 1.0f})
90 float(
M_PI), Eigen::Vector3f::UnitX())))
92 LightingProfileBuilder()
93 .name(
"Bright day with sun at +Z")
96 .sun_dir({0.577f, 0.577f, -0.577f})
98 LightingProfileBuilder()
99 .name(
"Less bright day with sun at +Y")
100 .ibl_intensity(35000)
101 .sun_intensity(50000)
102 .sun_dir({0.577f, -0.577f, -0.577f})
104 LightingProfileBuilder()
105 .name(
"Less bright day with sun at -Y")
106 .ibl_intensity(35000)
107 .sun_intensity(50000)
108 .sun_dir({0.577f, 0.577f, 0.577f})
109 .sun_color({1.0f, 1.0f, 1.0f})
112 float(
M_PI), Eigen::Vector3f::UnitX())))
114 LightingProfileBuilder()
115 .name(
"Less bright day with sun at +Z")
116 .ibl_intensity(35000)
117 .sun_intensity(50000)
118 .sun_dir({0.577f, 0.577f, -0.577f})
120 LightingProfileBuilder()
121 .name(POINT_CLOUD_PROFILE_NAME)
122 .ibl_intensity(60000)
123 .sun_intensity(50000)
124 .sun_dir({0.577f, -0.577f, -0.577f})
125 .sun_color({1.0f, 1.0f, 1.0f})
126 .ibl_rotation(rendering::Scene::Transform::Identity())
128 .use_default_ibl(
true)
132 const std::map<std::string, const GuiSettingsModel::LitMaterial>
134 {DEFAULT_MATERIAL_NAME, {}},
136 {{1.0f, 1.0f, 1.0f}, 1.0f, 0.5f, 0.5f, 0.0f, 0.0f, 0.0f}},
138 {{1.0f, 1.0f, 1.0f}, 1.0f, 0.2f, 0.5f, 0.0f, 0.0f, 0.0f}},
140 {{1.0f, 1.0f, 1.0f}, 0.0f, 0.5f, 0.5f, 0.5f, 0.8f, 0.0f}},
142 {{1.0f, 1.0f, 1.0f}, 0.0f, 0.5f, 0.5f, 1.0f, 0.2f, 0.0f}},
144 {{0.7725f, 0.7725f, 0.7725f},
174 return errorMaterial;
203 sun_follows_cam_ = follow;
209 basic_mode_enabled_ = enable;
214 return wireframe_mode_enabled_;
217 wireframe_mode_enabled_ = enable;
235 user_has_changed_lighting_profile_ =
true;
236 user_has_customized_lighting_ =
false;
241 user_has_customized_lighting_ =
true;
246 return current_type_;
249 current_type_ =
type;
255 return current_materials_;
259 return current_materials_;
263 const std::string&
name) {
265 current_materials_.
lit = material;
267 if (user_has_changed_color_) {
274 const std::string&
name) {
275 current_materials_ = materials;
290 if (user_has_changed_color_) {
298 if (user_has_changed_color_) {
301 if (current_type_ ==
LIT) {
303 }
else if (current_type_ ==
UNLIT) {
306 static Eigen::Vector3f
white = {1.0f, 1.0f, 1.0f};
313 if (current_type_ ==
LIT) {
315 user_has_changed_color_ =
true;
317 }
else if (current_type_ ==
UNLIT) {
319 user_has_changed_color_ =
true;
327 if (custom_default_color.x() >= 0.0f) {
335 user_has_changed_color_ =
false;
340 custom_default_color =
color;
344 custom_default_color = {-1.0f, -1.0f, -1.0f};
357 if (user_wants_estimate_normals_) {
358 user_wants_estimate_normals_ =
false;
366 user_wants_estimate_normals_ =
true;
371 return displaying_point_clouds_;
374 displaying_point_clouds_ = displaying;
379 return user_has_changed_lighting_profile_;
383 return user_has_customized_lighting_;
387 return user_has_changed_color_;
391 on_changed_ = on_changed;
394 void GuiSettingsModel::NotifyChanged(
bool material_changed ) {
396 on_changed_(material_changed);
CloudViewerScene::LightingProfile profile
bool GetUserHasCustomizedLighting() const
const Eigen::Vector3f & GetBackgroundColor() const
static constexpr const char * DEFAULT_IBL
bool GetUserHasChangedColor() const
static constexpr const char * MATERIAL_FROM_FILE_NAME
void EstimateNormalsClicked()
void SetCustomLighting(const LightingProfile &profile)
bool GetShowSkybox() const
void SetCurrentMaterials(const Materials &materials, const std::string &name)
void SetLitMaterial(const LitMaterial &material, const std::string &name)
void SetShowSkybox(bool show)
static const LitMaterial & GetDefaultLitMaterial()
bool GetUserWantsEstimateNormals()
void SetBackgroundColor(const Eigen::Vector3f &color)
void SetCustomDefaultColor(const Eigen::Vector3f color)
void SetCurrentMaterialColor(const Eigen::Vector3f &color)
void UnsetCustomDefaultColor()
const Materials & GetCurrentMaterials() const
static constexpr const char * CUSTOM_IBL
void SetBasicMode(bool enable)
void SetMaterialType(MaterialType type)
void SetMaterialsToDefault()
bool GetUserHasChangedLightingProfile() const
void SetDisplayingPointClouds(bool displaying)
If true, enables point size.
static const LightingProfile & GetDefaultLightingProfile()
static constexpr const char * DEFAULT_MATERIAL_NAME
void SetLightingProfile(const LightingProfile &profile)
void SetWireframeMode(bool enable)
const Eigen::Vector3f & GetCurrentMaterialColor() const
static const std::map< std::string, const LitMaterial > prefab_materials_
static const LightingProfile & GetDefaultPointCloudLightingProfile()
void SetOnChanged(std::function< void(bool)> on_changed)
bool GetSunFollowsCamera() const
void SetShowAxes(bool show)
void SetPointSize(int size)
bool GetWireframeMode() const
bool GetDisplayingPointClouds() const
bool GetBasicMode() const
static const std::vector< LightingProfile > lighting_profiles_
static constexpr const char * POINT_CLOUD_PROFILE_NAME
void SetShowGround(bool show)
bool GetShowGround() const
const LightingProfile & GetLighting() const
void SetSunFollowsCamera(bool follow)
MaterialType GetMaterialType() const
Eigen::Transform< float, 3, Eigen::Affine > Transform
Generic file read and write utility for python interface.
constexpr Rgb white(MAX, MAX, MAX)
Eigen::Vector3f base_color
Eigen::Vector3f base_color