OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreConvexBody.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 Copyright (c) 2006 Matthias Fink, netAllied GmbH <matthias.fink@web.de>
9 
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16 
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 THE SOFTWARE.
27 -----------------------------------------------------------------------------
28 */
29 #ifndef __ConvexBody_H__
30 #define __ConvexBody_H__
31 
32 #include "OgrePrerequisites.h"
33 #include "OgrePolygon.h"
34 #if OGRE_THREAD_SUPPORT
36 #endif
37 #include "OgreHeaderPrefix.h"
38 
39 
40 namespace Ogre
41 {
42 
56  {
57  public:
59 
60  protected:
62 
63  // Static 'free list' of polygons to save reallocation, shared between all bodies
65 #if OGRE_THREAD_SUPPORT
66  OGRE_STATIC_MUTEX(msFreePolygonsMutex);
67 #endif
68 
69  public:
70  ConvexBody();
71  ~ConvexBody();
72  ConvexBody( const ConvexBody& cpy );
73 
76  void define(const Frustum& frustum);
77 
80  void define(const AxisAlignedBox& aab);
81 
85  void clip( const Frustum& frustum );
86 
90  void clip( const AxisAlignedBox& aab );
91 
94  void clip(const ConvexBody& body);
95 
98  void clip(const Plane& pl, bool keepNegative = true);
99 
106  void extend(const Vector3& pt);
107 
110  void reset( void );
111 
114  size_t getPolygonCount( void ) const;
115 
118  size_t getVertexCount( size_t poly ) const;
119 
122  const Polygon& getPolygon( size_t poly ) const;
123 
126  const Vector3& getVertex( size_t poly, size_t vertex ) const;
127 
130  const Vector3& getNormal( size_t poly );
131 
134  AxisAlignedBox getAABB( void ) const;
135 
138  bool hasClosedHull( void ) const;
139 
143  void mergePolygons( void );
144 
147  bool operator == ( const ConvexBody& rhs ) const;
148 
151  bool operator != ( const ConvexBody& rhs ) const
152  { return !( *this == rhs ); }
153 
156  _OgreExport friend std::ostream& operator<< ( std::ostream& strm, const ConvexBody& body );
157 
159  void logInfo() const;
160 
162  static void _initialisePool();
164  static void _destroyPool();
165 
166 
167  protected:
170  static Polygon* allocatePolygon();
172  static void freePolygon(Polygon* poly);
178  void insertPolygon(Polygon* pdata, size_t poly);
184  void insertPolygon(Polygon* pdata);
185 
191  void insertVertex(size_t poly, const Vector3& vdata, size_t vertex);
197  void insertVertex(size_t poly, const Vector3& vdata);
200  void deletePolygon(size_t poly);
201 
206  Polygon* unlinkPolygon(size_t poly);
207 
211  void moveDataFromBody(ConvexBody& body);
212 
215  void deleteVertex(size_t poly, size_t vertex);
216 
221  void setPolygon(Polygon* pdata, size_t poly );
222 
228  void setVertex( size_t poly, const Vector3& vdata, size_t vertex );
229 
233  Polygon::EdgeMap getSingleEdges() const;
234 
237  void storeEdgesOfPolygon(size_t poly, Polygon::EdgeMap *edgeMap) const;
238 
244  void allocateSpace(size_t numPolygons, size_t numVertices);
245 
254  bool findAndEraseEdgePair(const Vector3& vec,
255  Polygon::EdgeMap& intersectionEdges, Vector3& vNext ) const;
256 
257  };
261 }
262 
263 #include "OgreHeaderSuffix.h"
264 
265 #endif
266 
#define _OgreExport
Definition: OgrePlatform.h:260
Defines a plane in 3D space.
Definition: OgrePlane.h:61
A frustum represents a pyramid, capped at the near and far end which is used to represent either a vi...
Definition: OgreFrustum.h:85
Holds a solid representation of a convex body.
A 3D box aligned with the x/y/z axes.
static PolygonList msFreePolygons
The class represents a polygon in 3D space.
Definition: OgrePolygon.h:52
multimap< Vector3, Vector3 >::type EdgeMap
Definition: OgrePolygon.h:58
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
std::ostream & operator<<(std::ostream &o, const TRect< T > &r)
Definition: OgreCommon.h:636
#define OGRE_STATIC_MUTEX(name)
vector< Polygon * >::type PolygonList
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
PolygonList mPolygons
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)