Fixed broken references: - texture-import-settings: Fix 16 files referencing wrong overview filename - math/rectint: Fix 9 method links (rectint-* → get*, contains, intersects) - rhi/opengl/device: Fix 8 cross-references (opengl-* → */**) - resources/mesh: Fix meshsection and vertexattribute links - rhi/d3d12/sampler: Fix RHISampler reference path - math/vector3: Fix projectonplane → project-on-plane - rhi/opengl/command-list: Remove broken ClearFlag enum ref - rhi/opengl/device: Create 2 new method docs (MakeContextCurrent, GetNativeContext) - rhi/device: Fix device-info types reference All 0 broken references remaining.
53 lines
1.5 KiB
Markdown
53 lines
1.5 KiB
Markdown
# OBB
|
||
|
||
**命名空间**: `XCEngine::Math`
|
||
|
||
**类型**: `struct`
|
||
|
||
**头文件**: `XCEngine/Core/Math/AABB.h`
|
||
|
||
**描述**: 定向包围盒,支持任意方向旋转的盒状包围体
|
||
|
||
## 概述
|
||
|
||
OBB(Oriented Bounding Box)是一种包围盒类型,与轴对齐包围盒(AABB)不同,OBB 可以任意旋转,因此能够更紧凑地包围复杂形状的对象。OBB 由一个中心点、半长向量(extents)和一个变换矩阵组成,变换矩阵定义了盒子的朝向。
|
||
|
||
OBB 常用于碰撞检测、剔除运算和物理模拟等场景。
|
||
|
||
## 公共方法
|
||
|
||
| 方法 | 描述 |
|
||
|------|------|
|
||
| [`GetAxis`](get-axis.md) | 获取指定索引处的局部轴方向 |
|
||
| [`GetMin`](get-min.md) | 获取包围盒最小顶点 |
|
||
| [`GetMax`](get-max.md) | 获取包围盒最大顶点 |
|
||
| [`Contains`](contains.md) | 检测点是否在包围盒内 |
|
||
| [`Intersects`](intersects-obb.md) | 检测与另一个 OBB 是否相交 |
|
||
| [`Intersects`](intersects-sphere.md) | 检测与球体是否相交 |
|
||
|
||
## 使用示例
|
||
|
||
```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)) {
|
||
}
|
||
|
||
Vector3 axis = obb.GetAxis(0);
|
||
Vector3 min = obb.GetMin();
|
||
Vector3 max = obb.GetMax();
|
||
```
|
||
|
||
## 相关文档
|
||
|
||
- [Vector3](../vector3/vector3.md) - 三维向量
|
||
- [Matrix4](../matrix4/matrix4.md) - 4x4 变换矩阵
|
||
- [Sphere](../sphere/sphere.md) - 球体
|