fork download
  1. #ifndef __C_GRID_SCENE_NODE_H__
  2. #define __C_GRID_SCENE_NODE_H__
  3.  
  4. #include "irrlicht.h"
  5.  
  6. //! Grid scene node
  7. /*! If you need a grid on the XY or ZY axis, simply rotate this node by 90
  8. degrees in the appropiate axis.
  9. This node creates an XZ grid by default, which should be fine for normal use.
  10. Axis Lines are a default Red and Blue for the X and Z axis respectively.
  11.  
  12. Please note that the internal meshbuffer used for the grid has a max size of 65535 indices.
  13.  
  14. Thanks goes to MasterGod for helping to clean up the code and for a few bug fixes.
  15.  
  16. Additional thanks to:
  17. JP for optimising the rendering.
  18. Vins for fixing a nasty crash bug and optimising memory usage.
  19. */
  20.  
  21. class CGridSceneNode : public irr::scene::ISceneNode
  22. {
  23. public:
  24. //! Constructor
  25. CGridSceneNode(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* smgr, irr::s32 id = -1,
  26. irr::u32 spacing = 8, irr::u32 size = 1024, irr::video::SColor gridcolor = irr::video::SColor(255,128,128,128),
  27. irr::u32 accentlineoffset = 8, irr::video::SColor accentgridcolor = irr::video::SColor(255,192,192,192),
  28. bool axislinestate = false);
  29.  
  30. virtual ~CGridSceneNode();
  31.  
  32. //! Will create a copy of this scenenode and it's settings
  33. virtual CGridSceneNode* clone(irr::scene::ISceneNode* newParent = 0, irr::scene::ISceneManager* newSceneManager = 0);
  34.  
  35. //! Pre-Register stuff
  36. virtual void OnRegisterSceneNode();
  37.  
  38. //! Render our grid using 3D lines stored inside the internal meshbuffer
  39. virtual void render();
  40.  
  41. //! Returns our bounding box
  42. virtual const irr::core::aabbox3d<irr::f32>& getBoundingBox() const;
  43.  
  44. //! Returns the total number of materials, in this case, only 1
  45. virtual irr::u32 getMaterialCount() const;
  46.  
  47. //! Returns the only material
  48. virtual irr::video::SMaterial& getMaterial(irr::u32 i);
  49.  
  50. //! Will cause the grid scene node to rebuild it's grid
  51. void RegenerateGrid();
  52.  
  53. //! Returns the Spacing of the grid
  54. irr::u32 GetSpacing();
  55.  
  56. //! Returns the total size of the grid
  57. irr::u32 GetSize();
  58.  
  59. //! Returns the Grid Color
  60. irr::video::SColor GetGridColor();
  61.  
  62. //! Returns the offset of the accent lines
  63. irr::u32 GetAccentlineOffset();
  64.  
  65. //! Returns the Accent Line Color
  66. irr::video::SColor GetAccentlineColor();
  67.  
  68. //! Returns the Active State of the Axis Lines
  69. bool AreAxisLineActive();
  70.  
  71. //! Returns the Color of the "X" axis lines
  72. irr::video::SColor GetAxisLineXColor();
  73.  
  74. //! Returns the Color of the "Z" axis lines
  75. irr::video::SColor GetAxisLineZColor();
  76.  
  77. //! Sets Spacing
  78. void SetSpacing(irr::u32 newspacing);
  79.  
  80. //! Sets Size
  81. void SetSize(irr::u32 newsize);
  82.  
  83. //! Sets the general grid color
  84. void SetGridColor(irr::video::SColor newcolor);
  85.  
  86. //! Sets the offset for the accent lines
  87. //! If > 0, accent lines will be active, otherwise not
  88. void SetAccentlineOffset(irr::u32 newoffset);
  89.  
  90. //! Sets the color of the accent lines
  91. void SetAccentlineColor(irr::video::SColor newcolor);
  92.  
  93. //! Sets whether the lines denoting the center of the grid are active
  94. void SetAxisLineActive(bool active);
  95.  
  96. //! Sets the Color of the "X" axis lines
  97. void SetAxisLineXColor(irr::video::SColor XLine);
  98.  
  99. //! Sets the Color of the "Z" axis lines
  100. void SetAxisLineZColor(irr::video::SColor ZLine);
  101.  
  102. //! Allows for setting a complete new material
  103. void SetMaterial(irr::video::SMaterial newMaterial);
  104.  
  105. private:
  106. irr::u32 m_spacing;
  107. irr::u32 m_size;
  108. irr::video::SColor m_gridcolor;
  109. irr::video::SColor m_accentgridcolor;
  110. irr::u32 m_accentlineoffset;
  111. bool m_AxisLineState;
  112. irr::video::SColor m_XLineColor;
  113. irr::video::SColor m_YLineColor;
  114. irr::video::SColor m_ZLineColor;
  115.  
  116. irr::scene::IDynamicMeshBuffer * m_buffer;
  117. };
  118.  
  119. #endif // __C_GRID_SCENE_NODE_H__
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty