Files
DX12/Engine/EngineAPI/TransformComponent.h
2026-03-19 18:27:49 +08:00

54 lines
1.1 KiB
C++

/**
* @file TransformComponent.h
* @brief 变换组件句柄与只读查询接口定义。
* @details
* component 以轻量句柄方式访问 ECS 中的变换数据,提供:
* - 位置(position)、朝向(orientation)、缩放(scale)查询;
* - 四元数旋转(rotation)读取;
* - 与 id 系统一致的有效性判断语义。
*/
#pragma once
#include "..\Components\ComponentsCommon.h"
namespace XEngine::transform {
/**
* @brief 变换组件强类型标识符。
*/
DEFINE_TYPED_ID(transform_id);
/**
* @brief 变换组件句柄对象。
*/
class component final
{
public:
constexpr explicit component(transform_id id) : _id{ id } {}
constexpr component() : _id{ id::invalid_id } {}
constexpr transform_id get_id() const { return _id; }
constexpr bool is_valid() const { return id::is_valid(_id); }
/**
* @brief 获取世界空间位置。
*/
math::v3 position() const;
/**
* @brief 获取朝向向量。
*/
math::v3 orientation() const;
/**
* @brief 获取缩放向量。
*/
math::v3 scale() const;
/**
* @brief 获取旋转四元数。
*/
math::v4 rotation() const;
private:
transform_id _id;
};
}