ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Light.h
Go to the documentation of this file.
1/**
2 * @file Light.h
3 * @brief Defines the Light class for managing light sources in a 3D scene.
4 *
5 * The Light class encapsulates the properties of a light source, including its position,
6 * intensity, falloff, and attenuation curve. It provides methods for manipulating
7 * these properties and updating the light's behavior in the scene.
8 *
9 * @date 22/12/2024
10 * @version 1.0
11 * @author Coela Can't
12 */
13
14#pragma once
15
16#include "../../Utils/Math/Vector3D.h"
17
18/**
19 * @class Light
20 * @brief Represents a light source with position, intensity, and falloff properties.
21 */
22class Light {
23public:
24 /**
25 * @brief Default constructor for the Light class.
26 */
27 Light();
28
29 /**
30 * @brief Constructs a Light object with specified properties.
31 * @param p Position of the light source.
32 * @param intensity Intensity of the light.
33 * @param falloff Falloff rate of the light.
34 * @param a Curve parameter for attenuation.
35 * @param b Curve parameter for attenuation.
36 */
37 Light(Vector3D p, Vector3D intensity, float falloff, float a, float b);
38
39 /**
40 * @brief Sets the light's properties.
41 * @param p Position of the light source.
42 * @param intensity Intensity of the light.
43 * @param falloff Falloff rate of the light.
44 * @param a Curve parameter for attenuation.
45 * @param b Curve parameter for attenuation.
46 */
47 void Set(Vector3D p, Vector3D intensity, float falloff, float a, float b);
48
49 /**
50 * @brief Sets the intensity of the light.
51 * @param intensity Intensity vector of the light.
52 */
54
55 /**
56 * @brief Sets the falloff and attenuation parameters for the light.
57 * @param falloff Falloff rate of the light.
58 * @param a Curve parameter for attenuation.
59 * @param b Curve parameter for attenuation.
60 */
61 void SetFalloff(float falloff, float a, float b);
62
63 /**
64 * @brief Moves the light to a specified position.
65 * @param p New position of the light source.
66 */
67 void MoveTo(Vector3D p);
68
69 /**
70 * @brief Translates the light by a specified vector.
71 * @param p Translation vector.
72 */
73 void Translate(Vector3D p);
74
75 /**
76 * @brief Sets the falloff rate of the light.
77 * @param falloff Falloff rate.
78 */
79 void SetFalloff(float falloff);
80
81 /**
82 * @brief Sets the attenuation curve parameters for the light.
83 * @param a Curve parameter A.
84 * @param b Curve parameter B.
85 */
86 void SetCurve(float a, float b);
87
88 /**
89 * @brief Retrieves the position of the light source.
90 * @return Position vector of the light.
91 */
93
94 /**
95 * @brief Retrieves the falloff rate of the light.
96 * @return Falloff rate.
97 */
98 float GetFalloff();
99
100 /**
101 * @brief Retrieves the first curve parameter for attenuation.
102 * @return Curve parameter A.
103 */
104 float GetCurveA();
105
106 /**
107 * @brief Retrieves the second curve parameter for attenuation.
108 * @return Curve parameter B.
109 */
110 float GetCurveB();
111
112 /**
113 * @brief Retrieves the intensity of the light.
114 * @return Intensity vector.
115 */
117
118private:
119 Vector3D p; ///< Position of the light source.
120 Vector3D intensity; ///< Intensity vector of the light.
121 float falloff; ///< Falloff rate of the light.
122 float a; ///< Attenuation curve parameter A.
123 float b; ///< Attenuation curve parameter B.
124};
Represents a light source with position, intensity, and falloff properties.
Definition Light.h:22
void Translate(Vector3D p)
Translates the light by a specified vector.
Definition Light.cpp:33
Vector3D intensity
Intensity vector of the light.
Definition Light.h:120
void SetCurve(float a, float b)
Sets the attenuation curve parameters for the light.
Definition Light.cpp:41
float a
Attenuation curve parameter A.
Definition Light.h:122
void SetIntensity(Vector3D intensity)
Sets the intensity of the light.
Definition Light.cpp:19
float GetCurveA()
Retrieves the first curve parameter for attenuation.
Definition Light.cpp:59
Light()
Default constructor for the Light class.
Definition Light.cpp:3
float GetFalloff()
Retrieves the falloff rate of the light.
Definition Light.cpp:55
float b
Attenuation curve parameter B.
Definition Light.h:123
Vector3D GetIntensity()
Retrieves the intensity of the light.
Definition Light.cpp:51
float GetCurveB()
Retrieves the second curve parameter for attenuation.
Definition Light.cpp:63
Vector3D GetPosition()
Retrieves the position of the light source.
Definition Light.cpp:47
void Set(Vector3D p, Vector3D intensity, float falloff, float a, float b)
Sets the light's properties.
Definition Light.cpp:11
void SetFalloff(float falloff, float a, float b)
Sets the falloff and attenuation parameters for the light.
Definition Light.cpp:23
float falloff
Falloff rate of the light.
Definition Light.h:121
Vector3D p
Position of the light source.
Definition Light.h:119
void MoveTo(Vector3D p)
Moves the light to a specified position.
Definition Light.cpp:29
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26