Advertisement
Guest User

Irrlicht CGridSceneNode.h

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