68 lines
1.4 KiB
C++
68 lines
1.4 KiB
C++
#ifndef GRIDRENDERER_H
|
|
#define GRIDRENDERER_H
|
|
|
|
#include "MyNode.h"
|
|
|
|
#include <unordered_set>
|
|
|
|
#include "../misc/Renderable3D.h"
|
|
#include "../misc/Shader.h"
|
|
#include "../misc/TriangleData.h"
|
|
|
|
enum class GridRendererColorMode {
|
|
SHOW_NODE_TYPE,
|
|
SHOW_NODE_IMPORTANCE,
|
|
};
|
|
|
|
class GridModel;
|
|
|
|
class GridRenderer {
|
|
|
|
private:
|
|
|
|
// settings
|
|
GridRendererColorMode colorMode = GridRendererColorMode::SHOW_NODE_IMPORTANCE;
|
|
bool showEdges = true;
|
|
bool showNodes = true;
|
|
|
|
struct Color {
|
|
float r,g,b;
|
|
Color() : r(1), g(0), b(0) {;}
|
|
Color(float r, float g, float b) : r(r), g(g), b(b) {;}
|
|
};
|
|
|
|
/** node color depending on the node's type. see ctor */
|
|
Color colors[200];
|
|
|
|
TriangleData edges;
|
|
TriangleData nodes;
|
|
int lastBuildID = 0; // to check whether the model has changed
|
|
|
|
public:
|
|
|
|
/** ctor */
|
|
GridRenderer() {
|
|
|
|
colors[GridNode::TYPE_FLOOR] = Color(0.4, 0.4, 0.4);
|
|
colors[GridNode::TYPE_STAIR] = Color(0,0,1);
|
|
colors[GridNode::TYPE_ELEVATOR] = Color(0,0,1);
|
|
colors[GridNode::TYPE_DOOR] = Color(0.0, 0.0, 0.0);
|
|
|
|
colors[GridNode::TYPE_OUTDOOR] = Color(0.0, 0.5, 0.0);
|
|
|
|
}
|
|
|
|
void setNodeColorMode(const GridRendererColorMode mode) {this->colorMode = mode;}
|
|
void setShowEdges(const bool show) {this->showEdges = show;}
|
|
|
|
/** render the given grid using GL commands */
|
|
void render(const RenderSettings& rs, GridModel* model);
|
|
|
|
private:
|
|
|
|
void rebuildIfNeeded(GridModel* model);
|
|
|
|
};
|
|
|
|
#endif // GRIDRENDERER_H
|