#pragma once
#include "ED_Engine.h"
class EDE_GridSceneNode : public ISceneNode
{
private:
/////////////////
// The Grid Cells
/////////////////
class Cell
{
private:
IDynamicMeshBuffer* meshBuffer;
bool visible;
vector3df topLeft, topRight, bottomLeft, bottomRight, center;
int id;
SMaterial Material;
void setDefaultMaterial();
public:
Cell();
Cell(vector3df topLeft, vector3df topRight, vector3df bottomLeft, vector3df bottomRight, int id, bool visible, SMaterial material);
~Cell();
void RenderCell(IVideoDriver* driver, SColor color);
};
///////////
// The Grid
///////////
vector3df gridPos;
float cellSize;
int width, height;
Cell** gridCells;
SColor color;
aabbox3d<f32> Box;
SMaterial Material;
public:
EDE_GridSceneNode(ISceneNode* parent, ISceneManager* smgr, s32 id = -1);
void init( int width, int height, SColor color, vector3df gridPos = vector3df(0.0f, 0.0f, 0.0f), float cellSize = 1.0f);
void createGridFlat();
void createGridOnTerrain(ITerrainSceneNode* terrainSceneNode);
void renderGrid(IVideoDriver* driver, SColor color);
virtual void OnRegisterSceneNode();
virtual void render();
virtual const core::aabbox3d<f32>& getBoundingBox() const;
virtual u32 getMaterialCount() const;
virtual video::SMaterial& getMaterial(u32 i);
};
I3ByYWdtYSBvbmNlCiNpbmNsdWRlICJFRF9FbmdpbmUuaCIKCmNsYXNzIEVERV9HcmlkU2NlbmVOb2RlIDogcHVibGljIElTY2VuZU5vZGUKewoKICAgIHByaXZhdGU6CgkJLy8vLy8vLy8vLy8vLy8vLy8KCQkvLyBUaGUgR3JpZCBDZWxscwoJCS8vLy8vLy8vLy8vLy8vLy8vCgkJY2xhc3MgQ2VsbAoJCXsKCQkJcHJpdmF0ZToKCQkJCUlEeW5hbWljTWVzaEJ1ZmZlciogbWVzaEJ1ZmZlcjsKCQkJCWJvb2wgdmlzaWJsZTsKCQkJCXZlY3RvcjNkZiB0b3BMZWZ0LCB0b3BSaWdodCwgYm90dG9tTGVmdCwgYm90dG9tUmlnaHQsIGNlbnRlcjsKCQkJCWludCBpZDsKCQkJCVNNYXRlcmlhbCB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