DebugDraw.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef DEBUG_DRAW_H
  2. #define DEBUG_DRAW_H
  3. #include <OgreHardwareVertexBuffer.h>
  4. #include <OgreRenderQueueListener.h>
  5. #include <OgreRoot.h>
  6. #include <OgreSingleton.h>
  7. #include <OgreFont.h>
  8. class DebugDraw : public Ogre::RenderQueueListener, public Ogre::Singleton< DebugDraw >
  9. {
  10. public:
  11. DebugDraw();
  12. virtual ~DebugDraw();
  13. void SetColour( const Ogre::ColourValue& colour );
  14. void SetScreenSpace( const bool screen_space );
  15. void SetZ( const float z );
  16. void SetFadeDistance( const float fade_s, const float fade_e );
  17. enum TextAlignment
  18. {
  19. LEFT,
  20. RIGHT,
  21. CENTER
  22. };
  23. void SetTextAlignment( TextAlignment alignment );
  24. void Line( const float x1, const float y1, const float x2, const float y2 );
  25. void Line3d( const Ogre::Vector3& point1, const Ogre::Vector3& point2 );
  26. void Triangle3d( const Ogre::Vector3& point1, const Ogre::Vector3& point2, const Ogre::Vector3& point3 );
  27. void Quad( const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, const float x4, const float y4 );
  28. void Text( const float x1, const float y1, const Ogre::String& text );
  29. void Text( const Ogre::Vector3& point, const float x, const float y, const Ogre::String& text );
  30. void renderQueueEnded( Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation );
  31. private:
  32. void CreateLineVertexBuffer();
  33. void DestroyLineVertexBuffer();
  34. void CreateLine3dVertexBuffer();
  35. void DestroyLine3dVertexBuffer();
  36. void CreateTriangle3dVertexBuffer();
  37. void DestroyTriangle3dVertexBuffer();
  38. void CreateQuadVertexBuffer();
  39. void DestroyQuadVertexBuffer();
  40. void CreateTextVertexBuffer();
  41. void DestroyTextVertexBuffer();
  42. private:
  43. Ogre::SceneManager* m_SceneManager;
  44. Ogre::RenderSystem* m_RenderSystem;
  45. // line
  46. Ogre::RenderOperation m_LineRenderOp;
  47. Ogre::HardwareVertexBufferSharedPtr m_LineVertexBuffer;
  48. unsigned int m_LineMaxVertexCount;
  49. // line3d
  50. Ogre::RenderOperation m_Line3dRenderOp;
  51. Ogre::HardwareVertexBufferSharedPtr m_Line3dVertexBuffer;
  52. unsigned int m_Line3dMaxVertexCount;
  53. // triangle3d
  54. Ogre::RenderOperation m_Triangle3dRenderOp;
  55. Ogre::HardwareVertexBufferSharedPtr m_Triangle3dVertexBuffer;
  56. unsigned int m_Triangle3dMaxVertexCount;
  57. // quad
  58. Ogre::RenderOperation m_QuadRenderOp;
  59. Ogre::HardwareVertexBufferSharedPtr m_QuadVertexBuffer;
  60. unsigned int m_QuadMaxVertexCount;
  61. // text
  62. Ogre::RenderOperation m_TextRenderOp;
  63. Ogre::HardwareVertexBufferSharedPtr m_TextVertexBuffer;
  64. unsigned int m_TextMaxVertexCount;
  65. Ogre::FontPtr m_Font;
  66. int m_FontHeight;
  67. TextAlignment m_TextAlignment;
  68. Ogre::MaterialPtr m_Material;
  69. Ogre::MaterialPtr m_Material3d;
  70. Ogre::ColourValue m_Colour;
  71. bool m_ScreenSpace;
  72. float m_Z;
  73. float m_FadeStartSquare; // text start fading from this distance
  74. float m_FadeEndSquare; // text fully faded from this distance
  75. };
  76. #define DEBUG_DRAW DebugDraw::getSingleton()
  77. #endif // DEBUG_DRAW_H