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) - 球体
|
||||
|
||||
Reference in New Issue
Block a user