Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgrePolygon.h @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

File size: 3.4 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-2006 Torus Knot Software Ltd
8Copyright (c) 2006 Matthias Fink, netAllied GmbH <matthias.fink@web.de>                                                         
9Also see acknowledgements in Readme.html
10
11This program is free software; you can redistribute it and/or modify it under
12the terms of the GNU Lesser General Public License as published by the Free Software
13Foundation; either version 2 of the License, or (at your option) any later
14version.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
19
20You should have received a copy of the GNU Lesser General Public License along with
21this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22Place - Suite 330, Boston, MA 02111-1307, USA, or go to
23http://www.gnu.org/copyleft/lesser.txt.
24
25You may alternatively use this source under the terms of a specific version of
26the OGRE Unrestricted License provided you have obtained such a license from
27Torus Knot Software Ltd.
28-----------------------------------------------------------------------------
29*/
30#ifndef __Polygon_H__
31#define __Polygon_H__
32
33#include "OgrePrerequisites.h"
34#include "OgreVector3.h"
35
36
37namespace Ogre
38{
39
40
41        /** The class represents a polygon in 3D space.
42        @remarks
43                It is made up of 3 or more vertices in a single plane, listed in
44                counter-clockwise order.
45        */
46        class _OgreExport Polygon
47        {
48
49        public:
50                typedef std::vector<Vector3>                            VertexList;
51
52                typedef std::multimap<Vector3, Vector3>         EdgeMap;
53                typedef std::pair< Vector3, Vector3>            Edge;
54
55        protected:
56                VertexList              mVertexList;
57                Vector3                 mNormal;
58                bool                    mIsNormalSet;
59                /** Updates the normal.
60                */
61                void updateNormal(void);
62
63
64        public:
65                Polygon();
66                ~Polygon();
67                Polygon( const Polygon& cpy );
68
69                /** Inserts a vertex at a specific position.
70                @note Vertices must be coplanar.
71                */
72                void insertVertex(const Vector3& vdata, size_t vertexIndex);
73                /** Inserts a vertex at the end of the polygon.
74                @note Vertices must be coplanar.
75                */
76                void insertVertex(const Vector3& vdata);
77
78                /** Returns a vertex.
79                */
80                const Vector3& getVertex(size_t vertex) const;
81
82                /** Sets a specific vertex of a polygon.
83                @note Vertices must be coplanar.
84                */
85                void setVertex(const Vector3& vdata, size_t vertexIndex);
86
87                /** Removes duplicate vertices from a polygon.
88                */
89                void removeDuplicates(void);
90
91                /** Vertex count.
92                */
93                size_t getVertexCount(void) const;
94
95                /** Returns the polygon normal.
96                */
97                const Vector3& getNormal(void);
98
99                /** Deletes a specific vertex.
100                */
101                void deleteVertex(size_t vertex);
102
103                /** Stores the edges of the polygon in ccw order.
104                        The vertices are copied so the user has to take the
105                        deletion into account.
106                */
107                void storeEdges(EdgeMap *edgeMap) const;
108
109                /** Resets the object.
110                */
111                void reset(void);
112
113                /** Determines if the current object is equal to the compared one.
114                */
115                bool operator == (const Polygon& rhs) const;
116
117                /** Determines if the current object is not equal to the compared one.
118                */
119                bool operator != (const Polygon& rhs) const
120                { return !( *this == rhs ); }
121
122                /** Prints out the polygon data.
123                */
124                _OgreExport friend std::ostream& operator<< ( std::ostream& strm, const Polygon& poly );
125
126        };
127
128}
129
130#endif
Note: See TracBrowser for help on using the repository browser.