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-2013 Torus Knot Software Ltd 00008 Copyright (c) 2006 Matthias Fink, netAllied GmbH <matthias.fink@web.de> 00009 00010 Permission is hereby granted, free of charge, to any person obtaining a copy 00011 of this software and associated documentation files (the "Software"), to deal 00012 in the Software without restriction, including without limitation the rights 00013 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00014 copies of the Software, and to permit persons to whom the Software is 00015 furnished to do so, subject to the following conditions: 00016 00017 The above copyright notice and this permission notice shall be included in 00018 all copies or substantial portions of the Software. 00019 00020 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00021 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00022 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00023 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00024 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00025 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00026 THE SOFTWARE. 00027 ----------------------------------------------------------------------------- 00028 */ 00029 #ifndef __ConvexBody_H__ 00030 #define __ConvexBody_H__ 00031 00032 #include "OgrePrerequisites.h" 00033 #include "OgrePolygon.h" 00034 #if OGRE_THREAD_SUPPORT 00035 #include "Threading/OgreThreadHeaders.h" 00036 #endif 00037 #include "OgreHeaderPrefix.h" 00038 00039 00040 namespace Ogre 00041 { 00042 00055 class _OgreExport ConvexBody 00056 { 00057 public: 00058 typedef vector< Polygon* >::type PolygonList; 00059 00060 protected: 00061 PolygonList mPolygons; 00062 00063 // Static 'free list' of polygons to save reallocation, shared between all bodies 00064 static PolygonList msFreePolygons; 00065 #if OGRE_THREAD_SUPPORT 00066 OGRE_STATIC_MUTEX(msFreePolygonsMutex); 00067 #endif 00068 00069 public: 00070 ConvexBody(); 00071 ~ConvexBody(); 00072 ConvexBody( const ConvexBody& cpy ); 00073 00076 void define(const Frustum& frustum); 00077 00080 void define(const AxisAlignedBox& aab); 00081 00085 void clip( const Frustum& frustum ); 00086 00090 void clip( const AxisAlignedBox& aab ); 00091 00094 void clip(const ConvexBody& body); 00095 00098 void clip(const Plane& pl, bool keepNegative = true); 00099 00106 void extend(const Vector3& pt); 00107 00110 void reset( void ); 00111 00114 size_t getPolygonCount( void ) const; 00115 00118 size_t getVertexCount( size_t poly ) const; 00119 00122 const Polygon& getPolygon( size_t poly ) const; 00123 00126 const Vector3& getVertex( size_t poly, size_t vertex ) const; 00127 00130 const Vector3& getNormal( size_t poly ); 00131 00134 AxisAlignedBox getAABB( void ) const; 00135 00138 bool hasClosedHull( void ) const; 00139 00143 void mergePolygons( void ); 00144 00147 bool operator == ( const ConvexBody& rhs ) const; 00148 00151 bool operator != ( const ConvexBody& rhs ) const 00152 { return !( *this == rhs ); } 00153 00156 _OgreExport friend std::ostream& operator<< ( std::ostream& strm, const ConvexBody& body ); 00157 00159 void logInfo() const; 00160 00162 static void _initialisePool(); 00164 static void _destroyPool(); 00165 00166 00167 protected: 00170 static Polygon* allocatePolygon(); 00172 static void freePolygon(Polygon* poly); 00178 void insertPolygon(Polygon* pdata, size_t poly); 00184 void insertPolygon(Polygon* pdata); 00185 00191 void insertVertex(size_t poly, const Vector3& vdata, size_t vertex); 00197 void insertVertex(size_t poly, const Vector3& vdata); 00200 void deletePolygon(size_t poly); 00201 00206 Polygon* unlinkPolygon(size_t poly); 00207 00211 void moveDataFromBody(ConvexBody& body); 00212 00215 void deleteVertex(size_t poly, size_t vertex); 00216 00221 void setPolygon(Polygon* pdata, size_t poly ); 00222 00228 void setVertex( size_t poly, const Vector3& vdata, size_t vertex ); 00229 00233 Polygon::EdgeMap getSingleEdges() const; 00234 00237 void storeEdgesOfPolygon(size_t poly, Polygon::EdgeMap *edgeMap) const; 00238 00244 void allocateSpace(size_t numPolygons, size_t numVertices); 00245 00254 bool findAndEraseEdgePair(const Vector3& vec, 00255 Polygon::EdgeMap& intersectionEdges, Vector3& vNext ) const; 00256 00257 }; 00261 } 00262 00263 #include "OgreHeaderSuffix.h" 00264 00265 #endif 00266
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:41