Open3D (C++ API)
MaterialModifier.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2019 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 <Eigen/Core>
30 
32 
33 namespace open3d {
34 namespace visualization {
35 
37  enum class MinFilter : uint8_t {
38  Nearest = 0,
39  Linear =
40  1,
42  2,
47  };
49 
50  enum class MagFilter : uint8_t {
51  Nearest = 0,
52  Linear =
53  1,
54  };
55 
56  enum class WrapMode : uint8_t {
57  ClampToEdge,
58  Repeat,
60  MirroredRepeat,
62  };
64 
65  /* filterMag = MagFilter::Nearest
66  * filterMin = MinFilter::Nearest
67  * wrapU = WrapMode::ClampToEdge
68  * wrapV = WrapMode::ClampToEdge
69  * wrapW = WrapMode::ClampToEdge
70  * anisotropy = 0
71  */
73 
74  /* filterMag = MagFilter::Linear
75  * filterMin = MinFilter::Linear
76  * wrapU = WrapMode::ClampToEdge
77  * wrapV = WrapMode::ClampToEdge
78  * wrapW = WrapMode::ClampToEdge
79  * anisotropy = 4
80  */
82 
83  TextureSamplerParameters() = default;
84 
85  // Creates a TextureSampler with the default parameters but setting the
86  // filtering and wrap modes. 'minMag' is filtering for both minification and
87  // magnification 'uvw' is wrapping mode for all texture coordinate axes
88  explicit TextureSamplerParameters(MagFilter min_mag,
90 
91  // Creates a TextureSampler with the default parameters but setting the
92  // filtering and wrap modes. 'uvw' is wrapping mode for all texture
93  // coordinate axes
95  MagFilter mag,
97 
99  MinFilter min, MagFilter mag, WrapMode u, WrapMode v, WrapMode w);
100 
101  // \param a needs to be a power of 2
102  void SetAnisotropy(std::uint8_t a);
103 
104  std::uint8_t GetAnisotropy() const { return anisotropy; }
105 
111 
112 private:
113  std::uint8_t anisotropy = 0;
114 };
115 
117 public:
118  virtual ~MaterialModifier() = default;
119 
120  virtual MaterialModifier& SetParameter(const char* parameter,
121  int value) = 0;
122  virtual MaterialModifier& SetParameter(const char* parameter,
123  float value) = 0;
124  virtual MaterialModifier& SetParameter(const char* parameter,
125  const Eigen::Vector3f& value) = 0;
126  virtual MaterialModifier& SetColor(const char* parameter,
127  const Eigen::Vector3f& value) = 0;
128  virtual MaterialModifier& SetColor(const char* parameter,
129  const Eigen::Vector4f& value) = 0;
130  virtual MaterialModifier& SetTexture(
131  const char* parameter,
132  const TextureHandle& texture,
133  const TextureSamplerParameters& sampler) = 0;
134 
135  virtual MaterialModifier& SetDoubleSided(bool doubleSided) = 0;
136 
137  virtual MaterialInstanceHandle Finish() = 0;
138 };
139 
140 } // namespace visualization
141 } // namespace open3d
void SetAnisotropy(std::uint8_t a)
Definition: MaterialModifier.cpp:74
Definition: MaterialModifier.h:116
WrapMode wrap_w
Definition: MaterialModifier.h:110
static TextureSamplerParameters Pretty()
Definition: MaterialModifier.cpp:36
WrapMode wrap_u
Definition: MaterialModifier.h:108
Box filtering. Weighted average of 4 neighbors is used.
MinFilter
Definition: MaterialModifier.h:37
Definition: Open3DViewer.h:29
WrapMode wrap_v
Definition: MaterialModifier.h:109
static TextureSamplerParameters Simple()
Definition: MaterialModifier.cpp:32
MinFilter filter_min
Definition: MaterialModifier.h:107
Definition: MaterialModifier.h:36
MagFilter
Definition: MaterialModifier.h:50
MagFilter filter_mag
Definition: MaterialModifier.h:106
WrapMode
Definition: MaterialModifier.h:56
std::uint8_t GetAnisotropy() const
Definition: MaterialModifier.h:104