98 lines
1.9 KiB
C++
98 lines
1.9 KiB
C++
/**
|
|
* @file Light.h
|
|
* @brief 光源句柄与光照参数访问接口定义。
|
|
* @details
|
|
* light 封装渲染层光源实例的轻量句柄语义,支持:
|
|
* - 启停、强度、颜色等常用光照属性读写;
|
|
* - 查询光源类型与绑定实体;
|
|
* - 通过 light_set_key 区分不同光照集合。
|
|
*/
|
|
#pragma once
|
|
#include "CommonHeader.h"
|
|
|
|
namespace XEngine::graphics {
|
|
|
|
|
|
/**
|
|
* @brief 光源强类型标识符。
|
|
*/
|
|
DEFINE_TYPED_ID(light_id);
|
|
|
|
/**
|
|
* @brief 光源句柄对象。
|
|
*/
|
|
class light
|
|
{
|
|
public:
|
|
/**
|
|
* @brief 光源类型枚举。
|
|
*/
|
|
enum type :u32
|
|
{
|
|
directioinal,
|
|
point,
|
|
spot,
|
|
|
|
count
|
|
};
|
|
|
|
constexpr explicit light(light_id id, u64 light_set_key)
|
|
:_light_set_key{ light_set_key }, _id { id } {}
|
|
constexpr light() = default;
|
|
constexpr light_id get_id() const { return _id; }
|
|
constexpr u64 get_light_set_key() const { return _light_set_key; }
|
|
constexpr bool is_valid() const { return id::is_valid(_id); }
|
|
|
|
/**
|
|
* @brief 设置光源启用状态。
|
|
* @param is_enabled true 表示启用。
|
|
*/
|
|
void is_enabled(bool is_enabled) const;
|
|
/**
|
|
* @brief 设置光照强度。
|
|
* @param intensity 光照强度值。
|
|
*/
|
|
void intensity(f32 intensity) const;
|
|
/**
|
|
* @brief 设置光照颜色。
|
|
* @param color RGB 颜色。
|
|
*/
|
|
void color(math::v3 color) const;
|
|
|
|
/**
|
|
* @brief 查询光源启用状态。
|
|
* @return 启用返回 true。
|
|
*/
|
|
bool is_enabled( ) const;
|
|
/**
|
|
* @brief 查询光照强度。
|
|
* @return 当前强度值。
|
|
*/
|
|
f32 intensity( ) const;
|
|
/**
|
|
* @brief 查询光照颜色。
|
|
* @return 当前 RGB 颜色。
|
|
*/
|
|
math::v3 color( ) const;
|
|
|
|
|
|
|
|
/**
|
|
* @brief 查询光源类型。
|
|
* @return 光源类型枚举值。
|
|
*/
|
|
type light_type() const;
|
|
/**
|
|
* @brief 查询绑定实体 ID。
|
|
* @return 实体 ID。
|
|
*/
|
|
id::id_type entity_id() const;
|
|
|
|
private:
|
|
u64 _light_set_key{ 0 };
|
|
light_id _id{ id::invalid_id };
|
|
};
|
|
|
|
|
|
}
|