File Light.h
Go to the documentation of this file
#pragma once
#include "ID.h"
#include "Transform.h"
#include "Sprite.h"
#include "RenderConfigs.h"
enum LightType
{
NONELIGHT = -1,
POINTLIGHT,
SUNLIGHT,
SPOTLIGHT,
AREALIGHT
};
class Light : public ObjectID, public Transform3D
{
public:
bool use_shadow{ true };
LightType light_type{ LightType::NONELIGHT };
float light_power{ 1.0f };
glm::vec3 light_color{ 1.0f };
// Point light parameters
float light_radius{ 0.05f };
// Spot light parameters
float spot_cutoff{ 0.9f };
float spot_outer_cutoff{ 0.8f };
// Area light parameters
float area_ratio{ 1.0f };
public:
Sprite light_sprite;
public:
// TODO: Move to RenderConfigs
static float sun_shaodow_field;
static float sun_shaodow_near;
static float sun_shaodow_far;
static float point_shaodow_near;
static float point_shaodow_far;
static float point_blur_range;
static float spot_shaodow_near;
static float spot_shaodow_far;
static float spot_blur_range;
static float area_shaodow_near;
static float area_shaodow_far;
static float area_blur_range;
public:
Light();
Light(LightType type, float power = 10, glm::vec3 color = glm::vec3{ 1, 1, 1 });
inline static std::pair<SpriteType, std::string> ParseLightName(LightType _type);
public:
bool is_light_changed{ false };
void SetColor(const glm::vec3& _col);
void SetPower(float _power);
void SetShadow(bool _state);
void SetRadius(float _rad);
void SetCutoff(float _ang);
void SetOuterCutoff(float _ang);
void SetRatio(float _ratio);
public:
void RenderLightSpr(const Context& ctx);
public:
void* GetTransform() override { return dynamic_cast<Transform*>(GetTransformPtr()); }
void* GetShader() override;
};