AABB轴向包围盒

来源:互联网 发布:法律英语翻译 知乎 编辑:程序博客网 时间:2024/04/26 20:47

 AABB,Axis-Aligned Bounding Box,即通过两个三维向量作为对角点产生的与空间轴平行的长方体空间。在Ogre中通过类AxisAlignedBox来实现,该类中两个成员变量Vector3 mMinimum和Vector3 mMaximum是两个三维向量,分别表示长方体空间的对角点。

    主要成员函数如下:

1、提取最小角点和最大角点

[cpp] view plain copy
  1. const Vector3& getMinimum(voidconst;  
  2. Vector3& getMinimum(void);  
  3. const Vector3& getMaximum(voidconst;  
  4. Vector3& getMaximum(void);  

2、提取八个顶点或指定的顶点

[cpp] view plain copy
  1. const Vector3* getAllCorners(voidconst;  
  2. Vector3 getCorner(CornerEnum cornerToGet) const;  

3、提取中心、大小、体积

[cpp] view plain copy
  1. Vector3 getCenter(voidconst;  
  2. Vector3 getSize(voidconst;  
  3. Vector3 getHalfSize(voidconst;  
  4. Real volume(voidconst;  

4、重置最小角点和最大角点

[cpp] view plain copy
  1. void setMinimum( const Vector3& vec );  
  2. void setMinimum( Real x, Real y, Real z );  
  3. void setMinimumX(Real x);  
  4. void setMinimumY(Real y);  
  5. void setMinimumZ(Real z);  
  6. void setMaximum( const Vector3& vec );  
  7. void setMaximum( Real x, Real y, Real z );  
  8. void setMaximumX(Real x);  
  9. void setMaximumY(Real y);  
  10. void setMaximumZ(Real z);  

 5、重置范围

[cpp] view plain copy
  1. void setExtents( const Vector3& min, const Vector3& max );  
  2. void setExtents(Real mx, Real my, Real mz,Real Mx, Real My, Real Mz );  
  3. void setFinite(void);  
  4. void setNull(void);  

6、判断范围

[cpp] view plain copy
  1. bool isNull(voidconst;  
  2. bool isFinite(voidconst;  
  3. bool isInfinite(voidconst;  

7、布尔并

[cpp] view plain copy
  1. void merge( const AxisAlignedBox& rhs );  
  2. void merge( const Vector3& point );  

8、布尔交

[cpp] view plain copy
  1. bool intersects(const AxisAlignedBox& b2) const;  
  2. AxisAlignedBox intersection(const AxisAlignedBox& b2) const;  
  3. bool intersects(const Sphere& s) const;  
  4. bool intersects(const Plane& p) const;  
  5. bool intersects(const Vector3& v) const;  

9、包含关系

[cpp] view plain copy
  1. bool contains(const Vector3& v) const;  
  2. bool contains(const AxisAlignedBox& other) const;  

10、矩阵变换

[cpp] view plain copy
  1. void transform( const Matrix4& matrix );  
  2. void transformAffine(const Matrix4& m);  
0 0
原创粉丝点击