2026-03-22 03:33:55 +08:00
|
|
|
|
# Scene 模块概览
|
|
|
|
|
|
|
refactor: improve test infrastructure and fix OpenGL GLAD initialization
- Rename D3D12Enum.h to D3D12Enums.h for naming consistency
- Fix OpenGL unit test GLAD initialization by using gladLoadGL()
instead of gladLoadGLLoader(wglGetProcAddress) for fallback support
- Migrate remaining tests to use gtest_discover_tests for granular
test discovery (math, core, containers, memory, threading, debug,
components, scene, resources, input, opengl)
- Remove obsolete TEST_RESOURCES_DIR and copy_directory commands
from OpenGL unit test CMakeLists (minimal/Res doesn't exist)
- Update TEST_SPEC.md with performance metrics and per-module
build/test commands for faster development workflow
- Update CMake path references to use lowercase paths
2026-03-23 00:43:02 +08:00
|
|
|
|
**命名空间**: `XCEngine::Scene`
|
2026-03-22 03:33:55 +08:00
|
|
|
|
|
|
|
|
|
|
**类型**: `module`
|
|
|
|
|
|
|
|
|
|
|
|
**描述**: XCEngine 的场景管理模块,提供场景创建、加载和 GameObject 管理功能。
|
|
|
|
|
|
|
|
|
|
|
|
## 概述
|
|
|
|
|
|
|
|
|
|
|
|
Scene 模块是 XCEngine 中管理游戏场景的核心模块。它提供了 Scene 类用于管理场景中的所有 GameObject,以及 SceneManager 单例用于管理多个场景、场景切换和生命周期。场景是 GameObject 的容器,支持场景保存/加载、子对象查找、事件通知等功能。
|
|
|
|
|
|
|
|
|
|
|
|
## 模块内容
|
|
|
|
|
|
|
|
|
|
|
|
### 核心类
|
|
|
|
|
|
|
|
|
|
|
|
| 组件 | 文件 | 描述 |
|
|
|
|
|
|
|------|------|------|
|
|
|
|
|
|
| [Scene](scene/scene.md) | `Scene.h` | 场景类,管理 GameObject 层级和生命周期 |
|
|
|
|
|
|
| [SceneManager](scene-manager/scene-manager.md) | `SceneManager.h` | 场景管理器单例,管理所有场景 |
|
|
|
|
|
|
|
|
|
|
|
|
## 使用示例
|
|
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
|
#include <XCEngine/Scene/SceneManager.h>
|
|
|
|
|
|
#include <XCEngine/Scene/Scene.h>
|
|
|
|
|
|
#include <XCEngine/Components/GameObject.h>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace XCEngine::Components;
|
|
|
|
|
|
|
|
|
|
|
|
void CreateNewScene() {
|
|
|
|
|
|
Scene* scene = SceneManager::Get().CreateScene("MainMenu");
|
|
|
|
|
|
SceneManager::Get().SetActiveScene(scene);
|
|
|
|
|
|
|
|
|
|
|
|
GameObject* camera = scene->CreateGameObject("MainCamera");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LoadSceneExample() {
|
|
|
|
|
|
SceneManager::Get().LoadScene("levels/gameplay.json");
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 相关文档
|
|
|
|
|
|
|
|
|
|
|
|
- [Components 模块](../components/components.md) - Components 模块总览
|
|
|
|
|
|
- [GameObject](../components/game-object/game-object.md) - 游戏对象
|