Files
XCEngine/docs/api/math/aabb/aabb.md
ssdfasd f5a34f8adc 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 类总览方法列表
2026-03-26 01:50:27 +08:00

63 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# OBB
**命名空间**: `XCEngine::Math`
**类型**: `struct`
**头文件**: `XCEngine/Core/Math/AABB.h`
**描述**: 有向包围盒Oriented Bounding Box支持任意方向旋转的盒状包围体
## 概述
OBBOriented Bounding Box是一种包围盒类型与轴对齐包围盒AABB不同OBB 可以任意旋转因此能够更紧凑地包围复杂形状的对象。OBB 由一个中心点、半长向量extents和一个变换矩阵组成变换矩阵定义了盒子的朝向。
OBB 常用于碰撞检测、剔除运算和物理模拟等场景。
## 结构体成员
| 成员 | 类型 | 描述 |
|------|------|------|
| `center` | `Vector3` | OBB 中心点 |
| `extents` | `Vector3` | 从中心到每个面的距离(半长) |
| `transform` | `Matrix4x4` | 变换矩阵,定义盒子朝向 |
## 公共方法
| 方法 | 描述 |
|------|------|
| `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) - 轴对齐包围盒
- [Vector3](vector3/vector3.md) - 三维向量
- [Matrix4](matrix4/matrix4.md) - 4x4 变换矩阵
- [Sphere](sphere/sphere.md) - 球体