Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre_src_v1-9-0/OgreMain/include/OgrePolygon.h @ 148

Last change on this file since 148 was 148, checked in by patricwi, 6 years ago

Added new dependencies for ogre1.9 and cegui0.8

File size: 3.9 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2013 Torus Knot Software Ltd
8Copyright (c) 2006 Matthias Fink, netAllied GmbH <matthias.fink@web.de>                                                         
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files (the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26THE SOFTWARE.
27-----------------------------------------------------------------------------
28*/
29#ifndef __Polygon_H__
30#define __Polygon_H__
31
32#include "OgrePrerequisites.h"
33#include "OgreVector3.h"
34#include "OgreHeaderPrefix.h"
35
36
37namespace Ogre
38{
39
40
41        /** \addtogroup Core
42        *  @{
43        */
44        /** \addtogroup Math
45        *  @{
46        */
47        /** The class represents a polygon in 3D space.
48        @remarks
49                It is made up of 3 or more vertices in a single plane, listed in
50                counter-clockwise order.
51        */
52        class _OgreExport Polygon
53        {
54
55        public:
56                typedef vector<Vector3>::type                           VertexList;
57
58                typedef multimap<Vector3, Vector3>::type                EdgeMap;
59                typedef std::pair< Vector3, Vector3>            Edge;
60
61        protected:
62                VertexList              mVertexList;
63                mutable Vector3 mNormal;
64                mutable bool    mIsNormalSet;
65                /** Updates the normal.
66                */
67                void updateNormal(void) const;
68
69
70        public:
71                Polygon();
72                ~Polygon();
73                Polygon( const Polygon& cpy );
74
75                /** Inserts a vertex at a specific position.
76                @note Vertices must be coplanar.
77                */
78                void insertVertex(const Vector3& vdata, size_t vertexIndex);
79                /** Inserts a vertex at the end of the polygon.
80                @note Vertices must be coplanar.
81                */
82                void insertVertex(const Vector3& vdata);
83
84                /** Returns a vertex.
85                */
86                const Vector3& getVertex(size_t vertex) const;
87
88                /** Sets a specific vertex of a polygon.
89                @note Vertices must be coplanar.
90                */
91                void setVertex(const Vector3& vdata, size_t vertexIndex);
92
93                /** Removes duplicate vertices from a polygon.
94                */
95                void removeDuplicates(void);
96
97                /** Vertex count.
98                */
99                size_t getVertexCount(void) const;
100
101                /** Returns the polygon normal.
102                */
103                const Vector3& getNormal(void) const;
104
105                /** Deletes a specific vertex.
106                */
107                void deleteVertex(size_t vertex);
108
109                /** Determines if a point is inside the polygon.
110                @remarks
111                        A point is inside a polygon if it is both on the polygon's plane,
112                        and within the polygon's bounds. Polygons are assumed to be convex
113                        and planar.
114                */
115                bool isPointInside(const Vector3& point) const;
116
117                /** Stores the edges of the polygon in ccw order.
118                        The vertices are copied so the user has to take the
119                        deletion into account.
120                */
121                void storeEdges(EdgeMap *edgeMap) const;
122
123                /** Resets the object.
124                */
125                void reset(void);
126
127                /** Determines if the current object is equal to the compared one.
128                */
129                bool operator == (const Polygon& rhs) const;
130
131                /** Determines if the current object is not equal to the compared one.
132                */
133                bool operator != (const Polygon& rhs) const
134                { return !( *this == rhs ); }
135
136                /** Prints out the polygon data.
137                */
138                _OgreExport friend std::ostream& operator<< ( std::ostream& strm, const Polygon& poly );
139
140        };
141        /** @} */
142        /** @} */
143
144}
145
146#include "OgreHeaderSuffix.h"
147
148#endif
Note: See TracBrowser for help on using the repository browser.