Ocean
GILightSource.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_RENDERING_GI_LIGHT_SOURCE_H
9 #define META_OCEAN_RENDERING_GI_LIGHT_SOURCE_H
10 
13 
15 
17 
18 namespace Ocean
19 {
20 
21 namespace Rendering
22 {
23 
24 namespace GlobalIllumination
25 {
26 
27 // Forward declaration.
28 class GILightSource;
29 
30 /**
31  * Definition of a pair holding a light source and a homogenous matrix.
32  * @ingroup renderinggi
33  */
34 typedef std::pair<SmartObjectRef<GILightSource>, HomogenousMatrix4> LightPair;
35 
36 /**
37  * Definition of a vector holding light pairs.
38  * @ingroup renderinggi
39  */
40 typedef std::vector<LightPair> LightSources;
41 
42 /**
43  * This class is the base class for all Global Illumination light sources.
44  * @ingroup renderinggi
45  */
46 class OCEAN_RENDERING_GI_EXPORT GILightSource :
47  virtual public GIObject,
48  virtual public LightSource
49 {
50  public:
51 
52  /**
53  * Returns the ambient color of this light source.
54  * @see LightSource::ambientColor().
55  */
56  RGBAColor ambientColor() const override;
57 
58  /**
59  * Returns the diffuse color of this light source.
60  * @see LightSource::diffuseColor().
61  */
62  RGBAColor diffuseColor() const override;
63 
64  /**
65  * Returns the specular color of this light source.
66  * @see LightSource::specularColor().
67  */
68  RGBAColor specularColor() const override;
69 
70  /**
71  * Returns the intensity of this light source.
72  * @see LightSource::intensity().
73  */
74  Scalar intensity() const override;
75 
76  /**
77  * Returns whether this light source is enabled.
78  * @see LightSource::enabled().
79  */
80  bool enabled() const override;
81 
82  /**
83  * Gets all color values of the light at once.
84  * @see LightSource::get().
85  */
86  void get(RGBAColor& ambient, RGBAColor& diffuse, RGBAColor& specular, Scalar& intensity) override;
87 
88  /**
89  * Returns the ambient color of this light source.
90  * @see ambientColor().
91  */
92  inline const RGBAColor& ambientColorInline() const;
93 
94  /**
95  * Returns the diffuse color of this light source.
96  * @see diffuseColor().
97  */
98  inline const RGBAColor& diffuseColorInline() const;
99 
100  /**
101  * Returns the specular color of this light source.
102  * @see specularColor().
103  */
104  inline const RGBAColor& specularColorInline() const;
105 
106  /**
107  * Returns the intensity of this light source.
108  * @see intensity().
109  */
110  inline Scalar intensityInline() const;
111 
112  /**
113  * Returns whether this light source is enabled.
114  * @see enabled().
115  */
116  inline bool enabledInline() const;
117 
118  /**
119  * Sets the ambient color of the light source.
120  * @see LightSource::setAmbientcolor().
121  */
122  bool setAmbientColor(const RGBAColor& color) override;
123 
124  /**
125  * Sets the diffuse color of the light source.
126  * @see LightSource::setDiffuseColor().
127  */
128  bool setDiffuseColor(const RGBAColor& color) override;
129 
130  /**
131  * Sets the specular color of the light source.
132  * @see LightSource::setSpecularColor().
133  */
134  bool setSpecularColor(const RGBAColor& color) override;
135 
136  /**
137  * Sets the specular exponent of this material.
138  * @see LightSource::setIntensity().
139  */
140  bool setIntensity(const Scalar intensity) override;
141 
142  /**
143  * Sets all color values of the light source at once.
144  * @see LightSource::set().
145  */
146  bool set(const RGBAColor& ambient, const RGBAColor& diffuse, const RGBAColor& specular, const Scalar intensity) override;
147 
148  /**
149  * Sets whether the light source is enabled.
150  * @see LightSource::setEnabled().
151  */
152  void setEnabled(const bool state) override;
153 
154  protected:
155 
156  /**
157  * Creates a new Global Illumination light source.
158  */
160 
161  /**
162  * Destructs a Global Illumination light source.
163  */
164  ~GILightSource() override;
165 
166  protected:
167 
168  /// Ambient light color.
170 
171  /// Diffuse light color.
173 
174  /// Specular light color.
176 
177  /// Light intensity.
179 
180  /// Determines whether the light is enabled.
182 };
183 
185 {
186  return lightAmbientColor;
187 }
188 
190 {
191  return lightDiffuseColor;
192 }
193 
195 {
196  return lightSpecularColor;
197 }
198 
200 {
201  return lightIntensity;
202 }
203 
204 inline bool GILightSource::enabledInline() const
205 {
206  return lightEnabled;
207 }
208 
209 }
210 
211 }
212 
213 }
214 
215 #endif // META_OCEAN_RENDERING_GI_LIGHT_SOURCE_H
This class implements a color defined by red, green, blue and alpha parameters.
Definition: RGBAColor.h:41
This class is the base class for all Global Illumination light sources.
Definition: GILightSource.h:49
~GILightSource() override
Destructs a Global Illumination light source.
RGBAColor diffuseColor() const override
Returns the diffuse color of this light source.
GILightSource()
Creates a new Global Illumination light source.
bool lightEnabled
Determines whether the light is enabled.
Definition: GILightSource.h:181
bool setDiffuseColor(const RGBAColor &color) override
Sets the diffuse color of the light source.
Scalar intensityInline() const
Returns the intensity of this light source.
Definition: GILightSource.h:199
bool setAmbientColor(const RGBAColor &color) override
Sets the ambient color of the light source.
void get(RGBAColor &ambient, RGBAColor &diffuse, RGBAColor &specular, Scalar &intensity) override
Gets all color values of the light at once.
Scalar intensity() const override
Returns the intensity of this light source.
bool setSpecularColor(const RGBAColor &color) override
Sets the specular color of the light source.
bool enabled() const override
Returns whether this light source is enabled.
const RGBAColor & ambientColorInline() const
Returns the ambient color of this light source.
Definition: GILightSource.h:184
RGBAColor lightSpecularColor
Specular light color.
Definition: GILightSource.h:175
const RGBAColor & diffuseColorInline() const
Returns the diffuse color of this light source.
Definition: GILightSource.h:189
RGBAColor lightDiffuseColor
Diffuse light color.
Definition: GILightSource.h:172
Scalar lightIntensity
Light intensity.
Definition: GILightSource.h:178
void setEnabled(const bool state) override
Sets whether the light source is enabled.
RGBAColor ambientColor() const override
Returns the ambient color of this light source.
RGBAColor specularColor() const override
Returns the specular color of this light source.
bool set(const RGBAColor &ambient, const RGBAColor &diffuse, const RGBAColor &specular, const Scalar intensity) override
Sets all color values of the light source at once.
bool enabledInline() const
Returns whether this light source is enabled.
Definition: GILightSource.h:204
RGBAColor lightAmbientColor
Ambient light color.
Definition: GILightSource.h:169
bool setIntensity(const Scalar intensity) override
Sets the specular exponent of this material.
const RGBAColor & specularColorInline() const
Returns the specular color of this light source.
Definition: GILightSource.h:194
This class is the base class for all Global Illumination objects.
Definition: GIObject.h:29
This is the base class for all lights.
Definition: LightSource.h:38
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::pair< SmartObjectRef< GILightSource >, HomogenousMatrix4 > LightPair
Definition of a pair holding a light source and a homogenous matrix.
Definition: GILightSource.h:28
std::vector< LightPair > LightSources
Definition of a vector holding light pairs.
Definition: GILightSource.h:40
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15