OgreConvexBody.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Copyright (c) 2006 Matthias Fink, netAllied GmbH <matthias.fink@web.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __ConvexBody_H__
#define __ConvexBody_H__
#include "OgrePrerequisites.h"
#include "OgrePolygon.h"
#if OGRE_THREAD_SUPPORT
#include "Threading/OgreThreadHeaders.h"
#endif
#include "OgreHeaderPrefix.h"
namespace Ogre
{
class _OgreExport ConvexBody
{
public:
typedef vector< Polygon* >::type PolygonList;
protected:
PolygonList mPolygons;
// Static 'free list' of polygons to save reallocation, shared between all bodies
static PolygonList msFreePolygons;
#if OGRE_THREAD_SUPPORT
OGRE_STATIC_MUTEX(msFreePolygonsMutex);
#endif
public:
ConvexBody();
~ConvexBody();
ConvexBody( const ConvexBody& cpy );
void define(const Frustum& frustum);
void define(const AxisAlignedBox& aab);
void clip( const Frustum& frustum );
void clip( const AxisAlignedBox& aab );
void clip(const ConvexBody& body);
void clip(const Plane& pl, bool keepNegative = true);
void extend(const Vector3& pt);
void reset( void );
size_t getPolygonCount( void ) const;
size_t getVertexCount( size_t poly ) const;
const Polygon& getPolygon( size_t poly ) const;
const Vector3& getVertex( size_t poly, size_t vertex ) const;
const Vector3& getNormal( size_t poly );
AxisAlignedBox getAABB( void ) const;
bool hasClosedHull( void ) const;
void mergePolygons( void );
bool operator == ( const ConvexBody& rhs ) const;
bool operator != ( const ConvexBody& rhs ) const
{ return !( *this == rhs ); }
_OgreExport friend std::ostream& operator<< ( std::ostream& strm, const ConvexBody& body );
void logInfo() const;
static void _initialisePool();
static void _destroyPool();
protected:
static Polygon* allocatePolygon();
static void freePolygon(Polygon* poly);
void insertPolygon(Polygon* pdata, size_t poly);
void insertPolygon(Polygon* pdata);
void insertVertex(size_t poly, const Vector3& vdata, size_t vertex);
void insertVertex(size_t poly, const Vector3& vdata);
void deletePolygon(size_t poly);
Polygon* unlinkPolygon(size_t poly);
void moveDataFromBody(ConvexBody& body);
void deleteVertex(size_t poly, size_t vertex);
void setPolygon(Polygon* pdata, size_t poly );
void setVertex( size_t poly, const Vector3& vdata, size_t vertex );
Polygon::EdgeMap getSingleEdges() const;
void storeEdgesOfPolygon(size_t poly, Polygon::EdgeMap *edgeMap) const;
void allocateSpace(size_t numPolygons, size_t numVertices);
bool findAndEraseEdgePair(const Vector3& vec,
Polygon::EdgeMap& intersectionEdges, Vector3& vNext ) const;
};
}
#include "OgreHeaderSuffix.h"
#endif
Ogre::ConvexBody::PolygonList
vector< Polygon *>::type PolygonList
Definition: OgreConvexBody.h:58
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Polygon
The class represents a polygon in 3D space.
Definition: OgrePolygon.h:52
OgrePolygon.h
Ogre::Plane
Defines a plane in 3D space.
Definition: OgrePlane.h:61
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
OgrePrerequisites.h
Ogre::operator<<
std::ostream & operator<<(std::ostream &o, const TRect< T > &r)
Definition: OgreCommon.h:636
Ogre::operator!=
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
Definition: OgreMemorySTLAllocator.h:202
Ogre::ConvexBody::mPolygons
PolygonList mPolygons
Definition: OgreConvexBody.h:61
OgreHeaderSuffix.h
OgreThreadHeaders.h
Ogre::ConvexBody
Holds a solid representation of a convex body.
Definition: OgreConvexBody.h:55
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::ConvexBody::msFreePolygons
static PolygonList msFreePolygons
Definition: OgreConvexBody.h:64
OGRE_STATIC_MUTEX
#define OGRE_STATIC_MUTEX(name)
Definition: OgreThreadDefinesBoost.h:48
Ogre::vector
Definition: OgrePrerequisites.h:491
OgreHeaderPrefix.h
Ogre::operator==
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
Definition: OgreMemorySTLAllocator.h:184
Ogre::Polygon::EdgeMap
multimap< Vector3, Vector3 >::type EdgeMap
Definition: OgrePolygon.h:58
Ogre::Frustum
A frustum represents a pyramid, capped at the near and far end which is used to represent either a vi...
Definition: OgreFrustum.h:85
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:54

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.