19 renderer.lock()->SetLightType(lightName, LightType::LIGHT_NONEXISTENT);
25 eastl::string oldName = lightName;
28 renderer.lock()->SetLightType(oldName, LightType::LIGHT_NONEXISTENT);
29 renderer.lock()->CreateLight(lightName, lightType,
48 if (vulkanEnabled && type != lightType &&
isEnabled) {
49 renderer.lock()->SetLightType(lightName, type);
52 renderer.lock()->SetLightDirection(lightName,
56 renderer.lock()->SetLightPosition(lightName,
60 renderer.lock()->SetLightDirection(lightName,
62 renderer.lock()->SetLightConeInnerAngle(lightName, lightInfo.
coneInnerAngle);
63 renderer.lock()->SetLightConeOuterAngle(lightName, lightInfo.
coneOuterAngle);
81 renderer.lock()->SetLightPosition(lightName, position);
83 lightInfo.
position = glm::vec4(position.x, position.y, position.z, 1.f);
94 renderer.lock()->SetLightDirection(lightName, direction);
96 lightInfo.
direction = glm::vec4(direction.x, direction.y, direction.z, 0.f);
107 renderer.lock()->SetLightColor(lightName, color);
109 lightInfo.
color = glm::vec4(color.x, color.y, color.z, 1.f);
114 return glm::vec3(lightInfo.
color.x, lightInfo.
color.y, lightInfo.
color.z);
120 renderer.lock()->SetLightRadius(lightName, radius);
122 lightInfo.
radius = radius;
133 renderer.lock()->SetLightConeInnerAngle(lightName, angle);
146 renderer.lock()->SetLightConeOuterAngle(lightName, angle);
156 LightComponent::LightComponent(eastl::string name,
LightType type, glm::vec3 position, glm::vec3 direction, glm::vec3 color,
float radius,
float attunuation,
float coneInnerAngle,
float coneOuterAngle) noexcept
159 vulkanEnabled =
true;
163 vulkanEnabled =
false;
165 #endif// USING_VULKAN 170 lightName =
GetOwner().lock()->name;
173 renderer.lock()->CreateLight(lightName,
175 glm::vec3(position.x, position.y, position.z),
176 glm::vec3(direction.x, direction.y, direction.z),
177 glm::vec3(color.x, color.y, color.z),
178 radius, attunuation, coneInnerAngle, coneOuterAngle);
181 lightInfo.
position = glm::vec4(position.x, position.y, position.z, 1.f);
182 lightInfo.
direction = glm::vec4(direction.x, direction.y, direction.z, 0.f);
183 lightInfo.
color = glm::vec4(color.x, color.y, color.z, 1.f);
184 lightInfo.
radius = radius;
197 lightName =
GetOwner().lock()->name;
202 void LightComponent::InitializeComponent()
207 vulkanEnabled =
true;
208 renderer = eastl::static_pointer_cast<VulkanRenderer,
Renderer>(
213 vulkanEnabled =
false;
218 lightName =
GetOwner().lock()->name;
220 renderer.lock()->CreateLight(lightName,
221 LightType::LIGHT_NONEXISTENT,
227 lightType = LightType::LIGHT_NONEXISTENT;
230 lightInfo.
color = glm::vec4();
238 void LightComponent::Update()
246 renderer.lock()->SetLightType(lightName, LightType::LIGHT_NONEXISTENT);
248 renderer.lock()->SetLightType(lightName, lightType);
glm::vec3 GetLightDirection()
Returns the direction of the light.
void SetLightConeOuterAngle(float angle)
Sets the outer angle of the light cone. NOTE: If the light isn't a spot light this value will take ef...
void SetLightPosition(glm::vec3 position)
Sets the position of the light. NOTE: In case of directional lights and ambient lights this value wil...
LightComponent(eastl::string name, LightType type, glm::vec3 position, glm::vec3 direction, glm::vec3 color, float radius, float attunuation, float coneInnerAngle, float coneOuterAngle) noexcept
Creates a new light component with the given name and type, and initializes it with the given variabl...
float GetLightConeInnerAngle()
Returns the inner angle of the light cone.
float GetLightConeOuterAngle()
Returns the outer angle of the light cone.
LightType GetLightType() const
Returns the type of the light.
void SetLightRadius(float radius)
Sets the new radius of the light. NOTE: In case of directional lights and ambient lights this value w...
This is the main renderer parent class which contains the base methods required for a renderer...
void SetLightColor(glm::vec3 color)
Sets the color of the light.
eastl::string GetLightName() const
Returns the name of the light. The default name is the entity name.
glm::vec3 GetLightPosition()
Returns the position of the light.
eastl::weak_ptr< Entity > GetOwner() const
This method allows you to get the entity holding this component.
void SetLightName(eastl::string name)
Sets the name of the light. This is used internally by the engine to reference the light...
void SetLightConeInnerAngle(float angle)
Sets the inner angle of the light cone. NOTE: If the light isn't a spot light this value will take ef...
void SetLightDirection(glm::vec3 direction)
Sets the direction of the light. NOTE: In case of point and ambient lights this value will take effec...
enum ENGINE_API LightType
Enum containing the different types of lights that can be created.
static eastl::weak_ptr< Engine > GetEngine() noexcept
This method allows you to get the instance of the Engine. This method will automatically initialize t...
float GetLightRadius() const
Returns the radius of the light.
void SetLightType(LightType type)
Sets the type of the light. NOTE: the type non-existent (-1) disables the light.
glm::vec3 GetLightColor()
Returns the color of the light.