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
2018-10-25 12:23:40 +02:00

78 lines
1.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* © Copyright 2014 Urheberrechtshinweis
* Alle Rechte vorbehalten / All Rights Reserved
*
* Programmcode ist urheberrechtlich geschuetzt.
* Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner.
* Keine Verwendung ohne explizite Genehmigung.
* (vgl. § 106 ff UrhG / § 97 UrhG)
*/
#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