- components: 修复英文标题为中文,添加缺失组件文档 - 新增 camera-component, light-component, audio-source-component, audio-listener-component 类总览 - 修复 get-position.md 格式 - 更新 components.md 模块总览 - scene: 修复方法文档格式,新增缺失方法 - 修复 find.md, create-game-object.md 英文标题 - 新增 FindByID, SerializeToString, DeserializeFromString 方法文档 - 更新 scene.md 类总览方法列表
66 lines
2.2 KiB
Markdown
66 lines
2.2 KiB
Markdown
# Components 模块概览
|
||
|
||
**命名空间**: `XCEngine::Components`
|
||
|
||
**类型**: `module`
|
||
|
||
**描述**: XCEngine 的 ECS(实体组件系统)组件模块。
|
||
|
||
## 概述
|
||
|
||
Components 模块是 XCEngine ECS 架构中的组件层,提供各种游戏对象组件。这些组件附加到实体(Entity)上,定义了游戏对象的行为和数据。组件系统支持 Transform、Audio、Render 等功能。
|
||
|
||
## 模块内容
|
||
|
||
### 核心组件
|
||
|
||
| 组件 | 文件 | 描述 |
|
||
|------|------|------|
|
||
| [Component](component/component.md) | `Component.h` | 组件基类,所有组件的父类 |
|
||
| [GameObject](game-object/game-object.md) | `GameObject.h` | 游戏对象实体 |
|
||
|
||
### 变换组件
|
||
|
||
| 组件 | 文件 | 描述 |
|
||
|------|------|------|
|
||
| [TransformComponent](transform-component/transform-component.md) | `TransformComponent.h` | 变换组件,包含位置、旋转、缩放 |
|
||
|
||
### 渲染组件
|
||
|
||
| 组件 | 文件 | 描述 |
|
||
|------|------|------|
|
||
| [CameraComponent](camera-component/camera-component.md) | `CameraComponent.h` | 相机组件,定义视图和投影参数 |
|
||
| [LightComponent](light-component/light-component.md) | `LightComponent.h` | 光源组件,支持方向光、点光、聚光灯 |
|
||
|
||
### 音频组件
|
||
|
||
| 组件 | 文件 | 描述 |
|
||
|------|------|------|
|
||
| [AudioSourceComponent](audio-source-component/audio-source-component.md) | `AudioSourceComponent.h` | 音频源组件,负责声音播放和3D音效 |
|
||
| [AudioListenerComponent](audio-listener-component/audio-listener-component.md) | `AudioListenerComponent.h` | 音频监听组件,接收声音并处理多普勒效应和混响 |
|
||
|
||
## 使用示例
|
||
|
||
```cpp
|
||
#include <XCEngine/Components/GameObject.h>
|
||
#include <XCEngine/Components/TransformComponent.h>
|
||
#include <XCEngine/Components/AudioSourceComponent.h>
|
||
|
||
using namespace XCEngine::Components;
|
||
|
||
void CreateAudioEntity() {
|
||
GameObject* entity = new GameObject("AudioEntity");
|
||
|
||
auto transform = entity->AddComponent<TransformComponent>();
|
||
transform->SetPosition(Vector3(0, 0, 0));
|
||
|
||
auto audioSource = entity->AddComponent<AudioSourceComponent>();
|
||
audioSource->SetVolume(0.8f);
|
||
}
|
||
```
|
||
|
||
## 相关文档
|
||
|
||
- [Audio 模块](../audio/audio.md) - 音频系统模块
|
||
- [Core 模块](../core/core.md) - ECS 核心类型
|