Orxonox  0.0.5 Codename: Arcturus
DebugDrawer.h
Go to the documentation of this file.
1 
14 #ifndef _DebugDrawer_H__
15 #define _DebugDrawer_H__
16 
17 #include "tools/ToolsPrereqs.h"
18 
19 #include <map>
20 
21 #include "IcoSphere.h"
22 
23 namespace orxonox
24 {
30  {
31  public:
32  DebugDrawer(Ogre::SceneManager *_sceneManager, float _fillAlpha);
33  ~DebugDrawer();
34 
35  void build();
36 
37  void drawLine(const Ogre::Vector3& start, const Ogre::Vector3& end, const Ogre::ColourValue& colour);
38  void drawCircle(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, const Ogre::ColourValue& colour, bool isFilled = false);
39  void drawCylinder(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, float height, const Ogre::ColourValue& colour, bool isFilled = false);
40  void drawCone(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, float height, const Ogre::ColourValue& colour, bool isFilled = false);
41 
42  void drawQuad(const Ogre::Vector3* vertices, const Ogre::ColourValue& colour, bool isFilled = false);
43  void drawCuboid(const Ogre::Vector3* vertices, const Ogre::ColourValue& colour, bool isFilled = false);
44  void drawSphere(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, const Ogre::ColourValue& colour, bool isFilled = false);
45  void drawTetrahedron(const Ogre::Vector3& centre, float scale, const Ogre::ColourValue& colour, bool isFilled = false);
46 
47  void setFillAlpha(float alpha)
48  {
49  fillAlpha = alpha;
50  }
51 
52  bool getEnabled()
53  {
54  return isEnabled;
55  }
56  void setEnabled(bool _isEnabled)
57  {
58  isEnabled = _isEnabled;
59  }
61  {
62  isEnabled = !isEnabled;
63  }
64 
65  void clear();
66 
67  private:
68  const IcoSphere& getIcoSphere(float radius) const;
69 
70  Ogre::SceneManager* sceneManager;
71  float fillAlpha;
72  Ogre::ManualObject* manualObject;
78 
79  bool isEnabled;
80 
81  std::list<VertexPair> lineVertices, triangleVertices;
82  std::list<int> lineIndices, triangleIndices;
83 
84  int linesIndex, trianglesIndex;
85 
86  void initialise();
87  void shutdown();
88 
89  void buildLine(const Ogre::Vector3& start, const Ogre::Vector3& end, const Ogre::ColourValue& colour, float alpha = 1.0f);
90  void buildQuad(const Ogre::Vector3* vertices, const Ogre::ColourValue& colour, float alpha = 1.0f);
91  void buildFilledQuad(const Ogre::Vector3* vertices, const Ogre::ColourValue& colour, float alpha = 1.0f);
92  void buildFilledTriangle(const Ogre::Vector3* vertices, const Ogre::ColourValue& colour, float alpha = 1.0f);
93  void buildCuboid(const Ogre::Vector3* vertices, const Ogre::ColourValue& colour, float alpha = 1.0f);
94  void buildFilledCuboid(const Ogre::Vector3* vertices, const Ogre::ColourValue& colour, float alpha = 1.0f);
95 
96  void buildCircle(const Ogre::Matrix4& transform, float radius, int segmentsCount, const Ogre::ColourValue& colour, float alpha = 1.0f);
97  void buildFilledCircle(const Ogre::Matrix4& transform, float radius, int segmentsCount, const Ogre::ColourValue& colour, bool up, float alpha = 1.0f);
98 
99  void buildCylinder(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, int segmentsCount, float height, const Ogre::ColourValue& colour, float alpha = 1.0f);
100  void buildFilledCylinder(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, int segmentsCount, float height, const Ogre::ColourValue& colour, float alpha = 1.0f);
101 
102  void buildCone(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, int segmentsCount, float height, const Ogre::ColourValue& colour, float alpha = 1.0f);
103  void buildFilledCone(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, int segmentsCount, float height, const Ogre::ColourValue& colour, float alpha = 1.0f);
104 
105  void buildTetrahedron(const Ogre::Vector3& centre, float scale, const Ogre::ColourValue& colour, float alpha = 1.0f);
106  void buildFilledTetrahedron(const Ogre::Vector3& centre, float scale, const Ogre::ColourValue& colour, float alpha = 1.0f);
107 
108  int addLineVertex(const Ogre::Vector3& vertex, const Ogre::ColourValue& colour);
109  void addLineIndices(int index1, int index2);
110 
111  int addTriangleVertex(const Ogre::Vector3& vertex, const Ogre::ColourValue& colour);
112  void addTriangleIndices(int index1, int index2, int index3);
113 
114  void addQuadIndices(int index1, int index2, int index3, int index4);
115  };
116 }
117 
118 #endif /* _DebugDrawer_H__ */
std::list< int > triangleIndices
Definition: DebugDrawer.h:82
void switchEnabled()
Definition: DebugDrawer.h:60
Ogre::SceneManager * sceneManager
Definition: DebugDrawer.h:70
Copy-pasted from.
Definition: IcoSphere.h:24
Shared library macros, enums, constants and forward declarations for the tools module ...
std::list< VertexPair > triangleVertices
Definition: DebugDrawer.h:81
IcoSphere icoSphere1
Definition: DebugDrawer.h:74
#define _ToolsExport
Definition: ToolsPrereqs.h:59
Ogre::ColourValue colour(const btVector3 &color, btScalar alpha)
Definition: OgreBulletUtils.h:41
int trianglesIndex
Definition: DebugDrawer.h:84
float fillAlpha
Definition: DebugDrawer.h:71
Ogre::ManualObject * manualObject
Definition: DebugDrawer.h:72
void setFillAlpha(float alpha)
Definition: DebugDrawer.h:47
IcoSphere icoSphere3
Definition: DebugDrawer.h:76
DebugDrawer is a utility to draw debug shapes (lines, triangles, spheres) with Ogre.
Definition: DebugDrawer.h:29
IcoSphere icoSphere0
Definition: DebugDrawer.h:73
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
IcoSphere icoSphere2
Definition: DebugDrawer.h:75
bool isEnabled
Definition: DebugDrawer.h:79
void setEnabled(bool _isEnabled)
Definition: DebugDrawer.h:56
IcoSphere icoSphere4
Definition: DebugDrawer.h:77
bool getEnabled()
Definition: DebugDrawer.h:52