TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Box.h
Go to the documentation of this file.
1 
16 #ifndef G3D_Box_h
17 #define G3D_Box_h
18 
19 #include "G3D/platform.h"
20 #include "G3D/Vector3.h"
21 #include "G3D/Array.h"
22 #include "G3D/Plane.h"
23 
24 namespace G3D {
25 
26 class CoordinateFrame;
27 class Any;
28 
35 class Box {
36 private:
37 
38  static int32 dummy;
39 
40  friend class CoordinateFrame;
41 
46 
48 
49  float _area;
50 
51  float _volume;
52 
53  void init(
54  const Vector3& min,
55  const Vector3& max);
56 
57 public:
58 
59  Box();
60 
61  explicit Box(const Any& a);
62 
66  Box(const Vector3& min,
67  const Vector3& max);
68 
69  Box(const Vector3& osMin,
70  const Vector3& osMax,
71  const CoordinateFrame& frame);
72 
73  Box(class BinaryInput& b);
74 
75  Box(const class AABox& b);
76 
77  explicit Box(const Point3& p);
78 
79  static Box inf();
80 
81  Any toAny() const;
82 
83  void serialize(class BinaryOutput& b) const;
84  void deserialize(class BinaryInput& b);
85 
94 
96  void getLocalFrame(CoordinateFrame& frame) const;
97 
98  Box operator*(float f) const;
99 
103  inline Vector3 center() const {
104  return _center;
105  }
106 
132  Vector3 corner(int i) const;
133 
137  inline Vector3 axis(int a) const {
138  debugAssert(a < 3);
139  return _edgeVector[a].direction();
140  }
141 
146  inline float extent(int a) const {
147  debugAssert(a < 3);
148  return _edgeVector[a].length();
149  }
150 
151  inline Vector3 extent() const {
152  return Vector3(_edgeVector[0].length(), _edgeVector[1].length(), _edgeVector[2].length());
153  }
154 
185  void getFaceCorners(
186  int f,
187  Vector3& v0,
188  Vector3& v1,
189  Vector3& v2,
190  Vector3& v3) const;
191 
192 
196  bool culledBy
197  (
198  const Array<Plane>& plane,
199  int32& cullingPlaneIndex,
200  const uint32 testMask,
201  uint32& childMask) const;
202 
206  bool culledBy
207  (
208  const Array<Plane>& plane,
209  int32& cullingPlaneIndex = dummy,
210  const uint32 testMask = -1) const;
211 
212  bool contains(
213  const Vector3& point) const;
214 
215  float area() const;
216 
217  float volume() const;
218 
220 
225 
226  void getBounds(class AABox&) const;
227 
228  bool isFinite() const {
229  return G3D::isFinite(_volume);
230  }
231 };
232 
233 }
234 
235 #endif
void getBounds(class AABox &) const
Definition: Box.cpp:463
Vector3 axis(int a) const
Definition: Box.h:137
void getRandomSurfacePoint(Vector3 &P, Vector3 &N=Vector3::ignore()) const
Definition: Box.cpp:416
Vector3 extent() const
Definition: Box.h:151
static Box inf()
Definition: Box.cpp:458
void serialize(class BinaryOutput &b) const
Definition: Box.cpp:118
float volume() const
Definition: Box.cpp:217
static int32 dummy
Definition: Box.h:38
Definition: BinaryInput.h:69
A rigid body RT (rotation-translation) transformation.
Definition: CoordinateFrame.h:59
float extent(int a) const
Definition: Box.h:146
Box()
Definition: Box.cpp:21
Vector3 center() const
Definition: Box.h:103
Definition: AABox.h:25
Dynamic 1D array tuned for performance.
Definition: Array.h:95
float _area
Definition: Box.h:49
static Vector3 & ignore()
Definition: Vector3.cpp:114
void init(const Vector3 &min, const Vector3 &max)
Definition: Box.cpp:149
Vector3 direction() const
Definition: Vector3.h:756
An arbitrary (oriented) 3D box, useful as a bounding box.
Definition: Box.h:35
float length() const
Definition: Vector3.h:751
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Definition: Vector3.h:58
Vector3 corner(int i) const
Definition: Box.cpp:189
void deserialize(class BinaryInput &b)
Definition: Box.cpp:129
Point3 _center
Definition: Box.h:47
float _volume
Definition: Box.h:51
T min(const T &x, const T &y)
Definition: g3dmath.h:305
Easy loading and saving of human-readable configuration files.
Definition: Any.h:184
bool culledBy(const Array< Plane > &plane, int32 &cullingPlaneIndex, const uint32 testMask, uint32 &childMask) const
#define debugAssert(exp)
Definition: debugAssert.h:160
bool contains(const Vector3 &point) const
Definition: Box.cpp:386
void getLocalFrame(CoordinateFrame &frame) const
Definition: Box.cpp:227
Vector3 randomInteriorPoint() const
Definition: Box.cpp:447
Definition: AABox.h:32
float length(float v)
Definition: vectorMath.h:208
bool isFinite() const
Definition: Box.h:228
Definition: BinaryOutput.h:52
float area() const
Definition: Box.cpp:222
int32_t int32
Definition: g3dmath.h:167
Vector3 _edgeVector[3]
Definition: Box.h:45
Any toAny() const
Definition: Box.cpp:80
uint32_t uint32
Definition: g3dmath.h:168
uint8 const P[]
Definition: AuthenticationPackets.cpp:225
CoordinateFrame localFrame() const
Definition: Box.cpp:241
bool isFinite(double x)
Definition: g3dmath.h:525
Box operator*(float f) const
Definition: Box.cpp:104
void getFaceCorners(int f, Vector3 &v0, Vector3 &v1, Vector3 &v2, Vector3 &v3) const
Definition: Box.cpp:248