Kemena3D
Loading...
Searching...
No Matches
klight.h
Go to the documentation of this file.
1
5
6#ifndef KLIGHT_H
7#define KLIGHT_H
8
9#include "kexport.h"
10
11#include "kobject.h"
12
13namespace kemena
14{
28 {
29 public:
34 kLight(kObject *parentNode = nullptr);
35
41
46 void setDiffuseColor(kVec3 newColor);
47
53
58 void setSpecularColor(kVec3 newColor);
59
64 float getPower();
65
70 void setPower(float newValue);
71
76 float getConstant();
77
82 float getLinear();
83
88 float getQuadratic();
89
94 void setConstant(float newValue);
95
100 void setLinear(float newValue);
101
106 void setQuadratic(float newValue);
107
113
118 void setDirection(kVec3 newValue);
119
124 float getCutOff();
125
130 void setCutOff(float newValue);
131
137
142 void setOuterCutOff(float newValue);
143
149
155
164 json serialize() override;
165
166 protected:
167 private:
168 kVec3 diffuseColor = kVec3(1.0f, 1.0f, 1.0f);
169 kVec3 specularColor = kVec3(1.0f, 1.0f, 1.0f);
170
171 float power = 10.0f;
172
173 // Point light attenuation
174 float constant = 1.0f;
175 float linear = 0.7f;
176 float quadratic = 1.8f;
177
178 // Sun / directional
179 kVec3 direction = kVec3(1.0f, 1.0f, 1.0f);
180
181 // Spotlight cone
182 float cutOff = glm::cos(glm::radians(15.0f));
183 float outerCutOff = glm::cos(glm::radians(20.0f));
184
186 };
187}
188
189#endif // KLIGHT_H
void setLinear(float newValue)
Sets the linear attenuation term.
void setQuadratic(float newValue)
Sets the quadratic attenuation term.
void setOuterCutOff(float newValue)
Sets the outer cut-off angle (spotlight only).
void setPower(float newValue)
Sets the light power (intensity multiplier).
float getQuadratic()
Returns the quadratic attenuation term.
void setConstant(float newValue)
Sets the constant attenuation term.
kLightType getLightType()
Returns the light type.
kVec3 getDiffuseColor()
Returns the diffuse colour component.
float getLinear()
Returns the linear attenuation term.
kLight(kObject *parentNode=nullptr)
Constructs a light node and optionally attaches it to a parent.
float getConstant()
Returns the constant attenuation term.
json serialize() override
Serialises this light node to JSON.
void setSpecularColor(kVec3 newColor)
Sets the specular colour component.
void setDirection(kVec3 newValue)
Sets the light direction (sun and spotlight only).
void setDiffuseColor(kVec3 newColor)
Sets the diffuse colour component.
kVec3 getSpecularColor()
Returns the specular colour component.
void setCutOff(float newValue)
Sets the inner cut-off angle (spotlight only).
float getOuterCutOff()
Returns the outer cut-off cosine (spotlight only).
float getCutOff()
Returns the inner cut-off cosine (spotlight only).
kVec3 getDirection()
Returns the light direction (sun and spotlight only).
float getPower()
Returns the light power (intensity multiplier).
void setLightType(kLightType newType)
Sets the light type.
kObject(kObject *parentNode=nullptr)
Constructs a kObject and optionally attaches it to a parent.
Symbol visibility / linkage macro for the Kemena3D library.
#define KEMENA3D_API
Definition kexport.h:35
Base class for all scene-graph nodes in the Kemena3D engine.
nlohmann::json json
Definition kobject.h:30
Top-level Kemena3D engine namespace.
Definition kanimation.h:23
kLightType
Light source variety.
Definition kdatatype.h:115
@ LIGHT_TYPE_POINT
Omnidirectional point light.
Definition kdatatype.h:117
glm::vec3 kVec3
3-component float vector.
Definition kdatatype.h:33