OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Ogre::ConvexBody Class Reference

Holds a solid representation of a convex body. More...

#include <OgreConvexBody.h>

+ Collaboration diagram for Ogre::ConvexBody:

Public Types

typedef vector< Polygon * >::type PolygonList
 

Public Member Functions

 ConvexBody ()
 
 ConvexBody (const ConvexBody &cpy)
 
 ~ConvexBody ()
 
void clip (const Frustum &frustum)
 Clips the body with a frustum. More...
 
void clip (const AxisAlignedBox &aab)
 Clips the body with an AAB. More...
 
void clip (const ConvexBody &body)
 Clips the body with another body. More...
 
void clip (const Plane &pl, bool keepNegative=true)
 Clips the object by the positive half space of a plane. More...
 
void define (const Frustum &frustum)
 Build a new polygon representation from a frustum. More...
 
void define (const AxisAlignedBox &aab)
 Build a new polygon representation from an AAB. More...
 
void define (const Vector3 corners[8])
 Build a new polygon representation from an axis-UNaligned box. More...
 
void extend (const Vector3 &pt)
 Extends the existing body to incorporate the passed in point as a convex hull. More...
 
AxisAlignedBox getAABB (void) const
 Returns an AABB representation. More...
 
const Vector3getNormal (size_t poly)
 Returns the normal of a specified polygon. More...
 
const PolygongetPolygon (size_t poly) const
 Returns a polygon. More...
 
size_t getPolygonCount (void) const
 Returns the current number of polygons. More...
 
const Vector3getVertex (size_t poly, size_t vertex) const
 Returns a specific vertex of a polygon. More...
 
size_t getVertexCount (size_t poly) const
 Returns the number of vertices for a polygon. More...
 
bool hasClosedHull (void) const
 Checks if the body has a closed hull. More...
 
void logInfo () const
 Log details of this body. More...
 
void mergePolygons (void)
 Merges all neighboring polygons into one single polygon if they are lay in the same plane. More...
 
bool operator!= (const ConvexBody &rhs) const
 Determines if the current object is not equal to the compared one. More...
 
bool operator== (const ConvexBody &rhs) const
 Determines if the current object is equal to the compared one. More...
 
void reset (void)
 Resets the object. More...
 

Static Public Member Functions

static void _destroyPool ()
 Tear down the internal polygon pool used to minimise allocations. More...
 
static void _initialisePool ()
 Initialise the internal polygon pool used to minimise allocations. More...
 

Protected Member Functions

void allocateSpace (size_t numPolygons, size_t numVertices)
 Allocates space for an specified amount of polygons with each of them having a specified number of vertices. More...
 
void deletePolygon (size_t poly)
 Deletes a specific polygon. More...
 
void deleteVertex (size_t poly, size_t vertex)
 Deletes a specific vertex of a specific polygon. More...
 
bool findAndEraseEdgePair (const Vector3 &vec, Polygon::EdgeMap &intersectionEdges, Vector3 &vNext) const
 Searches for a pair (an edge) in the intersectionList with an entry that equals vec, and removes it from the passed in list. More...
 
Polygon::EdgeMap getSingleEdges () const
 Returns the single edges in an EdgeMap (= edges where one side is a vertex and the other is empty space (a hole in the body)). More...
 
void insertPolygon (Polygon *pdata, size_t poly)
 Inserts a polygon at a particular point in the body. More...
 
void insertPolygon (Polygon *pdata)
 Inserts a polygon at the end. More...
 
void insertVertex (size_t poly, const Vector3 &vdata, size_t vertex)
 Inserts a vertex for a polygon at a particular point. More...
 
void insertVertex (size_t poly, const Vector3 &vdata)
 Inserts a vertex for a polygon at the end. More...
 
void moveDataFromBody (ConvexBody &body)
 Moves all polygons from the parameter body to this instance. More...
 
void setPolygon (Polygon *pdata, size_t poly)
 Replace a polygon at a particular index. More...
 
void setVertex (size_t poly, const Vector3 &vdata, size_t vertex)
 Replace a specific vertex of a polygon. More...
 
void storeEdgesOfPolygon (size_t poly, Polygon::EdgeMap *edgeMap) const
 Stores the edges of a specific polygon in a passed in structure. More...
 
PolygonunlinkPolygon (size_t poly)
 Removes a specific polygon from the body without deleting it. More...
 

Static Protected Member Functions

static PolygonallocatePolygon ()
 Get a new polygon from the pool. More...
 
static void freePolygon (Polygon *poly)
 Release a polygon back tot he pool. More...
 

Protected Attributes

PolygonList mPolygons
 

Static Protected Attributes

static PolygonList msFreePolygons
 

Friends

_OgreExport friend std::ostream & operator<< (std::ostream &strm, const ConvexBody &body)
 Prints out the body with all its polygons. More...
 

Detailed Description

Holds a solid representation of a convex body.

Remarks
Administers a convex body. All polygons of the body are convex and planar. Several operations may be applied, ranging from intersection to join where each result it itself a convex body.

Definition at line 52 of file OgreConvexBody.h.

Member Typedef Documentation

Definition at line 55 of file OgreConvexBody.h.

Constructor & Destructor Documentation

Ogre::ConvexBody::ConvexBody ( )
Ogre::ConvexBody::~ConvexBody ( )
Ogre::ConvexBody::ConvexBody ( const ConvexBody cpy)

Member Function Documentation

static void Ogre::ConvexBody::_destroyPool ( )
static

Tear down the internal polygon pool used to minimise allocations.

static void Ogre::ConvexBody::_initialisePool ( )
static

Initialise the internal polygon pool used to minimise allocations.

static Polygon* Ogre::ConvexBody::allocatePolygon ( )
staticprotected

Get a new polygon from the pool.

void Ogre::ConvexBody::allocateSpace ( size_t  numPolygons,
size_t  numVertices 
)
protected

Allocates space for an specified amount of polygons with each of them having a specified number of vertices.

Note
Old data (if available) will be erased.
void Ogre::ConvexBody::clip ( const Frustum frustum)

Clips the body with a frustum.

The resulting holes are filled with new polygons.

void Ogre::ConvexBody::clip ( const AxisAlignedBox aab)

Clips the body with an AAB.

The resulting holes are filled with new polygons.

void Ogre::ConvexBody::clip ( const ConvexBody body)

Clips the body with another body.

void Ogre::ConvexBody::clip ( const Plane pl,
bool  keepNegative = true 
)

Clips the object by the positive half space of a plane.

void Ogre::ConvexBody::define ( const Frustum frustum)

Build a new polygon representation from a frustum.

void Ogre::ConvexBody::define ( const AxisAlignedBox aab)

Build a new polygon representation from an AAB.

void Ogre::ConvexBody::define ( const Vector3  corners[8])

Build a new polygon representation from an axis-UNaligned box.

void Ogre::ConvexBody::deletePolygon ( size_t  poly)
protected

Deletes a specific polygon.

void Ogre::ConvexBody::deleteVertex ( size_t  poly,
size_t  vertex 
)
protected

Deletes a specific vertex of a specific polygon.

void Ogre::ConvexBody::extend ( const Vector3 pt)

Extends the existing body to incorporate the passed in point as a convex hull.

Remarks
You must already have constructed a basic body using a 'construct' method.
bool Ogre::ConvexBody::findAndEraseEdgePair ( const Vector3 vec,
Polygon::EdgeMap intersectionEdges,
Vector3 vNext 
) const
protected

Searches for a pair (an edge) in the intersectionList with an entry that equals vec, and removes it from the passed in list.

Parameters
vecThe vertex to search for in intersectionEdges
intersectionEdgesA list of edges, which is updated if a match is found
vNextA reference to a vector which will be filled with the other vertex at the matching edge, if found.
Returns
True if a match was found
static void Ogre::ConvexBody::freePolygon ( Polygon poly)
staticprotected

Release a polygon back tot he pool.

AxisAlignedBox Ogre::ConvexBody::getAABB ( void  ) const

Returns an AABB representation.

const Vector3& Ogre::ConvexBody::getNormal ( size_t  poly)

Returns the normal of a specified polygon.

const Polygon& Ogre::ConvexBody::getPolygon ( size_t  poly) const

Returns a polygon.

size_t Ogre::ConvexBody::getPolygonCount ( void  ) const

Returns the current number of polygons.

Polygon::EdgeMap Ogre::ConvexBody::getSingleEdges ( ) const
protected

Returns the single edges in an EdgeMap (= edges where one side is a vertex and the other is empty space (a hole in the body)).

const Vector3& Ogre::ConvexBody::getVertex ( size_t  poly,
size_t  vertex 
) const

Returns a specific vertex of a polygon.

size_t Ogre::ConvexBody::getVertexCount ( size_t  poly) const

Returns the number of vertices for a polygon.

bool Ogre::ConvexBody::hasClosedHull ( void  ) const

Checks if the body has a closed hull.

void Ogre::ConvexBody::insertPolygon ( Polygon pdata,
size_t  poly 
)
protected

Inserts a polygon at a particular point in the body.

Note
After this method is called, the ConvexBody 'owns' this Polygon and will be responsible for deleting it.
void Ogre::ConvexBody::insertPolygon ( Polygon pdata)
protected

Inserts a polygon at the end.

Note
After this method is called, the ConvexBody 'owns' this Polygon and will be responsible for deleting it.
void Ogre::ConvexBody::insertVertex ( size_t  poly,
const Vector3 vdata,
size_t  vertex 
)
protected

Inserts a vertex for a polygon at a particular point.

Note
No checks are done whether the assembled polygon is (still) planar, the caller must ensure that this is the case.
void Ogre::ConvexBody::insertVertex ( size_t  poly,
const Vector3 vdata 
)
protected

Inserts a vertex for a polygon at the end.

Note
No checks are done whether the assembled polygon is (still) planar, the caller must ensure that this is the case.
void Ogre::ConvexBody::logInfo ( ) const

Log details of this body.

void Ogre::ConvexBody::mergePolygons ( void  )

Merges all neighboring polygons into one single polygon if they are lay in the same plane.

void Ogre::ConvexBody::moveDataFromBody ( ConvexBody body)
protected

Moves all polygons from the parameter body to this instance.

Note
Both the passed in object and this instance are modified
bool Ogre::ConvexBody::operator!= ( const ConvexBody rhs) const
inline

Determines if the current object is not equal to the compared one.

Definition at line 152 of file OgreConvexBody.h.

bool Ogre::ConvexBody::operator== ( const ConvexBody rhs) const

Determines if the current object is equal to the compared one.

void Ogre::ConvexBody::reset ( void  )

Resets the object.

void Ogre::ConvexBody::setPolygon ( Polygon pdata,
size_t  poly 
)
protected

Replace a polygon at a particular index.

Note
Again, the passed in polygon is owned by this object after this call returns, and this object is resonsible for deleting it.
void Ogre::ConvexBody::setVertex ( size_t  poly,
const Vector3 vdata,
size_t  vertex 
)
protected

Replace a specific vertex of a polygon.

Note
No checks are done whether the assembled polygon is (still) planar, the caller must ensure that this is the case.
void Ogre::ConvexBody::storeEdgesOfPolygon ( size_t  poly,
Polygon::EdgeMap edgeMap 
) const
protected

Stores the edges of a specific polygon in a passed in structure.

Polygon* Ogre::ConvexBody::unlinkPolygon ( size_t  poly)
protected

Removes a specific polygon from the body without deleting it.

Note
The retrieved polygon needs to be deleted later by the caller.

Friends And Related Function Documentation

_OgreExport friend std::ostream& operator<< ( std::ostream &  strm,
const ConvexBody body 
)
friend

Prints out the body with all its polygons.

Member Data Documentation

PolygonList Ogre::ConvexBody::mPolygons
protected

Definition at line 58 of file OgreConvexBody.h.

PolygonList Ogre::ConvexBody::msFreePolygons
staticprotected

Definition at line 61 of file OgreConvexBody.h.


The documentation for this class was generated from the following file: