# OgreConvexBody.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004 (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
    00008 Copyright (c) 2006 Matthias Fink, netAllied GmbH <matthias.fink@web.de>
    00009 Also see acknowledgements in Readme.html
    00010
    00011 This program is free software; you can redistribute it and/or modify it under
    00012 the terms of the GNU Lesser General Public License as published by the Free Software
    00013 Foundation; either version 2 of the License, or (at your option) any later
    00014 version.
    00015
    00016 This program is distributed in the hope that it will be useful, but WITHOUT
    00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00018 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00019
    00020 You should have received a copy of the GNU Lesser General Public License along with
    00021 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00022 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00023 http://www.gnu.org/copyleft/lesser.txt.
    00024
    00025 You may alternatively use this source under the terms of a specific version of
    00026 the OGRE Unrestricted License provided you have obtained such a license from
    00027 Torus Knot Software Ltd.
    00028 -----------------------------------------------------------------------------
    00029 */
    00030 #ifndef __ConvexBody_H__
    00031 #define __ConvexBody_H__
    00032
    00033 #include "OgrePrerequisites.h"
    00034 #include "OgrePolygon.h"
    00035
    00036
    00037 namespace Ogre
    00038 {
    00039
    00046     class _OgreExport ConvexBody
    00047     {
    00048     public:
    00049         typedef std::vector< Polygon* > PolygonList;
    00050
    00051     protected:
    00052         PolygonList mPolygons;
    00053
    00054         // Static 'free list' of polygons to save reallocation, shared between all bodies
    00055         static PolygonList msFreePolygons;
    00056 #if OGRE_THREAD_SUPPORT
    00057         static boost::recursive_mutex msFreePolygonsMutex;
    00058 #endif
    00059
    00060     public:
    00061         ConvexBody();
    00062         ~ConvexBody();
    00063         ConvexBody( const ConvexBody& cpy );
    00064
    00067         void define(const Frustum& frustum);
    00068
    00071         void define(const AxisAlignedBox& aab);
    00072
    00076         void clip( const Frustum& frustum );
    00077
    00081         void clip( const AxisAlignedBox& aab );
    00082
    00085         void clip(const ConvexBody& body);
    00086
    00089         void clip(const Plane& pl, bool keepNegative = true);
    00090
    00097         void extend(const Vector3& pt);
    00098
    00101         void reset( void );
    00102
    00105         size_t getPolygonCount( void ) const;
    00106
    00109         size_t getVertexCount( size_t poly ) const;
    00110
    00113         const Polygon& getPolygon( size_t poly ) const;
    00114
    00117         const Vector3& getVertex( size_t poly, size_t vertex ) const;
    00118
    00121         const Vector3& getNormal( size_t poly );
    00122
    00125         AxisAlignedBox getAABB( void ) const;
    00126
    00129         bool hasClosedHull( void ) const;
    00130
    00134         void mergePolygons( void );
    00135
    00138         bool operator == ( const ConvexBody& rhs ) const;
    00139
    00142         bool operator != ( const ConvexBody& rhs ) const
    00143         { return !( *this == rhs ); }
    00144
    00147         _OgreExport friend std::ostream& operator<< ( std::ostream& strm, const ConvexBody& body );
    00148
    00150         void logInfo() const;
    00151
    00153         static void _initialisePool();
    00155         static void _destroyPool();
    00156
    00157
    00158     protected:
    00161         static Polygon* allocatePolygon();
    00163         static void freePolygon(Polygon* poly);
    00169         void insertPolygon(Polygon* pdata, size_t poly);
    00175         void insertPolygon(Polygon* pdata);
    00176
    00182         void insertVertex(size_t poly, const Vector3& vdata, size_t vertex);
    00188         void insertVertex(size_t poly, const Vector3& vdata);
    00191         void deletePolygon(size_t poly);
    00192
    00197         Polygon* unlinkPolygon(size_t poly);
    00198
    00202         void moveDataFromBody(ConvexBody& body);
    00203
    00206         void deleteVertex(size_t poly, size_t vertex);
    00207
    00212         void setPolygon(Polygon* pdata, size_t poly );
    00213
    00219         void setVertex( size_t poly, const Vector3& vdata, size_t vertex );
    00220
    00224         Polygon::EdgeMap getSingleEdges() const;
    00225
    00228         void storeEdgesOfPolygon(size_t poly, Polygon::EdgeMap *edgeMap) const;
    00229
    00235         void allocateSpace(size_t numPolygons, size_t numVertices);
    00236
    00245         bool findAndEraseEdgePair(const Vector3& vec,
    00246             Polygon::EdgeMap& intersectionEdges, Vector3& vNext ) const;
    00247
    00248     };
    00249 }
    00250
    00251 #endif
    00252

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sat May 10 16:24:57 2008