RenderLight.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 #ifndef H_DC_RENDER_LIGHT
34 #define H_DC_RENDER_LIGHT
35 
36 #include <Dynacoe/Component.h>
37 #include <Dynacoe/Color.h>
38 #include <Dynacoe/Backends/Renderer/Renderer.h>
39 
40 namespace Dynacoe {
41 
45 class RenderLight : public Component {
46  public:
47  RenderLight();
48  ~RenderLight();
49 
52  enum class Light {
53  Point,
54  Directional,
55  };
56 
57 
58 
59 
63  void FormLight(Light type);
64 
67  void Clear();
68 
71  void Enable(bool);
72 
74  struct LightAttributes {
75  bool operator==(const LightAttributes & other) const {
76  return (position == other.position &&
77  color == other.color &&
78  intensity == other.intensity);
79  }
83 
86  float intensity;
87 
91  };
92 
97 
98 
99  void OnDraw();
100  std::string GetInfo();
101 
102  private:
103 
104  LightID lightID;
105  Light type;
106  LightAttributes current;
107  Vector currentPos;
108  bool enabled;
109 
110 };
111 }
112 
113 #endif
A standard object representing an RGBA color.
Definition: Color.h:47
LightAttributes state
Attributes of the light. Edit these to modify the light.
Definition: RenderLight.h:96
A 3D aspect that signifies a light.
Definition: RenderLight.h:45
Vector lights have a single location in space. The intensity of the light is dependent on how close o...
3D and 2D positional vector.
Definition: Vector.h:55
Light
Definition: RenderLight.h:52
Definition: AssetID.h:37
void OnDraw()
Function that is called upon each Draw iteration. Component Draw()s are run before the entity's draw ...
void Enable(bool)
Enables or disables the light.
void Clear()
Resets the RenderLight.
Attributes of a light.
Definition: RenderLight.h:74
Color color
Color of the light.
Definition: RenderLight.h:90
std::string GetInfo()
Returns a string containing human-readable information on the state of the component.
Directional lights have a constant effect on object regardless of the object's proximity.
void FormLight(Light type)
Defines the light.
Class that extends the functionality of an Entity, but as a removable and addable object...
Definition: Component.h:66
float intensity
Intensity of the light.
Definition: RenderLight.h:86
Vector position
Global / absolute position of the light.
Definition: RenderLight.h:82