Orxonox  0.0.5 Codename: Arcturus
IcoSphere.h
Go to the documentation of this file.
1 
2 
3 #ifndef _IcoSphere_H__
4 #define _IcoSphere_H__
5 
6 #include "tools/ToolsPrereqs.h"
7 
8 #include <OgreSingleton.h>
9 #include <map>
10 
11 namespace orxonox
12 {
13  typedef std::pair<Ogre::Vector3, Ogre::ColourValue> VertexPair;
14 
25  {
26  public:
28  {
29  int v1, v2, v3;
30 
31  TriangleIndices(int _v1, int _v2, int _v3) :
32  v1(_v1), v2(_v2), v3(_v3)
33  {
34  }
35 
36  bool operator <(const TriangleIndices &o) const
37  {
38  return v1 < o.v1 && v2 < o.v2 && v3 < o.v3;
39  }
40  };
41 
42  struct LineIndices
43  {
44  int v1, v2;
45 
46  LineIndices(int _v1, int _v2) :
47  v1(_v1), v2(_v2)
48  {
49  }
50 
51  bool operator ==(const LineIndices &o) const
52  {
53  return (v1 == o.v1 && v2 == o.v2) || (v1 == o.v2 && v2 == o.v1);
54  }
55  };
56 
57  IcoSphere();
58  ~IcoSphere();
59 
60  void create(int recursionLevel);
61  void addToLineIndices(int baseIndex, std::list<int>* target) const;
62  int addToVertices(std::list<VertexPair>* target, const Ogre::Vector3& position, const Ogre::ColourValue& colour, float scale) const;
63  void addToTriangleIndices(int baseIndex, std::list<int>* target) const;
64 
65  private:
66  int addVertex(const Ogre::Vector3& vertex);
67  void addLineIndices(int index0, int index1);
68  void addTriangleLines(int index0, int index1, int index2);
69  int getMiddlePoint(int index0, int index1);
70  void addFace(int index0, int index1, int index2);
71 
72  void removeLineIndices(int index0, int index1);
73 
74  std::vector<Ogre::Vector3> vertices;
75  std::list<LineIndices> lineIndices;
76  std::list<int> triangleIndices;
77  std::list<TriangleIndices> faces;
78  std::map<int64_t, int> middlePointIndexCache;
79  int index;
80  };
81 }
82 
83 #endif /* _IcoSphere_H__ */
int index
Definition: IcoSphere.h:79
std::map< int64_t, int > middlePointIndexCache
Definition: IcoSphere.h:78
std::list< TriangleIndices > faces
Definition: IcoSphere.h:77
int v1
Definition: IcoSphere.h:44
bool operator<(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:274
LineIndices(int _v1, int _v2)
Definition: IcoSphere.h:46
int v1
Definition: IcoSphere.h:29
int v3
Definition: IcoSphere.h:29
std::list< int > triangleIndices
Definition: IcoSphere.h:76
Copy-pasted from.
Definition: IcoSphere.h:24
Definition: IcoSphere.h:27
Shared library macros, enums, constants and forward declarations for the tools module ...
Definition: IcoSphere.h:42
#define _ToolsExport
Definition: ToolsPrereqs.h:59
Ogre::ColourValue colour(const btVector3 &color, btScalar alpha)
Definition: OgreBulletUtils.h:41
std::vector< Ogre::Vector3 > vertices
Definition: IcoSphere.h:74
TriangleIndices(int _v1, int _v2, int _v3)
Definition: IcoSphere.h:31
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
std::pair< Ogre::Vector3, Ogre::ColourValue > VertexPair
Definition: IcoSphere.h:13
int v2
Definition: IcoSphere.h:44
constexpr bool operator==(bool x, tribool y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: tribool.h:117
int v2
Definition: IcoSphere.h:29
std::list< LineIndices > lineIndices
Definition: IcoSphere.h:75