#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;
void setDefaultMaterial();
public:
Cell();
Cell(vector3df topLeft, vector3df topRight, vector3df bottomLeft, vector3df bottomRight, int id, bool visible);
~Cell();
void RenderCell(IVideoDriver* driver, SColor color);
};
///////////
// The Grid
///////////
private:
vector3df gridPos;
float cellSize;
int width, height;
Cell** gridCells;
public:
EDE_GridSceneNode(ISceneNode* parent, ISceneManager* smgr, s32 id = -1);
void init( int width, int height, vector3df gridPos = vector3df(0.0f, 0.0f, 0.0f), float cellSize = 1.0f);
void createGridFlat(float cellSize);
void createGridOnTerrain(ISceneNode* terrainSceneNode, float cellSize);
void renderGrid(IVideoDriver* driver, SColor color);
};
I3ByYWdtYSBvbmNlCgojaW5jbHVkZSAiRURfRW5naW5lLmgiCgpjbGFzcyBFREVfR3JpZFNjZW5lTm9kZSA6IHB1YmxpYyBJU2NlbmVOb2RlCnsKCiAgICBwcml2YXRlOgoJLy8vLy8vLy8vLy8vLy8vLy8KCS8vIFRoZSBHcmlkIENlbGxzCgkvLy8vLy8vLy8vLy8vLy8vLwoJY2xhc3MgQ2VsbAoJewoJCXByaXZhdGU6CgkJCUlEeW5hbWljTWVzaEJ1ZmZlciogbWVzaEJ1ZmZlcjsKCQkJYm9vbCB2aXNpYmxlOwoJCQl2ZWN0b3IzZGYgdG9wTGVmdCwgdG9wUmlnaHQsIGJvdHRvbUxlZnQsIGJvdHRvbVJpZ2h0LCBjZW50ZXI7CgkJCWludCBpZDsKCgkJCXZvaWQgc2V0RGVmYXVsdE1hdGVyaWFsKCk7CgoJCXB1YmxpYzoKCQkJQ2VsbCgpOwoJCQlDZWxsKHZlY3RvcjNkZiB0b3BMZWZ0LCB2ZWN0b3IzZGYgdG9wUmlnaHQsIHZlY3RvcjNkZiBib3R0b21M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