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-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 #if !defined(__OGREMAX_VERTEX_H__)
30 #define __OGREMAX_VERTEX_H__
31 
32 #include "OgreColourValue.h"
33 #include "OgreVector3.h"
34 
35 namespace OgreMax {
36 
37 	typedef std::map<int, Ogre::Vector3> TexCoordMap;
38 
39 	class Vertex {
40 	public:
41 
42 		Vertex(float x, float y, float z);
43 
44 		void setNormal(float x, float y, float z);
45 		void setColour(float r, float g, float b, float a = 1.0);
46 		void addTexCoord(int mapIndex, float u, float v, float w = 0.0);
47 
48 		bool operator==(Vertex& other);
49 
getPosition()50 		const Ogre::Vector3& getPosition() const { return m_position; }
getNormal()51 		const Ogre::Vector3& getNormal() const { return m_normal; }
getColour()52 		const Ogre::ColourValue& getColour() const { return m_colour; }
getUVW(int mapIndex)53 		const Ogre::Vector3& getUVW(int mapIndex) const { return m_uvwMap.find(mapIndex)->second; }
54 
55 	private:
56 		bool hasSameTexCoords(std::map<int, Ogre::Vector3>& uvwMap) ;
57 		Ogre::Vector3					m_position;
58 		Ogre::Vector3					m_normal;
59 		Ogre::ColourValue				m_colour;
60 		TexCoordMap						m_uvwMap;
61 	};
62 
63 	class VertexList {
64 	public:
65 		// returns the index into the list for the inserted element
66 		unsigned int add(Vertex& v);
size()67 		size_t size() { return m_vertexList.size(); }
front()68 		const Vertex& front() { return m_vertexList.front(); }
pop()69 		void pop() { m_vertexList.pop_front(); }
70 
71 	private:
72 		std::list<Vertex> m_vertexList;
73 
74 	};
75 
76 }
77 
78 
79 #endif