Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
OBB.h
Go to the documentation of this file.
1#ifndef ULT_MATH_OBB_H_INCLUDED
2#define ULT_MATH_OBB_H_INCLUDED
3
5#include <Ult/Math/Vector3D.h>
7
8namespace Ult
9{
10
15class OBB
16{
17public:
21 OBB();
25 OBB(const OBB& obb);
29 OBB(const BoundingBox& aabb);
30
34 void Calculate(const Vector3D* vertices, const int numVerts);
38 void Calculate(const BoundingBox& aabb);
39
44 void Transform(const OBB& obb, const Matrix4x4& mat);
49 void ObjectTransform(const OBB& obb, const Matrix4x4& mat);
50
56 const Vector3D& axis,
57 float& center,
58 float& ext,
59 float& min,
60 float& max
61 );
67 unsigned int GetSupport(const Vector3D& axis, Vector3D* contacts);
68
72 Vector3D GetFaceNormal(const int index) const {
73 if (index == 0) { return mAxis1; }
74 if (index == 1) { return mAxis2; }
75 return mAxis3;
76 }
77 Vector3D GetEdgeDirection(const int index) const {
78 return GetFaceNormal(index);
79 }
80
82 Vector3D GetCenterPos() const { return mCenter; }
84 void SetCenter(const Vector3D& center) { mCenter = center; }
85
87 float GetHalfAxis1() const { return mHalfAxis1; }
89 float GetHalfAxis2() const { return mHalfAxis2; }
91 float GetHalfAxis3() const { return mHalfAxis3; }
93 float GetHalfAxis(const int index) const {
94 if (index == 0) { return mHalfAxis1; }
95 if (index == 1) { return mHalfAxis2; }
96 return mHalfAxis3;
97 }
98
99 void SetHalfAxis1(const float val) { mHalfAxis1 = val; }
101 void SetHalfAxis2(const float val) { mHalfAxis2 = val; }
103 void SetHalfAxis3(const float val) { mHalfAxis3 = val; }
104
106 Vector3D GetAxis1() const { return mAxis1; }
108 Vector3D GetAxis2() const { return mAxis2; }
110 Vector3D GetAxis3() const { return mAxis3; }
112 Vector3D GetAxis(const int index) const {
113 if (index == 0) { return mAxis1; }
114 if (index == 1) { return mAxis2; }
115 return mAxis3;
116 }
117
118 void SetAxis1(const Vector3D& axis) { mAxis1 = axis; }
120 void SetAxis2(const Vector3D& axis) { mAxis2 = axis; }
122 void SetAxis3(const Vector3D& axis) { mAxis3 = axis; }
123
130};
131
132} // namespace Ult
133
134#endif // ULT_MATH_OBB_H_INCLUDED
Definition BoundingBox.h:18
Definition Matrix4x4.h:14
Vector3D GetAxis1() const
Definition OBB.h:106
void SetHalfAxis1(const float val)
Definition OBB.h:99
void SetAxis3(const Vector3D &axis)
Definition OBB.h:122
void SetAxis1(const Vector3D &axis)
Definition OBB.h:118
void ProjectionInterval(const Vector3D &axis, float &center, float &ext, float &min, float &max)
Definition OBB.cpp:90
void SetHalfAxis3(const float val)
Definition OBB.h:103
OBB()
Definition OBB.cpp:7
float mHalfAxis2
Definition OBB.h:127
Vector3D GetAxis3() const
Definition OBB.h:110
float GetHalfAxis(const int index) const
Definition OBB.h:93
unsigned int GetSupport(const Vector3D &axis, Vector3D *contacts)
Definition OBB.cpp:106
Vector3D GetEdgeDirection(const int index) const
Definition OBB.h:77
float GetHalfAxis2() const
Definition OBB.h:89
Vector3D GetCenterPos() const
Definition OBB.h:82
Vector3D mAxis2
Definition OBB.h:129
void SetCenter(const Vector3D &center)
Definition OBB.h:84
float GetHalfAxis3() const
Definition OBB.h:91
float mHalfAxis1
Definition OBB.h:127
void SetAxis2(const Vector3D &axis)
Definition OBB.h:120
Vector3D GetFaceNormal(const int index) const
Definition OBB.h:72
Vector3D GetAxis(const int index) const
Definition OBB.h:112
float mHalfAxis3
Definition OBB.h:127
Vector3D mAxis1
Definition OBB.h:129
void SetHalfAxis2(const float val)
Definition OBB.h:101
Vector3D mCenter
Definition OBB.h:125
Vector3D mAxis3
Definition OBB.h:129
void ObjectTransform(const OBB &obb, const Matrix4x4 &mat)
Definition OBB.cpp:69
void Transform(const OBB &obb, const Matrix4x4 &mat)
Definition OBB.cpp:51
void Calculate(const Vector3D *vertices, const int numVerts)
Definition OBB.cpp:33
Vector3D GetAxis2() const
Definition OBB.h:108
float GetHalfAxis1() const
Definition OBB.h:87
Definition Vector3D.h:12
Definition Archive.h:13