worked on 3D display
some ui changes refactoring new icons
This commit is contained in:
@@ -9,12 +9,10 @@
|
||||
#include <Indoor/navMesh/NavMeshType.h>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QGLWidget>
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
//enum class GridRendererColorMode {
|
||||
// SHOW_NODE_TYPE,
|
||||
// SHOW_NODE_IMPORTANCE,
|
||||
//};
|
||||
#include "../3D/misc/Renderable3D.h"
|
||||
#include "../3D/misc/Shader.h"
|
||||
|
||||
class NavMeshRenderer {
|
||||
|
||||
@@ -53,10 +51,88 @@ public:
|
||||
|
||||
|
||||
/** render the given grid using GL commands */
|
||||
void paintGL(NM::NavMesh<NM::NavMeshTriangle>* navMesh, QGLWidget* dst) {
|
||||
void render(const RenderSettings& rs, NM::NavMesh<NM::NavMeshTriangle>* navMesh, QOpenGLWidget* dst) {
|
||||
|
||||
if (navMesh == nullptr) {return;}
|
||||
|
||||
|
||||
rs.shader->bind();
|
||||
rs.shader->setModelMatrix(QMatrix4x4());
|
||||
|
||||
std::vector<float> vertices;
|
||||
std::vector<float> colors;
|
||||
|
||||
for (const NM::NavMeshTriangle* tria : *navMesh) {
|
||||
|
||||
Point3 color;
|
||||
|
||||
switch (tria->getType()) {
|
||||
case (int) NM::NavMeshType::FLOOR_INDOOR: color = Point3(0.8, 0.8, 0.8); break;
|
||||
case (int) NM::NavMeshType::FLOOR_OUTDOOR: color = Point3(0.1, 0.8, 0.1); break;
|
||||
case (int) NM::NavMeshType::DOOR: color = Point3(0.7, 0.7, 0.8); break;
|
||||
case (int) NM::NavMeshType::STAIR_LEVELED: color = Point3(0.5, 0.5, 0.5); break;
|
||||
case (int) NM::NavMeshType::STAIR_SKEWED: color = Point3(0.6, 0.6, 0.6); break;
|
||||
}
|
||||
|
||||
vertices.insert(vertices.end(), {tria->getP1().x, tria->getP1().y, tria->getP1().z});
|
||||
vertices.insert(vertices.end(), {tria->getP3().x, tria->getP3().y, tria->getP3().z});
|
||||
vertices.insert(vertices.end(), {tria->getP2().x, tria->getP2().y, tria->getP2().z});
|
||||
|
||||
colors.insert(colors.end(), {color.x, color.y, color.z, 1});
|
||||
colors.insert(colors.end(), {color.x, color.y, color.z, 1});
|
||||
colors.insert(colors.end(), {color.x, color.y, color.z, 1});
|
||||
|
||||
}
|
||||
|
||||
rs.shader->setVertices(vertices.data());
|
||||
rs.shader->setVertexColor(colors.data());
|
||||
glDrawArrays(GL_TRIANGLES, 0, vertices.size()/3);
|
||||
rs.shader->unsetVertices();
|
||||
rs.shader->unsetVertexColor();
|
||||
|
||||
vertices.clear();
|
||||
colors.clear();
|
||||
|
||||
for (const NM::NavMeshTriangle* tria : *navMesh) {
|
||||
|
||||
Point3 color;
|
||||
|
||||
switch (tria->getType()) {
|
||||
case (int) NM::NavMeshType::FLOOR_INDOOR: color = Point3(0.6, 0.6, 0.6); break;
|
||||
case (int) NM::NavMeshType::FLOOR_OUTDOOR: color = Point3(0.0, 0.6, 0.0); break;
|
||||
case (int) NM::NavMeshType::DOOR: color = Point3(0.5, 0.5, 0.6); break;
|
||||
case (int) NM::NavMeshType::STAIR_LEVELED: color = Point3(0.4, 0.4, 0.4); break;
|
||||
case (int) NM::NavMeshType::STAIR_SKEWED: color = Point3(0.4, 0.4, 0.4); break;
|
||||
}
|
||||
|
||||
const float o = 0.001f;
|
||||
vertices.insert(vertices.end(), {tria->getP1().x, tria->getP1().y, tria->getP1().z+o});
|
||||
vertices.insert(vertices.end(), {tria->getP2().x, tria->getP2().y, tria->getP2().z+o});
|
||||
|
||||
vertices.insert(vertices.end(), {tria->getP2().x, tria->getP2().y, tria->getP2().z+o});
|
||||
vertices.insert(vertices.end(), {tria->getP3().x, tria->getP3().y, tria->getP3().z+o});
|
||||
|
||||
vertices.insert(vertices.end(), {tria->getP3().x, tria->getP3().y, tria->getP3().z+o});
|
||||
vertices.insert(vertices.end(), {tria->getP1().x, tria->getP1().y, tria->getP1().z+o});
|
||||
|
||||
colors.insert(colors.end(), {color.x, color.y, color.z, 1});
|
||||
colors.insert(colors.end(), {color.x, color.y, color.z, 1});
|
||||
colors.insert(colors.end(), {color.x, color.y, color.z, 1});
|
||||
colors.insert(colors.end(), {color.x, color.y, color.z, 1});
|
||||
colors.insert(colors.end(), {color.x, color.y, color.z, 1});
|
||||
colors.insert(colors.end(), {color.x, color.y, color.z, 1});
|
||||
|
||||
}
|
||||
|
||||
rs.shader->setVertices(vertices.data());
|
||||
rs.shader->setVertexColor(colors.data());
|
||||
glDrawArrays(GL_LINES, 0, vertices.size()/3);
|
||||
rs.shader->unsetVertices();
|
||||
rs.shader->unsetVertexColor();
|
||||
|
||||
rs.shader->release();
|
||||
|
||||
|
||||
/*
|
||||
|
||||
TODO_GL
|
||||
@@ -68,21 +144,7 @@ public:
|
||||
glBegin(GL_TRIANGLES);
|
||||
for (const NM::NavMeshTriangle* tria : *navMesh) {
|
||||
|
||||
// // get the color to use
|
||||
// switch(colorMode) {
|
||||
// case GridRendererColorMode::SHOW_NODE_TYPE: {
|
||||
// const Color c = colors[n.getType()];
|
||||
// glColor3f(c.r, c.g, c.b);
|
||||
// break;
|
||||
// }
|
||||
|
||||
// case GridRendererColorMode::SHOW_NODE_IMPORTANCE: {
|
||||
// const float xx = n.navImportance - 0.6;
|
||||
// glColor3f(xx, xx, xx);
|
||||
// break;
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
switch (tria->getType()) {
|
||||
case (int) NM::NavMeshType::FLOOR_INDOOR: glColor3f(0.8, 0.8, 0.8); break;
|
||||
|
||||
Reference in New Issue
Block a user