My Project
ShapeOBB.h
1 #pragma once
2 #include "ShapeAABB.h"
3 
4 namespace ParaEngine
5 {
6  class Plane;
7  class CShapeAABB;
8 
11  class CShapeOBB
12  {
13  public:
14  CShapeOBB(void);
15  CShapeOBB(const CShapeAABB& aabb, const Matrix4& mat);
16  ~CShapeOBB(void);
17 
21  void SetEmpty();
22 
28  bool ContainsPoint(const Vector3& p) const;
29 
35  void Create(const CShapeAABB& aabb, const Matrix4& mat);
36 
42  void Rotate(const Matrix4& mtx, CShapeOBB& obb) const;
43 
48  BOOL IsValid() const;
49 
55  bool ComputePlanes(Plane* planes) const;
56 
62  bool ComputePoints(Vector3* pts) const;
63 
69  bool ComputeVertexNormals(Vector3* pts) const;
70 
75  const DWORD* GetEdges() const;
76 
81  const Vector3* GetLocalEdgeNormals() const;
82 
88  void ComputeWorldEdgeNormal(DWORD edge_index, Vector3& world_normal) const;
89 
95  BOOL IsInside(const CShapeOBB& box) const;
96 
97  const Vector3& GetCenter() const { return mCenter; }
98  const Vector3& GetExtents() const { return mExtents; }
99  const Matrix4& GetRot() const { return mRot; }
100 
101  void GetRotatedExtents(Matrix4& extents) const;
102 
106 
107  // Orientation is stored in row-major format,
108  // i.e. rows = eigen vectors of the covariance matrix
109  };
110 
111 }
const Vector3 * GetLocalEdgeNormals() const
Returns local edge normals.
Definition: ShapeOBB.cpp:202
Matrix4 mRot
O for Oriented.
Definition: ShapeOBB.h:105
Vector3 mExtents
B for Bounding.
Definition: ShapeOBB.h:104
bool ComputePlanes(Plane *planes) const
Computes the obb planes.
Definition: ShapeOBB.cpp:96
BOOL IsValid() const
Checks the CShapeOBB is valid.
Definition: ShapeOBB.cpp:45
void Rotate(const Matrix4 &mtx, CShapeOBB &obb) const
Recomputes the CShapeOBB after an arbitrary transform by a 4x4 matrix.
Definition: ShapeOBB.cpp:35
Vector3 mCenter
B for Box.
Definition: ShapeOBB.h:103
void SetEmpty()
Setups an empty CShapeOBB.
Definition: ShapeOBB.cpp:28
different physics engine has different winding order.
Definition: EventBinding.h:32
bool ComputeVertexNormals(Vector3 *pts) const
Computes vertex normals.
Definition: ShapeOBB.cpp:166
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
BOOL IsInside(const CShapeOBB &box) const
Checks the CShapeOBB is inside another CShapeOBB.
Definition: ShapeOBB.cpp:230
AABB-related code.
Definition: ShapeAABB.h:11
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
Defines a plane in 3D space.
Definition: ParaPlane.h:23
bool ContainsPoint(const Vector3 &p) const
Tests if a point is contained within the CShapeOBB.
Definition: ShapeOBB.cpp:60
const DWORD * GetEdges() const
Returns edges.
Definition: ShapeOBB.cpp:191
void Create(const CShapeAABB &aabb, const Matrix4 &mat)
Builds an CShapeOBB from an CShapeAABB and a world transform.
Definition: ShapeOBB.cpp:81
AABB with orientation by a matrix.
Definition: ShapeOBB.h:11
bool ComputePoints(Vector3 *pts) const
Computes the obb points.
Definition: ShapeOBB.cpp:132
void ComputeWorldEdgeNormal(DWORD edge_index, Vector3 &world_normal) const
Returns world edge normal.
Definition: ShapeOBB.cpp:224