5 #ifndef __IRR_AABBOX_3D_H_INCLUDED__ 6 #define __IRR_AABBOX_3D_H_INCLUDED__ 32 aabbox3d(T minx, T miny, T minz, T maxx, T maxy, T maxz):
MinEdge(minx, miny, minz),
MaxEdge(maxx, maxy, maxz) {}
122 const T radius =
getExtent().getLength() / 2;
138 return e.
X * e.
Y * e.
Z;
145 return 2*(e.
X*e.
Y + e.
X*e.
Z + e.
Y*e.
Z);
168 edges[0].
set(middle.
X + diag.
X, middle.
Y + diag.
Y, middle.
Z + diag.
Z);
169 edges[1].
set(middle.
X + diag.
X, middle.
Y - diag.
Y, middle.
Z + diag.
Z);
170 edges[2].
set(middle.
X + diag.
X, middle.
Y + diag.
Y, middle.
Z - diag.
Z);
171 edges[3].
set(middle.
X + diag.
X, middle.
Y - diag.
Y, middle.
Z - diag.
Z);
172 edges[4].
set(middle.
X - diag.
X, middle.
Y + diag.
Y, middle.
Z + diag.
Z);
173 edges[5].
set(middle.
X - diag.
X, middle.
Y - diag.
Y, middle.
Z + diag.
Z);
174 edges[6].
set(middle.
X - diag.
X, middle.
Y + diag.
Y, middle.
Z - diag.
Z);
175 edges[7].
set(middle.
X - diag.
X, middle.
Y - diag.
Y, middle.
Z - diag.
Z);
296 if ((fabs(
t.X) > e.
X + halflength * fabs(linevect.
X)) ||
297 (fabs(
t.Y) > e.
Y + halflength * fabs(linevect.
Y)) ||
298 (fabs(
t.Z) > e.
Z + halflength * fabs(linevect.
Z)) )
301 T
r = e.
Y * (T)fabs(linevect.
Z) + e.
Z * (T)fabs(linevect.
Y);
302 if (fabs(
t.Y*linevect.
Z -
t.Z*linevect.
Y) >
r )
305 r = e.
X * (T)fabs(linevect.
Z) + e.
Z * (T)fabs(linevect.
X);
306 if (fabs(
t.Z*linevect.
X -
t.X*linevect.
Z) >
r )
309 r = e.
X * (T)fabs(linevect.
Y) + e.
Y * (T)fabs(linevect.
X);
310 if (fabs(
t.X*linevect.
Y -
t.Y*linevect.
X) >
r)
326 if (plane.
Normal.X > (T)0)
332 if (plane.
Normal.Y > (T)0)
338 if (plane.
Normal.Z > (T)0)
344 if (plane.
Normal.dotProduct(nearPoint) + plane.
D > (T)0)
347 if (plane.
Normal.dotProduct(farPoint) + plane.
D > (T)0)
aabbox3d(const vector3d< T > &min, const vector3d< T > &max)
Constructor with min edge and max edge.
vector3d< T > MaxEdge
The far edge.
T Y
Y coordinate of the vector.
bool intersectsWithBox(const aabbox3d< T > &other) const
Determines if the axis-aligned box intersects with another axis-aligned box.
T getRadius() const
Get radius of the bounding sphere.
GLdouble GLdouble GLdouble r
float f32
32 bit floating point variable.
bool intersectsWithLine(const line3d< T > &line) const
Tests if the box intersects with a line.
vector3d< T > Normal
Normal vector of the plane.
EIntersectionRelation3D
Enumeration for intersection relations of 3d objects.
T X
X coordinate of the vector.
void reset(const vector3d< T > &initValue)
Resets the bounding box to a one-point box.
vector3d< T > & set(const T nx, const T ny, const T nz)
Everything in the Irrlicht Engine can be found in this namespace.
bool isPointInside(const vector3d< T > &p) const
Determines if a point is within this box.
3d vector template class with lots of operators and methods.
3D line between two points with intersection methods.
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
vector3d< T > getExtent() const
Get extent of the box (maximal distance of two points in the box)
vector3d< T > getVector() const
Get vector of line.
aabbox3d< T > intersect(const aabbox3d< T > &other) const
Returns the intersection of this box with another, if possible.
aabbox3d< T > getInterpolated(const aabbox3d< T > &other, f32 d) const
Calculates a new interpolated bounding box.
EIntersectionRelation3D classifyPlaneRelation(const plane3d< T > &plane) const
Classifies a relation with a plane.
aabbox3d(const vector3d< T > &init)
Constructor with only one point.
bool isFullInside(const aabbox3d< T > &other) const
Check if this box is completely inside the 'other' box.
void addInternalBox(const aabbox3d< T > &b)
Adds another bounding box.
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
aabbox3d< s32 > aabbox3di
Typedef for an integer 3d bounding box.
T getVolume() const
Get the volume enclosed by the box in cubed units.
vector3d< T > getMiddle() const
Get middle of line.
aabbox3d(T minx, T miny, T minz, T maxx, T maxy, T maxz)
Constructor with min edge and max edge as single values, not vectors.
bool isPointTotalInside(const vector3d< T > &p) const
Determines if a point is within this box and not its borders.
bool operator!=(const aabbox3d< T > &other) const
Inequality operator.
Template plane class with some intersection testing methods.
GLint GLint GLint GLint GLint GLint y
const T & min_(const T &a, const T &b)
returns minimum of two values. Own implementation to get rid of the STL (VS6 problems)
const T & max_(const T &a, const T &b)
returns maximum of two values. Own implementation to get rid of the STL (VS6 problems)
T getArea() const
Get the surface area of the box in squared units.
vector3d< T > MinEdge
The near edge.
void addInternalPoint(T x, T y, T z)
Adds a point to the bounding box.
void getEdges(vector3d< T > *edges) const
Stores all 8 edges of the box into an array.
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
void reset(const aabbox3d< T > &initValue)
Resets the bounding box.
GLboolean GLboolean GLboolean b
bool isEmpty() const
Check if the box is empty.
GLint GLint GLint GLint GLint x
T Z
Z coordinate of the vector.
vector3d< T > getCenter() const
Get center of the bounding box.
Axis aligned bounding box in 3d dimensional space.
void repair()
Repairs the box.
bool operator==(const aabbox3d< T > &other) const
Equality operator.
bool intersectsWithLine(const vector3d< T > &linemiddle, const vector3d< T > &linevect, T halflength) const
Tests if the box intersects with a line.
T getLength() const
Get length of line.
aabbox3d()
Default Constructor.