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/floorplan/FloorplanRenderer.h

93 lines
2.3 KiB
C++

#ifndef FLOORPLANRENDERER_H
#define FLOORPLANRENDERER_H
#include <unordered_set>
#include <Indoor/navMesh/NavMesh.h>
#include <Indoor/navMesh/NavMeshTriangle.h>
#include <Indoor/navMesh/NavMeshType.h>
#include <QPainter>
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include "../misc/Renderable3D.h"
#include "../misc/Shader.h"
#include "../misc/TriangleData.h"
#include <Indoor/wifi/estimate/ray3/ModelFactory.h>
#include "RenderTriangle.h"
class FloorplanRenderer {
public:
/** ctor */
FloorplanRenderer() {
;
}
/** render the given grid using GL commands */
void renderSolid(const RenderSettings& rs, const RenderTriangle& rt, bool wireframe) {
rs.shader->bind();
rs.shader->setModelMatrix(QMatrix4x4());
rs.shader->setVertices(rt.getVertices());
rs.shader->setNormals(rt.getNormals());
rs.shader->setVertexColor(rt.getRGBA());
rs.funcs->glDrawArrays(GL_TRIANGLES, 0, rt.count());
rs.shader->unsetVertices();
rs.shader->unsetNormals();
rs.shader->unsetVertexColor();
if (wireframe) {
RenderTriangle rt2 = rt.toWireframe(false);
rs.shader->setColor(0,0,0,128);
rs.shader->setVertices(rt2.getVertices());
//rs.shader->setVertexColor(rt2.getRGBA());
rs.funcs->glDrawArrays(GL_LINES, 0, rt2.count());
rs.shader->unsetVertices();
//rs.shader->unsetVertexColor();
}
rs.shader->release();
}
/** render the given grid using GL commands */
void renderTransp(const RenderSettings& rs, const RenderTriangle& rt, bool wireframe) {
rs.funcs->glEnable(GL_BLEND);
rs.funcs->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
rs.shader->bind();
rs.shader->setModelMatrix(QMatrix4x4());
rs.shader->setVertices(rt.getVertices());
rs.shader->setNormals(rt.getNormals());
rs.shader->setVertexColor(rt.getRGBA());
rs.funcs->glDrawArrays(GL_TRIANGLES, 0, rt.count());
rs.shader->unsetVertices();
rs.shader->unsetNormals();
rs.shader->unsetVertexColor();
if (wireframe) {
RenderTriangle rt2 = rt.toWireframe(false);
rs.shader->setColor(0,0,0,128);
rs.shader->setVertices(rt2.getVertices());
//rs.shader->setVertexColor(rt2.getRGBA());
rs.funcs->glDrawArrays(GL_LINES, 0, rt2.count());
rs.shader->unsetVertices();
//rs.shader->unsetVertexColor();
}
rs.shader->release();
rs.funcs->glDisable(GL_BLEND);
}
};
#endif // FLOORPLANRENDERER_H