CTextSceneNode.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef __C_TEXT_SCENE_NODE_H_INCLUDED__
  5. #define __C_TEXT_SCENE_NODE_H_INCLUDED__
  6. #include "ITextSceneNode.h"
  7. #include "IBillboardTextSceneNode.h"
  8. #include "IGUIFont.h"
  9. #include "IGUIFontBitmap.h"
  10. #include "ISceneCollisionManager.h"
  11. #include "SMesh.h"
  12. namespace irr
  13. {
  14. namespace scene
  15. {
  16. class CTextSceneNode : public ITextSceneNode
  17. {
  18. public:
  19. //! constructor
  20. CTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
  21. gui::IGUIFont* font, scene::ISceneCollisionManager* coll,
  22. const core::vector3df& position = core::vector3df(0,0,0), const wchar_t* text=0,
  23. video::SColor color=video::SColor(100,0,0,0));
  24. //! destructor
  25. virtual ~CTextSceneNode();
  26. virtual void OnRegisterSceneNode();
  27. //! renders the node.
  28. virtual void render();
  29. //! returns the axis aligned bounding box of this node
  30. virtual const core::aabbox3d<f32>& getBoundingBox() const;
  31. //! sets the text string
  32. virtual void setText(const wchar_t* text);
  33. //! sets the color of the text
  34. virtual void setTextColor(video::SColor color);
  35. //! Returns type of the scene node
  36. virtual ESCENE_NODE_TYPE getType() const { return ESNT_TEXT; }
  37. private:
  38. core::stringw Text;
  39. video::SColor Color;
  40. gui::IGUIFont* Font;
  41. scene::ISceneCollisionManager* Coll;
  42. core::aabbox3d<f32> Box;
  43. };
  44. class CBillboardTextSceneNode : public IBillboardTextSceneNode
  45. {
  46. public:
  47. CBillboardTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
  48. gui::IGUIFont* font,const wchar_t* text,
  49. const core::vector3df& position, const core::dimension2d<f32>& size,
  50. video::SColor colorTop, video::SColor shade_bottom);
  51. //! destructor
  52. virtual ~CBillboardTextSceneNode();
  53. //! sets the vertex positions etc
  54. virtual void OnAnimate(u32 timeMs);
  55. //! registers the node into the transparent pass
  56. virtual void OnRegisterSceneNode();
  57. //! renders the node.
  58. virtual void render();
  59. //! returns the axis aligned bounding box of this node
  60. virtual const core::aabbox3d<f32>& getBoundingBox() const;
  61. //! sets the text string
  62. virtual void setText(const wchar_t* text);
  63. //! sets the color of the text
  64. virtual void setTextColor(video::SColor color);
  65. //! sets the size of the billboard
  66. virtual void setSize(const core::dimension2d<f32>& size);
  67. //! gets the size of the billboard
  68. virtual const core::dimension2d<f32>& getSize() const;
  69. virtual video::SMaterial& getMaterial(u32 i);
  70. //! returns amount of materials used by this scene node.
  71. virtual u32 getMaterialCount() const;
  72. //! Returns type of the scene node
  73. virtual ESCENE_NODE_TYPE getType() const { return ESNT_TEXT; }
  74. //! Set the color of all vertices of the billboard
  75. //! \param overallColor: the color to set
  76. virtual void setColor(const video::SColor & overallColor);
  77. //! Set the color of the top and bottom vertices of the billboard
  78. //! \param topColor: the color to set the top vertices
  79. //! \param bottomColor: the color to set the bottom vertices
  80. virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor);
  81. //! Gets the color of the top and bottom vertices of the billboard
  82. //! \param topColor: stores the color of the top vertices
  83. //! \param bottomColor: stores the color of the bottom vertices
  84. virtual void getColor(video::SColor & topColor, video::SColor & bottomColor) const;
  85. virtual void setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWidth)
  86. {
  87. setSize(core::dimension2df(bottomEdgeWidth, height));
  88. }
  89. virtual void getSize(f32& height, f32& bottomEdgeWidth, f32& topEdgeWidth) const
  90. {
  91. height = Size.Height;
  92. bottomEdgeWidth = Size.Width;
  93. topEdgeWidth = Size.Width;
  94. }
  95. private:
  96. core::stringw Text;
  97. video::SColor Color;
  98. gui::IGUIFontBitmap* Font;
  99. core::dimension2d<f32> Size;
  100. core::aabbox3d<f32> BBox;
  101. video::SMaterial Material;
  102. video::SColor ColorTop;
  103. video::SColor ColorBottom;
  104. struct SSymbolInfo
  105. {
  106. u32 bufNo;
  107. f32 Width;
  108. f32 Kerning;
  109. u32 firstInd;
  110. u32 firstVert;
  111. };
  112. core::array < SSymbolInfo > Symbol;
  113. SMesh *Mesh;
  114. };
  115. } // end namespace scene
  116. } // end namespace irr
  117. #endif