40 #ifndef _axisalignedbox_cpp
41 #define _axisalignedbox_cpp
47 #include "MathTools/mathtools.h"
83 return ( this->
MinExt.
X >= this->MaxExt.X &&
84 this->MinExt.Y >= this->MaxExt.Y &&
85 this->MinExt.Z >= this->MaxExt.Z );
91 return ( MathTools::Abs(Diff.
X) * MathTools::Abs(Diff.
Y) * MathTools::Abs(Diff.
Z) );
100 if( NewMin.
X < NewMax.X && NewMin.
Y < NewMax.Y && NewMin.
Z < NewMax.Z ) {
120 {
return MathTools::IsInside(*
this,ToCheck); }
123 {
return MathTools::Overlap(*
this,ToCheck); }
126 {
return MathTools::Overlap(*
this,ToCheck); }
129 {
return MathTools::Overlap(*
this,ToCheck); }
132 {
return MathTools::Intersects(*
this,ToCheck); }
144 {
return ( this->
GetSize() * 0.5 ); }
151 return Vector3( ( XEx == AE_Min ? this->
MinExt.
X : this->MaxExt.X ),
152 ( YEx == AE_Min ? this->MinExt.Y : this->MaxExt.Y ),
153 ( ZEx == AE_Min ? this->MinExt.Z : this->MaxExt.Z ) );
158 switch(WhichSideExtent)
160 case SideMinX:
return this->
MinExt.
X;
161 case SideMinY:
return this->
MinExt.
Y;
162 case SideMinZ:
return this->
MinExt.
Z;
163 case SideMaxX:
return this->
MaxExt.
X;
164 case SideMaxY:
return this->
MaxExt.
Y;
165 case SideMaxZ:
return this->
MaxExt.
Z;
171 Real Extent = GetSideExtent(WhichSidePlane);
172 Real SideMultiplier = (Extent>=0) ? 1 : -1;
173 switch(WhichSidePlane)
218 if( !MinimumNode.
Empty() )
222 if( !MaximumNode.
Empty() )
234 return "AxisAlignedBox";
This is a generic sphere class used for spacial queries.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
AxisExtent
This enum is used to help make querys for data on the AABB.
bool Boole
Generally acts a single bit, true or false.
Boole IsInside(const Vector3 &ToCheck) const
Checks to see if a point is inside this AABB.
Ogre::AxisAlignedBox GetOgreAABB() const
Gets an Ogre::AxisAlignedBox that contains this Spheres information.
Real X
Coordinate on the X vector.
Real Z
Coordinate on the Z vector.
~AxisAlignedBox()
Class destructor.
Thrown when the requested identity could not be found.
Node GetFirstChild() const
Get the first child Node of this Node.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Boole IsZero() const
Gets whether or not this AABB has no size.
void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
Boole IsOverlapping(const Sphere &ToCheck) const
Checks to see if a sphere overlaps with this AABB.
Side
Used to uniquely identify sides of an axis aligned box.
bool Empty() const
Is this storing anything at all?
This is used to represent a flat infinite slice of the game world.
This implements the exception hiearchy for Mezzanine.
void Expand(const Vector3 &Point)
Expands the size of this AABB to encompass it's current bounds plus a point in 3D space...
Vector3 GetCorner(const AxisExtent XEx, const AxisExtent YEx, const AxisExtent ZEx) const
Gets the location of the specified corner.
This file contains the AxisAlignedBox class for representing AABB's of objects in the world...
float Real
A Datatype used to represent a real floating point number.
The interface for serialization.
bool SetValue(const Char8 *rhs)
Set the value of this.
Vector3 & Floor(const Vector3 &Other)
Sets each member of this Vector3 to the lower value between the two vector3s.
Boole operator<=(const AxisAlignedBox &Other) const
Less-than or equals-to operator.
Plane GetSidePlane(Side WhichSidePlane) const
Get a plane corresponding to a side of the box.
A light-weight handle for manipulating nodes in DOM tree.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
static Vector3 Unit_Y()
Gets a vector representing the Y unit of a Vector3.
Vector3 & Ceil(const Vector3 &Other)
Sets each member of this Vector3 to the higher value between the two vector3s.
void ExtractOgreVector3(const Ogre::Vector3 &temp)
Copies an existing Ogre vector3.
Ogre::Vector3 GetOgreVector3() const
Gets a Ogre vector3.
Real Y
Coordinate on the Y vector.
AxisAlignedBox()
Blank constructor.
static String GetSerializableName()
Get the name of the the XML tag this class will leave behind as its instances are serialized...
Boole operator>=(const AxisAlignedBox &Other) const
Less-than operator.
Real GetVolume() const
Gets the total volume of this AABB.
void SetExtents(const Vector3 &Min, const Vector3 &Max)
Sets the minimum and maximum extents of this AABB.
static Vector3 Unit_X()
Gets a vector representing the X unit of a Vector3.
Boole operator!=(const AxisAlignedBox &Other) const
Inequality operator.
void ProtoDeSerialize(const XML::Node &OneNode)
Take the data stored in an XML and overwrite this instance of this object with it.
Vector3 GetHalfSize() const
Gets half the size of this AABB.
static Vector3 Unit_Z()
Gets a vector representing the Z unit of a Vector3.
AxisAlignedBox GetOverlap(const AxisAlignedBox &Other) const
Gets an AABB that has the dimensions of the overlap between this AABB and another AABB...
This is used to represent a point in space, or a vector through space.
Vector3 MinExt
The minimum extents on each axis in world space.
Vector3 GetCenter() const
Gets the center of this AABB.
Boole operator==(const AxisAlignedBox &Other) const
Equality operator.
The bulk of the engine components go in this namspace.
std::pair< Boole, Ray > RayTestResult
This is a type used for the return of a ray intersection test.
void ExtractOgreAABB(const Ogre::AxisAlignedBox &InternalAABB)
Changes this AxisAlignedBox to match the Ogre AxisAlignedBox.
void operator=(const AxisAlignedBox &Other)
Assignment operator.
Boole operator<(const AxisAlignedBox &Other) const
Greater-than or equals-to operator.
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
Boole operator>(const AxisAlignedBox &Other) const
Greater-than operator.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
RayTestResult Intersects(const Ray &ToCheck) const
Checks to see if a ray intersects this AABB.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
std::string String
A datatype used to a series of characters.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
void ProtoSerialize(XML::Node &CurrentRoot) const
Convert this class to an XML::Node ready for serialization.
Vector3 MaxExt
The maximum extents on each axis in world space.
This represents a line placed in 3D space and is used with spacial queries.
Vector3 GetSize() const
Gets the size of this AABB.
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
This is a utility class used to represent the Axis-Aligned Bounding Boxes of objects in various subsy...