33#include " utils/math_matrix.hh"
44
55namespace Parrot {
6+ // / @brief Global light source illuminating all objects uniformly.
67 struct AmbientLight {
8+ // / @trivial
9+ friend ostream& operator <<(ostream& stream, const AmbientLight& light);
10+
11+ // / @trivial
712 DefaultFloat intensity = 1 ;
13+ // / @trivial
814 Vec3<uint8> color = { 255 , 255 , 255 };
915 };
16+ // / @brief Light source illuminating objects based on their surface normals.
1017 struct DirectionalLight {
18+ // / @trivial
19+ friend ostream& operator <<(ostream& stream, const DirectionalLight& light);
20+
21+ // / @trivial
1122 Vec3<DefaultFloat> direction = { 0 , 0 , 1 };
23+ // / @trivial
1224 DefaultFloat intensity = 1 ;
25+ // / @trivial
1326 Vec3<uint8> color = { 255 , 255 , 255 };
1427 };
28+ // / @brief Light source illuminating objects close to it
29+ // / based on their distance to the light.
1530 struct PointLight {
31+ // / @trivial
32+ friend ostream& operator <<(ostream& stream, const PointLight& light);
33+
34+ // / @trivial
1635 Vec3<DefaultFloat> position = { 0 , 0 , 0 };
36+ // / @brief Maximum distance to the objects the light illuminates.
1737 DefaultFloat range = 1 ;
38+ // / @trivial
1839 DefaultFloat intensity = 1 ;
40+ // / @trivial
1941 Vec3<uint8> color = { 255 , 255 , 255 };
2042 };
43+ // / @brief Light source illuminating objects in a cone shape,
44+ // / like a flashlight.
2145 struct SpotLight {
46+ // / @trivial
47+ friend ostream& operator <<(ostream& stream, const SpotLight& light);
48+
49+ // / @trivial
2250 Vec3<DefaultFloat> position = { 0 , 0 , 0 };
51+ // / @trivial
2352 Vec3<DefaultFloat> direction = { 0 , 0 , 1 };
24- DefaultFloat angle = PI<> / 2 ;
53+ // / @brief Angle of the cone in which the light illuminates objects.
54+ DefaultFloat angle = PI<> / 4 ;
55+ // / @trivial
2556 DefaultFloat intensity = 1 ;
57+ // / @trivial
2658 Vec3<uint8> color = { 255 , 255 , 255 };
2759 };
2860
61+ // / @brief One of the following light sources:
62+ // AmbientLight, DirectionalLight, PointLight, SpotLight.
2963 class Light : public Asset {
3064 public:
3165 Light (const AssetPath& path, AssetAPI& api);
3266 Light (const SerialNode& node, const AssetPath& path, AssetAPI& api);
3367
3468 void loadFromSerialNode (const SerialNode& node, AssetAPI& api);
3569
36- Variant<
37- AmbientLight, DirectionalLight, PointLight, SpotLight
38- > value;
39- };
70+ // / @trivial
71+ friend ostream& operator <<(ostream& stream, const Light& source);
4072
41- ostream& operator <<(ostream& stream, const AmbientLight& light);
42- ostream& operator <<(ostream& stream, const DirectionalLight& light);
43- ostream& operator <<(ostream& stream, const PointLight& light);
44- ostream& operator <<(ostream& stream, const SpotLight& light);
45- ostream& operator <<(ostream& stream, const Light& source);
73+ // / @trivial
74+ Variant<AmbientLight, DirectionalLight, PointLight, SpotLight> value;
75+ };
4676}
0 commit comments