This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
IndoorMap/mapview/3D/grid/GridRenderer.h
k-a-z-u 2f37baf497 re-added grid-rendering to the editor
rebuild grid/navMesh 3D data only if needed
2018-07-03 10:53:03 +02:00

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