Ocean
rendering/PointLight.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_POINT_LIGHT_H
9 #define META_OCEAN_RENDERING_POINT_LIGHT_H
10 
13 
14 namespace Ocean
15 {
16 
17 namespace Rendering
18 {
19 
20 // Forward declaration
21 class PointLight;
22 
23 /**
24  * Definition of a smart object reference holding a point light.
25  * @see SmartObjectRef, PointLight.
26  * @ingroup rendering
27  */
29 
30 /**
31  * This class is the base class for all point lights.
32  * In addition to the values of each light source a point light is defined by a position and three attenuation factors.<br>
33  * The position defined the 3D position of the point light in relation to the local coordinate system.<br>
34  * Default position is (0, 0, 0).<br>
35  * The attenuation factors define the light attenuation depending on the distance between light source and object.<br>
36  * A three element vector with a constant, a linear and a quadratic attenuation factor can be defined.<br>
37  * The entire attenuation factor is defined by: 1 / constant + linear * r + quadratic * r^2, with distance r.<br>
38  * Default attenuation factors are (1, 0, 0) meaning a disabled light attenuation.<br>
39  * @see LightSource, SpotLight, DirectionalLight.
40  * @ingroup rendering
41  */
42 class OCEAN_RENDERING_EXPORT PointLight : virtual public LightSource
43 {
44  public:
45 
46  /**
47  * Returns the position of the light object.
48  * @return Light position, default is (0, 0, 0)
49  * @exception NotSupportedException Is thrown if this function is not supported
50  */
51  virtual Vector3 position() const;
52 
53  /**
54  * Returns the attenuation factors of the point light.
55  * @return Three element vector with attenuation factors, with order (constant, linear, quadratic)
56  * @exception NotSupportedException Is thrown if this function is not supported
57  */
58  virtual Vector3 attenuation() const;
59 
60  /**
61  * Sets the position of the light object.
62  * @param position Light position to set
63  * @exception NotSupportedException Is thrown if this function is not supported
64  */
65  virtual void setPosition(const Vector3& position);
66 
67  /**
68  * Sets the attenuation factors for the point light.
69  * @param factors Three element attenuation factor vector with order (constant, linear, quadratic)
70  * @return True, if all three attenuation parameters are valid and could be set
71  * @exception NotSupportedException Is thrown if this function is not supported
72  */
73  virtual bool setAttenuation(const Vector3& factors);
74 
75  /**
76  * Returns the type of this object.
77  * @see Object::type().
78  */
79  ObjectType type() const override;
80 
81  protected:
82 
83  /**
84  * Creates a new point light.
85  */
87 
88  /**
89  * Destructs a point light.
90  */
91  ~PointLight() override;
92 };
93 
94 }
95 
96 }
97 
98 #endif // META_OCEAN_RENDERING_POINT_LIGHT_H
This is the base class for all lights.
Definition: LightSource.h:38
ObjectType
Definition of different object type.
Definition: Object.h:63
This class is the base class for all point lights.
Definition: rendering/PointLight.h:43
virtual void setPosition(const Vector3 &position)
Sets the position of the light object.
~PointLight() override
Destructs a point light.
virtual Vector3 attenuation() const
Returns the attenuation factors of the point light.
PointLight()
Creates a new point light.
ObjectType type() const override
Returns the type of this object.
virtual bool setAttenuation(const Vector3 &factors)
Sets the attenuation factors for the point light.
virtual Vector3 position() const
Returns the position of the light object.
This class implements a smart rendering object reference.
Definition: rendering/ObjectRef.h:34
SmartObjectRef< PointLight > PointLightRef
Definition of a smart object reference holding a point light.
Definition: rendering/PointLight.h:21
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15