Ocular Engine
BoundsAABB.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_MATH_BOUNDS_AABB__H__
19 #define __H__OCULAR_MATH_BOUNDS_AABB__H__
20 
21 #include "Math/Bounds/Bounds.hpp"
22 #include "Graphics/Mesh/Vertex.hpp"
23 
24 #include "Math/Matrix4x4.hpp"
25 #include "Math/Vector3.hpp"
26 
27 #include <list>
28 #include <vector>
29 
30 //------------------------------------------------------------------------------------------
31 
36 namespace Ocular
37 {
42  namespace Math
43  {
44  class Ray;
45  class BoundsSphere;
46  class BoundsOBB;
47  class Plane;
48 
63  class BoundsAABB : public Bounds
64  {
65  public:
66 
71  BoundsAABB(std::list<Point3f> const& points, Math::Matrix4x4 const& matrix = Math::Matrix4x4());
72 
76  BoundsAABB(std::vector<Graphics::Vertex> const& vertices, Math::Matrix4x4 const& matrix = Math::Matrix4x4());
77 
84  BoundsAABB(Vector3f const& center, Vector3f const& extents);
85 
86  BoundsAABB();
87 
88  ~BoundsAABB();
89 
95  void construct(std::list<Point3f> const& points, Math::Matrix4x4 const& matrix = Math::Matrix4x4());
96 
100  void construct(std::vector<Graphics::Vertex> const& vertices, Math::Matrix4x4 const& matrix = Math::Matrix4x4());
101 
110  void setCenter(Vector3f const& center);
111 
120  void setExtents(Vector3f const& extents);
121 
125  Vector3f const& getCenter() const;
126 
130  Vector3f const& getExtents() const;
131 
135  Vector3f const& getMinPoint() const;
136 
140  Vector3f const& getMaxPoint() const;
141 
152  void expand(Vector3f const& modifier);
153 
160  void expandToContain(Vector3f const& point);
161 
168  void expandToContain(BoundsAABB const& bounds);
169 
170  //------------------------------------------------------------------------------
171  // Intersection and Containment Testing
172  //------------------------------------------------------------------------------
173 
180  bool intersects(Ray const& ray) const;
181 
195  bool intersects(Ray const& ray, Point3f& point, float& distance) const;
196 
203  bool intersects(BoundsSphere const& bounds) const;
204 
211  bool intersects(BoundsAABB const& bounds) const;
212 
219  bool intersects(BoundsOBB const& bounds) const;
220 
244  bool intersects(Plane const& plane, IntersectionType* result = nullptr) const;
245 
256  bool contains(Vector3f const& point, IntersectionType* result = nullptr) const;
257 
268  bool contains(BoundsAABB const& bounds, IntersectionType* result = nullptr) const;
269 
270  protected:
271 
272  void calculateMinMaxPoints();
273 
274  private:
275 
276  Vector3f m_Center;
277  Vector3f m_Extents;
278  Vector3f m_MinPoint;
279  Vector3f m_MaxPoint;
280  };
281  }
285 }
290 //------------------------------------------------------------------------------------------
291 
292 #endif
Definition: Ray.hpp:47
void expand(Vector3f const &modifier)
Definition: BoundsAABB.cpp:191
bool intersects(Ray const &ray) const
Definition: BoundsAABB.cpp:246
Vector3f const & getMaxPoint() const
Definition: BoundsAABB.cpp:186
void setExtents(Vector3f const &extents)
Definition: BoundsAABB.cpp:165
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
Definition: BoundsOBB.hpp:56
void setCenter(Vector3f const &center)
Definition: BoundsAABB.cpp:159
void construct(std::list< Point3f > const &points, Math::Matrix4x4 const &matrix=Math::Matrix4x4())
Definition: BoundsAABB.cpp:69
Vector3f const & getExtents() const
Definition: BoundsAABB.cpp:176
Definition: Plane.hpp:50
Vector3f const & getMinPoint() const
Definition: BoundsAABB.cpp:181
A 4x4 column-major float matrix.
Definition: Matrix4x4.hpp:64
bool contains(Vector3f const &point, IntersectionType *result=nullptr) const
Definition: BoundsAABB.cpp:336
Definition: Bounds.hpp:45
Definition: BoundsAABB.hpp:63
Definition: BoundsSphere.hpp:52
Vector3f const & getCenter() const
Definition: BoundsAABB.cpp:171
void expandToContain(Vector3f const &point)
Definition: BoundsAABB.cpp:202