Merge branch 'master' of https://git.frank-ebner.de/FHWS/IndoorMap
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <QPainter>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QOpenGLFunctions>
|
||||
|
||||
#include "../misc/Renderable3D.h"
|
||||
#include "../misc/Shader.h"
|
||||
@@ -35,7 +36,7 @@ public:
|
||||
rs.shader->setVertices(rt.getVertices());
|
||||
rs.shader->setNormals(rt.getNormals());
|
||||
rs.shader->setVertexColor(rt.getRGBA());
|
||||
glDrawArrays(GL_TRIANGLES, 0, rt.count());
|
||||
rs.funcs->glDrawArrays(GL_TRIANGLES, 0, rt.count());
|
||||
rs.shader->unsetVertices();
|
||||
rs.shader->unsetNormals();
|
||||
rs.shader->unsetVertexColor();
|
||||
@@ -45,7 +46,7 @@ public:
|
||||
rs.shader->setColor(0,0,0,128);
|
||||
rs.shader->setVertices(rt2.getVertices());
|
||||
//rs.shader->setVertexColor(rt2.getRGBA());
|
||||
glDrawArrays(GL_LINES, 0, rt2.count());
|
||||
rs.funcs->glDrawArrays(GL_LINES, 0, rt2.count());
|
||||
rs.shader->unsetVertices();
|
||||
//rs.shader->unsetVertexColor();
|
||||
}
|
||||
@@ -56,8 +57,8 @@ public:
|
||||
/** render the given grid using GL commands */
|
||||
void renderTransp(const RenderSettings& rs, const RenderTriangle& rt, bool wireframe) {
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
rs.funcs->glEnable(GL_BLEND);
|
||||
rs.funcs->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
rs.shader->bind();
|
||||
rs.shader->setModelMatrix(QMatrix4x4());
|
||||
@@ -65,7 +66,7 @@ public:
|
||||
rs.shader->setVertices(rt.getVertices());
|
||||
rs.shader->setNormals(rt.getNormals());
|
||||
rs.shader->setVertexColor(rt.getRGBA());
|
||||
glDrawArrays(GL_TRIANGLES, 0, rt.count());
|
||||
rs.funcs->glDrawArrays(GL_TRIANGLES, 0, rt.count());
|
||||
rs.shader->unsetVertices();
|
||||
rs.shader->unsetNormals();
|
||||
rs.shader->unsetVertexColor();
|
||||
@@ -75,14 +76,14 @@ public:
|
||||
rs.shader->setColor(0,0,0,128);
|
||||
rs.shader->setVertices(rt2.getVertices());
|
||||
//rs.shader->setVertexColor(rt2.getRGBA());
|
||||
glDrawArrays(GL_LINES, 0, rt2.count());
|
||||
rs.funcs->glDrawArrays(GL_LINES, 0, rt2.count());
|
||||
rs.shader->unsetVertices();
|
||||
//rs.shader->unsetVertexColor();
|
||||
}
|
||||
|
||||
rs.shader->release();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
rs.funcs->glDisable(GL_BLEND);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -89,27 +89,37 @@ public:
|
||||
|
||||
void rebuild(Floorplan::IndoorMap* im) {
|
||||
|
||||
<<<<<<< HEAD
|
||||
// rebuild the mesh
|
||||
Ray3D::ModelFactory fac(im);
|
||||
fac.exportDoors = showDoors;
|
||||
mesh = fac.getMesh();
|
||||
|
||||
=======
|
||||
>>>>>>> 45592899ee7de1a99f3086205788ff43398fad41
|
||||
triaTransp.clear();
|
||||
triaSolid.clear();
|
||||
|
||||
for (const Ray3D::Obstacle3D& obs : mesh.elements) {
|
||||
const int matID = getMaterial(obs);
|
||||
const Material& mat = mats[matID];
|
||||
for (const Triangle3& tria : obs.triangles) {
|
||||
const Point3 n = cross(tria.p2-tria.p1, tria.p3-tria.p1).normalized();
|
||||
if (mat.a != 255) {
|
||||
triaTransp.addTriangle(tria.p1, tria.p2, tria.p3, n, mat.r/255.0f, mat.g/255.0f, mat.b/255.0f, mat.a/255.0f);
|
||||
} else {
|
||||
triaSolid.addTriangle(tria.p1, tria.p2, tria.p3, n, mat.r/255.0f, mat.g/255.0f, mat.b/255.0f, mat.a/255.0f);
|
||||
// rebuild the mesh
|
||||
try {
|
||||
Ray3D::ModelFactory fac(im);
|
||||
mesh = fac.getMesh();
|
||||
for (const Ray3D::Obstacle3D& obs : mesh.elements) {
|
||||
const int matID = getMaterial(obs);
|
||||
const Material& mat = mats[matID];
|
||||
for (const Triangle3& tria : obs.triangles) {
|
||||
const Point3 n = cross(tria.p2-tria.p1, tria.p3-tria.p1).normalized();
|
||||
if (mat.a != 255) {
|
||||
triaTransp.addTriangle(tria.p1, tria.p2, tria.p3, n, mat.r/255.0f, mat.g/255.0f, mat.b/255.0f, mat.a/255.0f);
|
||||
} else {
|
||||
triaSolid.addTriangle(tria.p1, tria.p2, tria.p3, n, mat.r/255.0f, mat.g/255.0f, mat.b/255.0f, mat.a/255.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(const std::exception& e) {
|
||||
std::cout << "Can't create 3D view. Failed to get mesh from model factory with error: '" << e.what() << "'" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -10,17 +10,17 @@ class RenderTriangle {
|
||||
struct Vertex{
|
||||
float x,y,z;
|
||||
Vertex(const float x, const float y, const float z) : x(x), y(y), z(z) {;}
|
||||
} __attribute__((packed));
|
||||
};
|
||||
|
||||
struct Normal {
|
||||
float x,y,z;
|
||||
Normal(const float x, const float y, const float z) : x(x), y(y), z(z) {;}
|
||||
} __attribute__((packed));
|
||||
};
|
||||
|
||||
struct RGBA {
|
||||
float r,g,b,a;
|
||||
RGBA(const float r, const float g, const float b, const float a) : r(r), g(g), b(b), a(a) {;}
|
||||
} __attribute__((packed));
|
||||
};
|
||||
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<Normal> normals;
|
||||
|
||||
Reference in New Issue
Block a user