93 lines
2.4 KiB
C++
93 lines
2.4 KiB
C++
/*
|
||
* © 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)
|
||
*/
|
||
|
||
#include "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/floorplan/3D/Builder.h>
|
||
|
||
#include "RenderTriangle.h"
|
||
|
||
|
||
/** ctor */
|
||
FloorplanRenderer::FloorplanRenderer() {
|
||
;
|
||
}
|
||
|
||
void FloorplanRenderer::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();
|
||
|
||
}
|
||
|
||
void FloorplanRenderer::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);
|
||
|
||
}
|