CmAABox.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #pragma once
  2. #include "CmPrerequisitesUtil.h"
  3. #include "CmVector3.h"
  4. #include "CmMatrix4.h"
  5. namespace CamelotFramework
  6. {
  7. class CM_UTILITY_EXPORT AABox
  8. {
  9. public:
  10. /*
  11. 1-----2
  12. /| /|
  13. / | / |
  14. 5-----4 |
  15. | 0--|--3
  16. | / | /
  17. |/ |/
  18. 6-----7
  19. */
  20. typedef enum CornerEnum {
  21. FAR_LEFT_BOTTOM = 0,
  22. FAR_LEFT_TOP = 1,
  23. FAR_RIGHT_TOP = 2,
  24. FAR_RIGHT_BOTTOM = 3,
  25. NEAR_RIGHT_BOTTOM = 7,
  26. NEAR_LEFT_BOTTOM = 6,
  27. NEAR_LEFT_TOP = 5,
  28. NEAR_RIGHT_TOP = 4
  29. };
  30. AABox();
  31. AABox(const AABox & rkBox);
  32. AABox(const Vector3& min, const Vector3& max);
  33. AABox& operator=(const AABox& rhs);
  34. ~AABox() { }
  35. const Vector3& getMin(void) const { return mMinimum; }
  36. const Vector3& getMax(void) const { return mMaximum; }
  37. void setMin(const Vector3& vec) { mMinimum = vec; }
  38. void setMax(const Vector3& vec) { mMaximum = vec; }
  39. void setExtents(const Vector3& min, const Vector3& max);
  40. Vector3 getCorner(CornerEnum cornerToGet) const;
  41. void merge(const AABox& rhs);
  42. void merge(const Vector3& point);
  43. void transform(const Matrix4& matrix);
  44. void transformAffine(const Matrix4& matrix);
  45. bool intersects(const AABox& b2) const;
  46. AABox intersection(const AABox& b2) const;
  47. float volume() const;
  48. inline void scale(const Vector3& s);
  49. bool intersects(const Sphere& s) const;
  50. bool intersects(const Plane& p) const;
  51. bool intersects(const Vector3& v) const;
  52. Vector3 getCenter() const;
  53. Vector3 getSize() const;
  54. Vector3 getHalfSize() const;
  55. bool contains(const Vector3& v) const;
  56. bool contains(const AABox& other) const;
  57. bool operator== (const AABox& rhs) const;
  58. bool operator!= (const AABox& rhs) const;
  59. static const AABox BOX_EMPTY;
  60. protected:
  61. Vector3 mMinimum;
  62. Vector3 mMaximum;
  63. };
  64. }