Avara3D 0.2.0
C++ API reference
Light.h
1//
2// Light.h
3// avara3d
4//
5// Created by Morgan Davis on 10/21/16.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_VISUAL_LIGHT_LIGHT_H
10#define AVARA3D_VISUAL_LIGHT_LIGHT_H
11
12#include "a3d/Color.h"
13
14#include <memory>
15#include <optional>
16#include <string>
17
18namespace a3d {
19
20 class AmbientLight;
21 class DirectionalLight;
22 class PointLight;
23 class SpotLight;
24
32 class Light {
33
34 public:
35 // [Public Static Member Functions]
36
38 static std::shared_ptr<AmbientLight> Ambient();
39
41 static std::shared_ptr<AmbientLight> Ambient(const Color& color);
42
44 static std::shared_ptr<DirectionalLight> Directional();
45
47 static std::shared_ptr<DirectionalLight> Directional(const Color& color);
48
50 static std::shared_ptr<PointLight> Point();
51
53 static std::shared_ptr<PointLight> Point(const Color& color);
54
56 static std::shared_ptr<SpotLight> Spot();
57
59 static std::shared_ptr<SpotLight> Spot(const Color& color);
60
61 protected:
62 // [Protected Lifecycle Functions]
63
64 Light();
65 explicit Light(const std::string& name);
66 explicit Light(const Color& color);
67 Light(const std::string& name, const Color& color);
68
69 Light(const Light&) = default;
70 Light& operator=(const Light&) = default;
71
72 Light(Light&&) noexcept = default;
73 Light& operator=(Light&&) noexcept = default;
74
75 virtual ~Light() = 0;
76
77 public:
78 // [Public Member Functions]
79
81 const std::optional<std::string>& name() const;
82
84 void name(const std::string& name);
85
87 const Color& color() const;
88
90 void color(const Color& color);
91
92 protected:
93 // [Protected Member Variables]
94
95 std::optional<std::string> _name;
96 Color _color;
97 };
98
99}
100
101#endif // AVARA3D_VISUAL_LIGHT_LIGHT_H
Represents a normalized RGBA color.
Definition: Color.h:27
Base class for light sources attached to Scene Nodes.
Definition: Light.h:32
static std::shared_ptr< PointLight > Point()
Creates a white PointLight.
static std::shared_ptr< DirectionalLight > Directional()
Creates a white DirectionalLight.
static std::shared_ptr< DirectionalLight > Directional(const Color &color)
Creates a DirectionalLight with color.
static std::shared_ptr< SpotLight > Spot(const Color &color)
Creates a SpotLight with color.
static std::shared_ptr< AmbientLight > Ambient()
Creates a white AmbientLight.
static std::shared_ptr< PointLight > Point(const Color &color)
Creates a PointLight with color.
const std::optional< std::string > & name() const
Returns the optional light name.
static std::shared_ptr< AmbientLight > Ambient(const Color &color)
Creates an AmbientLight with color.
const Color & color() const
Returns the light color.
static std::shared_ptr< SpotLight > Spot()
Creates a white SpotLight.