docs: 重构 API 文档 - components 和 scene 模块
- 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 类总览方法列表
This commit is contained in:
@@ -1,47 +1,62 @@
|
||||
# AABB / OBB
|
||||
# OBB
|
||||
|
||||
**命名空间**: `XCEngine::Math`
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/AABB.h`
|
||||
**头文件**: `XCEngine/Core/Math/AABB.h`
|
||||
|
||||
**描述**: 轴对齐包围盒 (AABB) 和有向包围盒 (OBB)
|
||||
**描述**: 有向包围盒(Oriented Bounding Box),支持任意方向旋转的盒状包围体
|
||||
|
||||
## 概述
|
||||
|
||||
`AABB` 在 Math 库中通过 `Bounds` 类型实现。OBB 是可以任意方向旋转的包围盒。
|
||||
OBB(Oriented Bounding Box)是一种包围盒类型,与轴对齐包围盒(AABB)不同,OBB 可以任意旋转,因此能够更紧凑地包围复杂形状的对象。OBB 由一个中心点、半长向量(extents)和一个变换矩阵组成,变换矩阵定义了盒子的朝向。
|
||||
|
||||
## AABB
|
||||
|
||||
`AABB` 在 Math 库中通过 `Bounds` 类型实现,参见 [./bounds/bounds.md](../bounds/bounds.md)。
|
||||
|
||||
## OBB - 有向包围盒
|
||||
|
||||
OBB 是可以任意方向旋转的包围盒。
|
||||
OBB 常用于碰撞检测、剔除运算和物理模拟等场景。
|
||||
|
||||
## 结构体成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `center` | `Vector3` | OBB 中心点 |
|
||||
| `extents` | `Vector3` | 从中心到每个面的距离 |
|
||||
| `transform` | `Matrix4` | 变换矩阵 |
|
||||
| `extents` | `Vector3` | 从中心到每个面的距离(半长) |
|
||||
| `transform` | `Matrix4x4` | 变换矩阵,定义盒子朝向 |
|
||||
|
||||
## 公共方法
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `OBB()` | 默认构造 |
|
||||
| `OBB(const Vector3& center, const Vector3& extents)` | 从中心和半长构造 |
|
||||
| [GetAxis](obb-getaxis.md) | 获取局部轴 |
|
||||
| [GetMin](obb-getmin.md) | 局部空间最小点 |
|
||||
| [GetMax](obb-getmax.md) | 局部空间最大点 |
|
||||
| [Contains](obb-contains.md) | 点是否在 OBB 内 |
|
||||
| [Intersects(OBB)](intersects-obb.md) | 与另一个 OBB 相交 |
|
||||
| [Intersects(Sphere)](intersects-sphere.md) | 与球体相交 |
|
||||
| `GetAxis(int index)` | 获取指定索引处的局部轴方向 |
|
||||
| `GetMin()` | 获取局部空间最小顶点 |
|
||||
| `GetMax()` | 获取局部空间最大顶点 |
|
||||
| `Contains(const Vector3& point)` | 检测点是否在 OBB 内 |
|
||||
| `Intersects(const OBB& other)` | 检测与另一个 OBB 是否相交 |
|
||||
| `Intersects(const Sphere& sphere)` | 检测与球体是否相交 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Core/Math/AABB.h>
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Matrix4.h>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
OBB obb(Vector3(0.0f, 0.0f, 0.0f), Vector3(1.0f, 0.5f, 1.0f));
|
||||
|
||||
Vector3 point(0.5f, 0.25f, 0.5f);
|
||||
if (obb.Contains(point)) {
|
||||
// 点在 OBB 内
|
||||
}
|
||||
|
||||
Vector3 axis = obb.GetAxis(0);
|
||||
Vector3 min = obb.GetMin();
|
||||
Vector3 max = obb.GetMax();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Bounds](../bounds/bounds.md) - 轴对齐包围盒
|
||||
- [Math 模块总览](../math.md)
|
||||
- [Bounds](bounds/bounds.md) - 轴对齐包围盒
|
||||
- [Vector3](vector3/vector3.md) - 三维向量
|
||||
- [Matrix4](matrix4/matrix4.md) - 4x4 变换矩阵
|
||||
- [Sphere](sphere/sphere.md) - 球体
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Bounds.h`
|
||||
**头文件**: `XCEngine/Core/Math/Bounds.h`
|
||||
|
||||
**描述**: 轴对齐包围盒,用于场景管理中的快速剔除
|
||||
|
||||
@@ -37,8 +37,8 @@ Bounds 表示一个轴对齐包围盒(AABB),使用中心点 `center` 和
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Bounds.h>
|
||||
#include <XCEngine/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Bounds.h>
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Box.h`
|
||||
**头文件**: `XCEngine/Core/Math/Box.h`
|
||||
|
||||
**描述**: 轴对齐盒体,用于碰撞检测和视锥体裁剪
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Box.h>
|
||||
#include <XCEngine/Math/Vector3.h>
|
||||
#include <XCEngine/Math/Sphere.h>
|
||||
#include <XCEngine/Core/Math/Box.h>
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Sphere.h>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Color.h`
|
||||
**头文件**: `XCEngine/Core/Math/Color.h`
|
||||
|
||||
**描述**: 颜色结构体,支持 RGBA 浮点分量,用于图形渲染
|
||||
|
||||
@@ -79,7 +79,7 @@ Color halfAlpha(0.5f, 0.5f, 0.5f); // a = 1.0f
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Color.h>
|
||||
#include <XCEngine/Core/Math/Color.h>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `class`
|
||||
|
||||
**头文件**: `XCEngine/Math/Frustum.h`
|
||||
**头文件**: `XCEngine/Core/Math/Frustum.h`
|
||||
|
||||
**描述**: 视锥体,用于 3D 裁剪和可见性判断
|
||||
|
||||
|
||||
@@ -43,8 +43,7 @@ Math 模块提供了一套完整的图形数学库,包括向量、矩阵、四
|
||||
| [Plane](plane/plane.md) | `Plane.h` | 平面 |
|
||||
| [Sphere](sphere/sphere.md) | `Sphere.h` | 球体 |
|
||||
| [Box](box/box.md) | `Box.h` | 盒子 |
|
||||
| [Bounds](bounds/bounds.md) | `Bounds.h` | 包围盒 |
|
||||
| [AABB](aabb/aabb.md) | `AABB.h` | 轴对齐包围盒 |
|
||||
| [Bounds](bounds/bounds.md) | `Bounds.h` | 轴对齐包围盒 |
|
||||
| [Frustum](frustum/frustum.md) | `Frustum.h` | 视锥体 |
|
||||
| [Rect](rect/rect.md) | `Rect.h` | 二维矩形 |
|
||||
|
||||
@@ -72,10 +71,10 @@ Math 模块提供了一套完整的图形数学库,包括向量、矩阵、四
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Math.h>
|
||||
#include <XCEngine/Math/Vector3.h>
|
||||
#include <XCEngine/Math/Matrix4.h>
|
||||
#include <XCEngine/Math/Quaternion.h>
|
||||
#include <XCEngine/Core/Math/Math.h>
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Matrix4.h>
|
||||
#include <XCEngine/Core/Math/Quaternion.h>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Matrix3.h`
|
||||
**头文件**: `XCEngine/Core/Math/Matrix3.h`
|
||||
|
||||
**描述**: 3x3 矩阵,用于旋转变换和线性代数运算。
|
||||
|
||||
@@ -56,8 +56,8 @@ using Matrix3 = Matrix3x3;
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Matrix3.h>
|
||||
#include <XCEngine/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Matrix3.h>
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Matrix4.h`
|
||||
**头文件**: `XCEngine/Core/Math/Matrix4.h`
|
||||
|
||||
**描述**: 4x4 矩阵,用于 3D 变换(平移、旋转、缩放)、视图和投影计算
|
||||
|
||||
@@ -49,9 +49,9 @@
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Math/Matrix4.h"
|
||||
#include "XCEngine/Math/Vector3.h"
|
||||
#include "XCEngine/Math/Quaternion.h"
|
||||
#include "XCEngine/Core/Math/Matrix4.h"
|
||||
#include "XCEngine/Core/Math/Vector3.h"
|
||||
#include "XCEngine/Core/Math/Quaternion.h"
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Plane.h`
|
||||
**头文件**: `XCEngine/Core/Math/Plane.h`
|
||||
|
||||
**描述**: 平面,用于 3D 空间中的平面表示和相交测试
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Plane.h>
|
||||
#include <XCEngine/Math/Vector3.h>
|
||||
#include <XCEngine/Math/Sphere.h>
|
||||
#include <XCEngine/Core/Math/Plane.h>
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Sphere.h>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Quaternion.h`
|
||||
**头文件**: `XCEngine/Core/Math/Quaternion.h`
|
||||
|
||||
**描述**: 四元数,用于表示三维旋转
|
||||
|
||||
@@ -43,9 +43,9 @@ Quaternion 提供了一套完整的三维旋转表示和操作方法。四元数
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Quaternion.h>
|
||||
#include <XCEngine/Math/Vector3.h>
|
||||
#include <XCEngine/Math/Math.h>
|
||||
#include <XCEngine/Core/Math/Quaternion.h>
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Math.h>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Ray.h`
|
||||
**头文件**: `XCEngine/Core/Math/Ray.h`
|
||||
|
||||
**描述**: 射线,用于 3D 拾取和光线追踪
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Ray.h>
|
||||
#include <XCEngine/Math/Vector3.h>
|
||||
#include <XCEngine/Math/Sphere.h>
|
||||
#include <XCEngine/Core/Math/Ray.h>
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Sphere.h>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Rect.h`
|
||||
**头文件**: `XCEngine/Core/Math/Rect.h`
|
||||
|
||||
**描述**: 二维矩形,用于表示平面上的矩形区域
|
||||
|
||||
@@ -42,8 +42,8 @@ Rect 结构体表示一个二维矩形,由位置 `(x, y)` 和尺寸 `(width, h
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Math/Rect.h"
|
||||
#include "XCEngine/Math/Vector2.h"
|
||||
#include "XCEngine/Core/Math/Rect.h"
|
||||
#include "XCEngine/Core/Math/Vector2.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Sphere.h`
|
||||
**头文件**: `XCEngine/Core/Math/Sphere.h`
|
||||
|
||||
**描述**: 球体,用于碰撞检测和范围查询
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Sphere.h>
|
||||
#include <XCEngine/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Sphere.h>
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Transform.h`
|
||||
**头文件**: `XCEngine/Core/Math/Transform.h`
|
||||
|
||||
**描述**: 变换组件,包含位置、旋转和缩放,用于层级变换计算
|
||||
|
||||
@@ -43,9 +43,9 @@
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Math/Transform.h"
|
||||
#include "XCEngine/Math/Vector3.h"
|
||||
#include "XCEngine/Math/Quaternion.h"
|
||||
#include "XCEngine/Core/Math/Transform.h"
|
||||
#include "XCEngine/Core/Math/Vector3.h"
|
||||
#include "XCEngine/Core/Math/Quaternion.h"
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Vector2.h`
|
||||
**头文件**: `XCEngine/Core/Math/Vector2.h`
|
||||
|
||||
**描述**: 二维向量,支持 2D 游戏开发和图形计算
|
||||
|
||||
@@ -51,7 +51,7 @@ Vector2 是 XCEngine 中的二维向量结构体,用于表示 2D 空间中的
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Math/Vector2.h"
|
||||
#include "XCEngine/Core/Math/Vector2.h"
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Vector3.h`
|
||||
**头文件**: `XCEngine/Core/Math/Vector3.h`
|
||||
|
||||
**描述**: 三维向量,用于 3D 图形和游戏开发中的位置、方向和缩放计算
|
||||
|
||||
@@ -68,7 +68,7 @@ Vector3 是 XCEngine 中用于表示三维向量的核心类型,支持常见
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Math/Vector3.h"
|
||||
#include "XCEngine/Core/Math/Vector3.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**头文件**: `XCEngine/Math/Vector4.h`
|
||||
**头文件**: `XCEngine/Core/Math/Vector4.h`
|
||||
|
||||
**描述**: 四维向量,用于齐次坐标变换和四元数相关计算
|
||||
|
||||
@@ -47,8 +47,8 @@ Vector4 是四维向量结构体,常用于:
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Vector4.h>
|
||||
#include <XCEngine/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Vector4.h>
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
#include <cstdio>
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
渲染视口结构体,用于屏幕到归一化坐标的映射。
|
||||
|
||||
**头文件:** `#include <XCEngine/Math/Rect.h>`
|
||||
**头文件:** `#include <XCEngine/Core/Math/Rect.h>`
|
||||
|
||||
**命名空间:** `XCEngine::Math`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user