From d746a253be0b04c4b69c52db77f085574333d0fa Mon Sep 17 00:00:00 2001 From: Markus Bullmann Date: Tue, 27 Mar 2018 12:25:42 +0200 Subject: [PATCH 01/12] Added .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..86a9657 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pro.user \ No newline at end of file From 0b0db2b7064cc60092ab832fa68f2327975b75e8 Mon Sep 17 00:00:00 2001 From: Markus Bullmann Date: Tue, 27 Mar 2018 14:04:31 +0200 Subject: [PATCH 02/12] VS fixes --- IndoorMap.pro | 9 +- MainController.cpp | 2 +- mapview/2D/tools/ToolSelector.h | 2 +- mapview/3D/MV3DElementFloorOutline.h | 6 +- mapview/3D/MapView3D.cpp | 6 +- mapview/3D/floorplan/RenderTriangle.h | 6 +- mapview/3D/misc/Polygon.h | 170 +++++++++++++------------- tree/MapTreeModel.h | 7 +- 8 files changed, 109 insertions(+), 99 deletions(-) diff --git a/IndoorMap.pro b/IndoorMap.pro index 692ea49..59635a4 100644 --- a/IndoorMap.pro +++ b/IndoorMap.pro @@ -6,7 +6,7 @@ QT += core gui opengl -CONFIG += c++11 -g3 -O0 +CONFIG += c++17 -g3 -O0 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets svg @@ -16,13 +16,18 @@ TEMPLATE = app DEFINES += WITH_ASSERTIONS DEFINES += WITH_DEBUG_LOG +win32 { + DEFINES += _USE_MATH_DEFINES + + LIBS+= -llibGLESV2d +} + INCLUDEPATH += \ ../ SOURCES += \ - lib/gpc/gpc.cpp \ main.cpp \ MainWindow.cpp \ MainController.cpp \ diff --git a/MainController.cpp b/MainController.cpp index b609756..08544cc 100644 --- a/MainController.cpp +++ b/MainController.cpp @@ -103,7 +103,7 @@ MainController::MainController() { connect(mw, &MainWindow::onGridNodeColorType, [&] () {mw->getMapView3D()->getGridRenderer()->setNodeColorMode(GridRendererColorMode::SHOW_NODE_TYPE);} ); connect(mw, &MainWindow::onGridShowEdges, [&] (const bool show) {mw->getMapView3D()->getGridRenderer()->setShowEdges(show);} ); - Ray3D::OBJPool::get().init("/mnt/vm/paper/diss/code/IndoorMap/res/mdl/"); + Ray3D::OBJPool::get().init("C:/Temp/"); //mapModel->load("../IndoorMap/maps/SHL36_noel.xml"); //mapModel->load("../IndoorMap/maps/SHL38_no_elev.xml"); diff --git a/mapview/2D/tools/ToolSelector.h b/mapview/2D/tools/ToolSelector.h index 82e1f5a..5fa19bb 100644 --- a/mapview/2D/tools/ToolSelector.h +++ b/mapview/2D/tools/ToolSelector.h @@ -232,7 +232,7 @@ private: const float g = m->getScaler().sm(15); // increase each BBox by 15 px (needed mainly for hor/ver lines) -#warning "which elements to select? among all currently visible? or only among the selected layer?" +#pragma message "which elements to select? among all currently visible? or only among the selected layer?" // get all elements with bounding-box matchings std::vector possible; // for (MapModelElement* el : m->getModel()->getSelectedLayerElements()) { diff --git a/mapview/3D/MV3DElementFloorOutline.h b/mapview/3D/MV3DElementFloorOutline.h index c397476..420e3e9 100644 --- a/mapview/3D/MV3DElementFloorOutline.h +++ b/mapview/3D/MV3DElementFloorOutline.h @@ -2,12 +2,12 @@ #define MV3DELEMENTFLOOROUTLINE_H #include +#include #include "misc/Cube.h" #include "MV3DElement.h" #include "../../lib/gpc/gpc.h" -#include "misc/Polygon.h" #include "misc/Outline.h" class MV3DElementFloorOutline : public MV3DElement { @@ -17,7 +17,7 @@ class MV3DElementFloorOutline : public MV3DElement { struct Temp { Point2 cacheSum; - Polygon* pol = nullptr; + Ray3D::Polygon* pol = nullptr; std::vector> trias; }; @@ -80,7 +80,7 @@ protected: std::vector add; std::vector rem; if (tmp.pol) {delete tmp.pol;} - tmp.pol = new Polygon(); + tmp.pol = new Ray3D::Polygon(); // all to-be-added polygons (filter!) for (Floorplan::FloorOutlinePolygon* poly : polys) { diff --git a/mapview/3D/MapView3D.cpp b/mapview/3D/MapView3D.cpp index 5695fd2..760e4b9 100644 --- a/mapview/3D/MapView3D.cpp +++ b/mapview/3D/MapView3D.cpp @@ -295,7 +295,7 @@ void MapView3D::draw() { V.rotate(rot.z, 0.0, 0.0, 1.0); V.translate(center.x, center.y, center.z); - float far = 200; // TODO + float farPlane = 200; // TODO // projection QMatrix4x4 P; @@ -306,14 +306,14 @@ void MapView3D::draw() { float h = height() / 30; viewport.size.x = w; viewport.size.y = h; - P.perspective(45.0f, aspect, 0.01, far); + P.perspective(45.0f, aspect, 0.01, farPlane); } else { // default size: 50 * 50/aspect meters float w = 50.0f; float h = 50.0f * height() / width(); viewport.size.x = w; viewport.size.y = h; - P.ortho(-w, +w, -h, +h, 0.1f, +far); + P.ortho(-w, +w, -h, +h, 0.1f, +farPlane); } rs.shader->bind(); diff --git a/mapview/3D/floorplan/RenderTriangle.h b/mapview/3D/floorplan/RenderTriangle.h index 36fe82f..c229705 100644 --- a/mapview/3D/floorplan/RenderTriangle.h +++ b/mapview/3D/floorplan/RenderTriangle.h @@ -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 vertices; std::vector normals; diff --git a/mapview/3D/misc/Polygon.h b/mapview/3D/misc/Polygon.h index 8b5536c..d24939a 100644 --- a/mapview/3D/misc/Polygon.h +++ b/mapview/3D/misc/Polygon.h @@ -1,110 +1,112 @@ -#ifndef POLYGON_H -#define POLYGON_H +// Duplicated file with Indoor/wifi/estimate/ray3/ModelFactoryHelper.h + +//#ifndef POLYGON_H +//#define POLYGON_H -#include -#include "../../../lib/gpc/gpc.h" +//#include +//#include "../../../lib/gpc/gpc.h" -class Polygon { +//class Polygon_ { - struct GPCPolygon : gpc_polygon { - GPCPolygon() { -// contour = (gpc_vertex_list*) calloc(0, 1024); -// contour->num_vertices = 0; -// contour->vertex = (gpc_vertex*) calloc(0, 1024); -// hole = (int*) calloc(0, 1024); - num_contours = 0; - contour = nullptr; - hole = nullptr; - } - ~GPCPolygon() { - if (contour) { - gpc_free_polygon(this); - //free(contour->vertex); contour->vertex = nullptr; - } - free(contour); contour = nullptr; - free(hole); hole = nullptr; +// struct GPCPolygon : gpc_polygon { +// GPCPolygon() { +//// contour = (gpc_vertex_list*) calloc(0, 1024); +//// contour->num_vertices = 0; +//// contour->vertex = (gpc_vertex*) calloc(0, 1024); +//// hole = (int*) calloc(0, 1024); +// num_contours = 0; +// contour = nullptr; +// hole = nullptr; +// } +// ~GPCPolygon() { +// if (contour) { +// gpc_free_polygon(this); +// //free(contour->vertex); contour->vertex = nullptr; +// } +// free(contour); contour = nullptr; +// free(hole); hole = nullptr; - } - GPCPolygon& operator = (const GPCPolygon& o) = delete; - GPCPolygon& operator = (GPCPolygon& o) { - this->contour = o.contour; - this->hole = o.hole; - this->num_contours = o.num_contours; - o.contour = nullptr; - o.hole = nullptr; - return *this; - } - }; +// } +// GPCPolygon& operator = (const GPCPolygon& o) = delete; +// GPCPolygon& operator = (GPCPolygon& o) { +// this->contour = o.contour; +// this->hole = o.hole; +// this->num_contours = o.num_contours; +// o.contour = nullptr; +// o.hole = nullptr; +// return *this; +// } +// }; -private: +//private: - GPCPolygon state; +// GPCPolygon state; -public: +//public: - void add(const Floorplan::Polygon2& poly) { - GPCPolygon cur = toGPC(poly); - //GPCPolygon out; - gpc_polygon_clip(GPC_UNION, &state, &cur, &state); - //state = out; - } +// void add(const Floorplan::Polygon2& poly) { +// GPCPolygon cur = toGPC(poly); +// //GPCPolygon out; +// gpc_polygon_clip(GPC_UNION, &state, &cur, &state); +// //state = out; +// } - void remove(const Floorplan::Polygon2& poly) { - GPCPolygon cur = toGPC(poly); - //GPCPolygon out; - gpc_polygon_clip(GPC_DIFF, &state, &cur, &state); - //state = out; - } +// void remove(const Floorplan::Polygon2& poly) { +// GPCPolygon cur = toGPC(poly); +// //GPCPolygon out; +// gpc_polygon_clip(GPC_DIFF, &state, &cur, &state); +// //state = out; +// } - std::vector> get(float z) { +// std::vector> get(float z) { - gpc_tristrip res; - res.num_strips = 0; - res.strip = nullptr; +// gpc_tristrip res; +// res.num_strips = 0; +// res.strip = nullptr; - //res.strip = (gpc_vertex_list*) malloc(1024); - gpc_polygon_to_tristrip(&state, &res); +// //res.strip = (gpc_vertex_list*) malloc(1024); +// gpc_polygon_to_tristrip(&state, &res); - std::vector> trias; +// std::vector> trias; - for (int i = 0; i < res.num_strips; ++i) { - gpc_vertex_list lst = res.strip[i]; - std::vector tria; - for (int j = 0; j < lst.num_vertices; ++j) { - gpc_vertex& vert = lst.vertex[j]; - Point3 p3(vert.x, vert.y, z); - tria.push_back(p3); - } - trias.push_back(tria); - } +// for (int i = 0; i < res.num_strips; ++i) { +// gpc_vertex_list lst = res.strip[i]; +// std::vector tria; +// for (int j = 0; j < lst.num_vertices; ++j) { +// gpc_vertex& vert = lst.vertex[j]; +// Point3 p3(vert.x, vert.y, z); +// tria.push_back(p3); +// } +// trias.push_back(tria); +// } - gpc_free_tristrip(&res); +// gpc_free_tristrip(&res); - return std::move(trias); +// return std::move(trias); - } +// } -private: +//private: - GPCPolygon toGPC(Floorplan::Polygon2 poly) { +// GPCPolygon toGPC(Floorplan::Polygon2 poly) { - std::vector verts; - for (Point2 p2 : poly.points) { - gpc_vertex vert; vert.x = p2.x; vert.y = p2.y; - verts.push_back(vert); - } +// std::vector verts; +// for (Point2 p2 : poly.points) { +// gpc_vertex vert; vert.x = p2.x; vert.y = p2.y; +// verts.push_back(vert); +// } - GPCPolygon gpol; - gpc_vertex_list list; - list.num_vertices = verts.size(); - list.vertex = verts.data(); - gpc_add_contour(&gpol, &list, 0); +// GPCPolygon gpol; +// gpc_vertex_list list; +// list.num_vertices = verts.size(); +// list.vertex = verts.data(); +// gpc_add_contour(&gpol, &list, 0); - return gpol; +// return gpol; - } +// } -}; +//}; -#endif // POLYGON_H +//#endif // POLYGON_H diff --git a/tree/MapTreeModel.h b/tree/MapTreeModel.h index bc8a6af..3095847 100644 --- a/tree/MapTreeModel.h +++ b/tree/MapTreeModel.h @@ -41,8 +41,11 @@ public: _parent = static_cast(parent.internalPointer()); } - return createIndex(row, column, _parent->getSubLayers().at(row)); - + if (_parent->getSubLayers().size() > 0) { + return createIndex(row, column, _parent->getSubLayers().at(row)); + } else { + return createIndex(0, 0, nullptr); + } } virtual QModelIndex parent(const QModelIndex& child) const override { From c4b07dcee65e5ec59b345124ce84e792d7bcfc99 Mon Sep 17 00:00:00 2001 From: k-a-z-u Date: Tue, 3 Apr 2018 16:13:44 +0200 Subject: [PATCH 03/12] added objects minor changes --- IndoorMap.pro | 7 +- MainController.cpp | 9 ++- main.cpp | 2 + res/mdl/dude1.obj | 164 +++++++++++++++++++++++++++++++++++++++++++++ res/mdl/dude2.obj | 164 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 341 insertions(+), 5 deletions(-) create mode 100644 res/mdl/dude1.obj create mode 100644 res/mdl/dude2.obj diff --git a/IndoorMap.pro b/IndoorMap.pro index 692ea49..3101202 100644 --- a/IndoorMap.pro +++ b/IndoorMap.pro @@ -6,7 +6,8 @@ QT += core gui opengl -CONFIG += c++11 -g3 -O0 +CONFIG += c++17 -g3 -O0 +LIBS += -lstdc++fs greaterThan(QT_MAJOR_VERSION, 4): QT += widgets svg @@ -16,13 +17,13 @@ TEMPLATE = app DEFINES += WITH_ASSERTIONS DEFINES += WITH_DEBUG_LOG + INCLUDEPATH += \ ../ SOURCES += \ - lib/gpc/gpc.cpp \ main.cpp \ MainWindow.cpp \ MainController.cpp \ @@ -172,7 +173,7 @@ HEADERS += MainWindow.h \ mapview/3D/grid/GridModel.h \ mapview/3D/grid/GridRenderer.h \ mapview/3D/grid/MyNode.h \ - mapview/3D/navMesh/NavMeshModel.h \ + mapview/3D/navMesh/NavMeshModel.h \ mapview/3D/navMesh/NavMeshRenderer.h \ mapview/3D/navMesh/QNavMeshSettings.h \ mapview/3D/misc/TriangleData.h \ diff --git a/MainController.cpp b/MainController.cpp index b609756..449a00f 100644 --- a/MainController.cpp +++ b/MainController.cpp @@ -103,7 +103,12 @@ MainController::MainController() { connect(mw, &MainWindow::onGridNodeColorType, [&] () {mw->getMapView3D()->getGridRenderer()->setNodeColorMode(GridRendererColorMode::SHOW_NODE_TYPE);} ); connect(mw, &MainWindow::onGridShowEdges, [&] (const bool show) {mw->getMapView3D()->getGridRenderer()->setShowEdges(show);} ); - Ray3D::OBJPool::get().init("/mnt/vm/paper/diss/code/IndoorMap/res/mdl/"); + //Ray3D::OBJPool::get().init("/mnt/vm/paper/diss/code/IndoorMap/res/mdl/"); + //Ray3D::OBJPool::get().init("/apps/paper/diss/code/IndoorMap/res/mdl/"); + Ray3D::OBJPool::get().init({ + "/mnt/vm/paper/diss/code/IndoorMap/res/mdl/", + "/apps/paper/diss/code/IndoorMap/res/mdl/", + }); //mapModel->load("../IndoorMap/maps/SHL36_noel.xml"); //mapModel->load("../IndoorMap/maps/SHL38_no_elev.xml"); @@ -113,7 +118,7 @@ MainController::MainController() { //mapModel->load("/mnt/vm/paper/diss/data/maps/test_in_out_overlap.xml"); - mapModel->load("/mnt/vm/paper/diss/data/maps/walkmodel_stairs3.xml"); + //mapModel->load("/mnt/vm/paper/diss/data/maps/walkmodel_stairs3.xml"); //mapModel->load("/mnt/vm/paper/diss/data/maps/SHL42_nm.xml"); //mapModel->load("/apps/paper/diss/data/maps/SHL41_nm.xml"); diff --git a/main.cpp b/main.cpp index ed98f72..48d844e 100644 --- a/main.cpp +++ b/main.cpp @@ -3,6 +3,8 @@ #include "MainController.h" #include +#include +#include //#include "exp.h" //#include "ray.h" diff --git a/res/mdl/dude1.obj b/res/mdl/dude1.obj new file mode 100644 index 0000000..397bbc0 --- /dev/null +++ b/res/mdl/dude1.obj @@ -0,0 +1,164 @@ +# Blender v2.79 (sub 0) OBJ File: 'dude1.blend' +# www.blender.org +v 0.050000 0.225000 0.750000 +v 0.050000 0.225000 1.450000 +v -0.050000 0.225000 0.750000 +v -0.050000 0.225000 1.450000 +v 0.050000 0.325000 0.750000 +v 0.050000 0.325000 1.450000 +v -0.050000 0.325000 0.750000 +v -0.050000 0.325000 1.450000 +vn 0.0000 -1.0000 0.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 1.0000 0.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 0.0000 1.0000 +s off +f 2//1 3//1 1//1 +f 4//2 7//2 3//2 +f 8//3 5//3 7//3 +f 6//4 1//4 5//4 +f 7//5 1//5 3//5 +f 4//6 6//6 8//6 +f 2//1 4//1 3//1 +f 4//2 8//2 7//2 +f 8//3 6//3 5//3 +f 6//4 2//4 1//4 +f 7//5 5//5 1//5 +f 4//6 2//6 6//6 +v 0.050000 -0.325000 0.750000 +v 0.050000 -0.325000 1.450000 +v -0.050000 -0.325000 0.750000 +v -0.050000 -0.325000 1.450000 +v 0.050000 -0.225000 0.750000 +v 0.050000 -0.225000 1.450000 +v -0.050000 -0.225000 0.750000 +v -0.050000 -0.225000 1.450000 +vn 0.0000 -1.0000 0.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 1.0000 0.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 0.0000 1.0000 +s off +f 10//7 11//7 9//7 +f 12//8 15//8 11//8 +f 16//9 13//9 15//9 +f 14//10 9//10 13//10 +f 15//11 9//11 11//11 +f 12//12 14//12 16//12 +f 10//7 12//7 11//7 +f 12//8 16//8 15//8 +f 16//9 14//9 13//9 +f 14//10 10//10 9//10 +f 15//11 13//11 9//11 +f 12//12 10//12 14//12 +v 0.100000 -0.100000 1.550000 +v 0.100000 -0.100000 1.750000 +v -0.100000 -0.100000 1.550000 +v -0.100000 -0.100000 1.750000 +v 0.100000 0.100000 1.550000 +v 0.100000 0.100000 1.750000 +v -0.100000 0.100000 1.550000 +v -0.100000 0.100000 1.750000 +vn 0.0000 -1.0000 0.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 1.0000 0.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 0.0000 1.0000 +s off +f 18//13 19//13 17//13 +f 20//14 23//14 19//14 +f 24//15 21//15 23//15 +f 22//16 17//16 21//16 +f 23//17 17//17 19//17 +f 20//18 22//18 24//18 +f 18//13 20//13 19//13 +f 20//14 24//14 23//14 +f 24//15 22//15 21//15 +f 22//16 18//16 17//16 +f 23//17 21//17 17//17 +f 20//18 18//18 22//18 +v 0.150000 -0.200000 0.900000 +v 0.150000 -0.200000 1.500000 +v -0.150000 -0.200000 0.900000 +v -0.150000 -0.200000 1.500000 +v 0.150000 0.200000 0.900000 +v 0.150000 0.200000 1.500000 +v -0.150000 0.200000 0.900000 +v -0.150000 0.200000 1.500000 +vn 0.0000 -1.0000 0.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 1.0000 0.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 0.0000 1.0000 +s off +f 26//19 27//19 25//19 +f 28//20 31//20 27//20 +f 32//21 29//21 31//21 +f 30//22 25//22 29//22 +f 31//23 25//23 27//23 +f 28//24 30//24 32//24 +f 26//19 28//19 27//19 +f 28//20 32//20 31//20 +f 32//21 30//21 29//21 +f 30//22 26//22 25//22 +f 31//23 29//23 25//23 +f 28//24 26//24 30//24 +v 0.075000 0.025000 0.000000 +v 0.075000 0.025000 0.850000 +v -0.075000 0.025000 0.000000 +v -0.075000 0.025000 0.850000 +v 0.075000 0.175000 0.000000 +v 0.075000 0.175000 0.850000 +v -0.075000 0.175000 0.000000 +v -0.075000 0.175000 0.850000 +vn 0.0000 -1.0000 0.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 1.0000 0.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 0.0000 1.0000 +s off +f 34//25 35//25 33//25 +f 36//26 39//26 35//26 +f 40//27 37//27 39//27 +f 38//28 33//28 37//28 +f 39//29 33//29 35//29 +f 36//30 38//30 40//30 +f 34//25 36//25 35//25 +f 36//26 40//26 39//26 +f 40//27 38//27 37//27 +f 38//28 34//28 33//28 +f 39//29 37//29 33//29 +f 36//30 34//30 38//30 +v 0.075000 -0.175000 0.000000 +v 0.075000 -0.175000 0.850000 +v -0.075000 -0.175000 0.000000 +v -0.075000 -0.175000 0.850000 +v 0.075000 -0.025000 0.000000 +v 0.075000 -0.025000 0.850000 +v -0.075000 -0.025000 0.000000 +v -0.075000 -0.025000 0.850000 +vn 0.0000 -1.0000 0.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 1.0000 0.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 0.0000 1.0000 +s off +f 42//31 43//31 41//31 +f 44//32 47//32 43//32 +f 48//33 45//33 47//33 +f 46//34 41//34 45//34 +f 47//35 41//35 43//35 +f 44//36 46//36 48//36 +f 42//31 44//31 43//31 +f 44//32 48//32 47//32 +f 48//33 46//33 45//33 +f 46//34 42//34 41//34 +f 47//35 45//35 41//35 +f 44//36 42//36 46//36 diff --git a/res/mdl/dude2.obj b/res/mdl/dude2.obj new file mode 100644 index 0000000..becee6d --- /dev/null +++ b/res/mdl/dude2.obj @@ -0,0 +1,164 @@ +# Blender v2.79 (sub 0) OBJ File: 'dude2.blend' +# www.blender.org +v -0.255778 0.216248 0.761661 +v 0.038929 0.242032 1.396077 +v -0.346064 0.208349 0.803923 +v -0.051357 0.234133 1.438339 +v -0.264493 0.315867 0.761661 +v 0.030214 0.341651 1.396077 +v -0.354779 0.307968 0.803923 +v -0.060072 0.333752 1.438339 +vn 0.0872 -0.9962 -0.0000 +vn -0.9029 -0.0790 0.4226 +vn -0.0872 0.9962 0.0000 +vn 0.9029 0.0790 -0.4226 +vn -0.4210 -0.0368 -0.9063 +vn 0.4210 0.0368 0.9063 +s off +f 2//1 3//1 1//1 +f 4//2 7//2 3//2 +f 7//3 6//3 5//3 +f 6//4 1//4 5//4 +f 7//5 1//5 3//5 +f 4//6 6//6 8//6 +f 2//1 4//1 3//1 +f 4//2 8//2 7//2 +f 7//3 8//3 6//3 +f 6//4 2//4 1//4 +f 7//5 5//5 1//5 +f 4//6 2//6 6//6 +v 0.357916 -0.307968 0.803923 +v 0.063209 -0.333752 1.438339 +v 0.267630 -0.315867 0.761661 +v -0.027077 -0.341651 1.396077 +v 0.349200 -0.208349 0.803923 +v 0.054493 -0.234133 1.438339 +v 0.258915 -0.216248 0.761661 +v -0.035792 -0.242032 1.396077 +vn 0.0872 -0.9962 -0.0000 +vn -0.9029 -0.0790 -0.4226 +vn -0.0872 0.9962 0.0000 +vn 0.9029 0.0790 0.4226 +vn 0.4210 0.0368 -0.9063 +vn -0.4210 -0.0368 0.9063 +s off +f 10//7 11//7 9//7 +f 12//8 15//8 11//8 +f 15//9 14//9 13//9 +f 14//10 9//10 13//10 +f 15//11 9//11 11//11 +f 16//12 10//12 14//12 +f 10//7 12//7 11//7 +f 12//8 16//8 15//8 +f 15//9 16//9 14//9 +f 14//10 10//10 9//10 +f 15//11 13//11 9//11 +f 16//12 12//12 10//12 +v 0.100000 -0.100000 1.550000 +v 0.100000 -0.100000 1.750000 +v -0.100000 -0.100000 1.550000 +v -0.100000 -0.100000 1.750000 +v 0.100000 0.100000 1.550000 +v 0.100000 0.100000 1.750000 +v -0.100000 0.100000 1.550000 +v -0.100000 0.100000 1.750000 +vn 0.0000 -1.0000 0.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 1.0000 0.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 0.0000 1.0000 +s off +f 18//13 19//13 17//13 +f 20//14 23//14 19//14 +f 24//15 21//15 23//15 +f 22//16 17//16 21//16 +f 23//17 17//17 19//17 +f 20//18 22//18 24//18 +f 18//13 20//13 19//13 +f 20//14 24//14 23//14 +f 24//15 22//15 21//15 +f 22//16 18//16 17//16 +f 23//17 21//17 17//17 +f 20//18 18//18 22//18 +v 0.166860 -0.186166 0.900000 +v 0.166860 -0.186166 1.500000 +v -0.131998 -0.212312 0.900000 +v -0.131998 -0.212312 1.500000 +v 0.131998 0.212312 0.900000 +v 0.131998 0.212312 1.500000 +v -0.166860 0.186166 0.900000 +v -0.166860 0.186166 1.500000 +vn 0.0872 -0.9962 0.0000 +vn -0.9962 -0.0872 0.0000 +vn -0.0872 0.9962 0.0000 +vn 0.9962 0.0872 0.0000 +vn -0.0000 0.0000 -1.0000 +vn -0.0000 0.0000 1.0000 +s off +f 26//19 27//19 25//19 +f 28//20 31//20 27//20 +f 32//21 29//21 31//21 +f 30//22 25//22 29//22 +f 31//23 25//23 27//23 +f 28//24 30//24 32//24 +f 26//19 28//19 27//19 +f 28//20 32//20 31//20 +f 32//21 30//21 29//21 +f 30//22 26//22 25//22 +f 31//23 29//23 25//23 +f 28//24 26//24 30//24 +v 0.210243 0.025000 0.019480 +v 0.062642 0.025000 0.856567 +v 0.062522 0.025000 -0.006567 +v -0.085079 0.025000 0.830520 +v 0.210243 0.175000 0.019480 +v 0.062642 0.175000 0.856567 +v 0.062522 0.175000 -0.006567 +v -0.085079 0.175000 0.830520 +vn 0.0000 -1.0000 0.0000 +vn -0.9848 0.0000 -0.1736 +vn 0.0000 1.0000 0.0000 +vn 0.9848 0.0000 0.1736 +vn 0.1736 0.0000 -0.9848 +vn -0.1736 0.0000 0.9848 +s off +f 34//25 35//25 33//25 +f 36//26 39//26 35//26 +f 40//27 37//27 39//27 +f 38//28 33//28 37//28 +f 39//29 33//29 35//29 +f 36//30 38//30 40//30 +f 34//25 36//25 35//25 +f 36//26 40//26 39//26 +f 40//27 38//27 37//27 +f 38//28 34//28 33//28 +f 39//29 37//29 33//29 +f 36//30 34//30 38//30 +v -0.075060 -0.175000 -0.006567 +v 0.072541 -0.175000 0.830520 +v -0.222781 -0.175000 0.019480 +v -0.075180 -0.175000 0.856567 +v -0.075060 -0.025000 -0.006567 +v 0.072541 -0.025000 0.830520 +v -0.222781 -0.025000 0.019480 +v -0.075180 -0.025000 0.856567 +vn 0.0000 -1.0000 0.0000 +vn -0.9848 0.0000 0.1736 +vn 0.0000 1.0000 0.0000 +vn 0.9848 0.0000 -0.1736 +vn -0.1736 0.0000 -0.9848 +vn 0.1736 0.0000 0.9848 +s off +f 42//31 43//31 41//31 +f 44//32 47//32 43//32 +f 48//33 45//33 47//33 +f 46//34 41//34 45//34 +f 47//35 41//35 43//35 +f 44//36 46//36 48//36 +f 42//31 44//31 43//31 +f 44//32 48//32 47//32 +f 48//33 46//33 45//33 +f 46//34 42//34 41//34 +f 47//35 45//35 41//35 +f 44//36 42//36 46//36 From cc997bc3f0e8727f8e82a53309c98234e6c40549 Mon Sep 17 00:00:00 2001 From: Markus Bullmann Date: Wed, 4 Apr 2018 09:39:42 +0200 Subject: [PATCH 04/12] Updated shader code to v330 --- mapview/3D/misc/Shader.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/mapview/3D/misc/Shader.cpp b/mapview/3D/misc/Shader.cpp index c5525d1..b3bc206 100644 --- a/mapview/3D/misc/Shader.cpp +++ b/mapview/3D/misc/Shader.cpp @@ -4,15 +4,16 @@ Shader::Shader() { addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, R"( - attribute highp vec3 a_vertex; - attribute highp vec3 a_normal; - attribute lowp vec4 a_color; + #version 330 + in highp vec3 a_vertex; + in highp vec3 a_normal; + in lowp vec4 a_color; uniform highp mat4 M; uniform highp mat4 V; uniform highp mat4 P; - varying highp vec3 v_normal; - varying lowp vec4 v_color; - varying lowp vec4 v_vertex; + out highp vec3 v_normal; + out lowp vec4 v_color; + out lowp vec4 v_vertex; void main() { gl_Position = P * V * M * vec4(a_vertex, 1.0); v_normal = (V * M * vec4(a_normal, 0.0)).xyz; @@ -22,20 +23,23 @@ Shader::Shader() { )"); addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, R"( + #version 330 uniform vec4 color; uniform bool useNormal; uniform bool useVertexColor; - varying highp vec3 v_normal; - varying lowp vec4 v_color; - varying lowp vec4 v_vertex; + in highp vec3 v_normal; + in lowp vec4 v_color; + in lowp vec4 v_vertex; + + layout(location=1) out vec4 fragColor; void main() { vec3 lightPos = vec3(0,0,0); // camera //vec3 lightVec = normalize(vec3(0,0,1)); vec3 lightVec = normalize(lightPos - v_vertex.xyz); float intensity = useNormal ? 0.3 + 0.7 * dot( normalize(v_normal), lightVec ) : 1.0; // light at camera pos vec4 col = useVertexColor ? v_color : color; - gl_FragColor.rgb = col.rgb * intensity; - gl_FragColor.a = col.a; + fragColor.rgb = col.rgb * intensity; + fragColor.a = col.a; } )"); From e02c294ff67c646701283341f378be65ca84eeba Mon Sep 17 00:00:00 2001 From: Markus Bullmann Date: Wed, 4 Apr 2018 09:40:39 +0200 Subject: [PATCH 05/12] Removed duplicated code regarding GPCPoly --- mapview/3D/MV3DElementFloorOutline.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mapview/3D/MV3DElementFloorOutline.h b/mapview/3D/MV3DElementFloorOutline.h index 420e3e9..f725440 100644 --- a/mapview/3D/MV3DElementFloorOutline.h +++ b/mapview/3D/MV3DElementFloorOutline.h @@ -2,12 +2,11 @@ #define MV3DELEMENTFLOOROUTLINE_H #include -#include +#include #include "misc/Cube.h" #include "MV3DElement.h" -#include "../../lib/gpc/gpc.h" #include "misc/Outline.h" class MV3DElementFloorOutline : public MV3DElement { @@ -17,7 +16,7 @@ class MV3DElementFloorOutline : public MV3DElement { struct Temp { Point2 cacheSum; - Ray3D::Polygon* pol = nullptr; + GPCPolygon2* pol = nullptr; std::vector> trias; }; @@ -80,7 +79,7 @@ protected: std::vector add; std::vector rem; if (tmp.pol) {delete tmp.pol;} - tmp.pol = new Ray3D::Polygon(); + tmp.pol = new GPCPolygon2(); // all to-be-added polygons (filter!) for (Floorplan::FloorOutlinePolygon* poly : polys) { From 467514ea6c97ddb70234216b507c4c09a1f27645 Mon Sep 17 00:00:00 2001 From: Markus Bullmann Date: Wed, 4 Apr 2018 09:40:53 +0200 Subject: [PATCH 06/12] Removed obsolete opengl module --- IndoorMap.pro | 4 +--- MainController.cpp | 2 +- mapview/3D/MV3DElementStair.h | 2 +- mapview/3D/MapView3D.cpp | 20 ++++++++++++-------- mapview/3D/MapView3D.h | 5 +++-- mapview/3D/floorplan/FloorplanRenderer.h | 15 ++++++++------- mapview/3D/misc/Cube.cpp | 3 +-- mapview/3D/misc/Handrail.cpp | 2 +- mapview/3D/misc/Outline.cpp | 2 +- mapview/3D/misc/Renderable3D.h | 8 ++++++-- mapview/3D/misc/Window.cpp | 8 ++++---- mapview/3D/navMesh/NavMeshRenderer.h | 3 ++- 12 files changed, 41 insertions(+), 33 deletions(-) diff --git a/IndoorMap.pro b/IndoorMap.pro index 59635a4..33bce88 100644 --- a/IndoorMap.pro +++ b/IndoorMap.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui opengl +QT += core gui CONFIG += c++17 -g3 -O0 @@ -18,8 +18,6 @@ DEFINES += WITH_DEBUG_LOG win32 { DEFINES += _USE_MATH_DEFINES - - LIBS+= -llibGLESV2d } INCLUDEPATH += \ diff --git a/MainController.cpp b/MainController.cpp index 08544cc..2ea894b 100644 --- a/MainController.cpp +++ b/MainController.cpp @@ -113,7 +113,7 @@ MainController::MainController() { //mapModel->load("/mnt/vm/paper/diss/data/maps/test_in_out_overlap.xml"); - mapModel->load("/mnt/vm/paper/diss/data/maps/walkmodel_stairs3.xml"); +// mapModel->load("/mnt/vm/paper/diss/data/maps/walkmodel_stairs3.xml"); //mapModel->load("/mnt/vm/paper/diss/data/maps/SHL42_nm.xml"); //mapModel->load("/apps/paper/diss/data/maps/SHL41_nm.xml"); diff --git a/mapview/3D/MV3DElementStair.h b/mapview/3D/MV3DElementStair.h index 1b90802..f63f3e5 100644 --- a/mapview/3D/MV3DElementStair.h +++ b/mapview/3D/MV3DElementStair.h @@ -58,7 +58,7 @@ protected: rs.shader->setColor(1.0, 0.55, 0.55); rs.shader->setVertices(data.getVertices().data()); rs.shader->setNormals(data.getNormals().data()); - glDrawArrays(GL_TRIANGLES, 0, data.getVertices().size()/3); + rs.funcs->glDrawArrays(GL_TRIANGLES, 0, data.getVertices().size()/3); rs.shader->unsetVertices(); rs.shader->unsetNormals(); rs.shader->release(); diff --git a/mapview/3D/MapView3D.cpp b/mapview/3D/MapView3D.cpp index 760e4b9..d3419cc 100644 --- a/mapview/3D/MapView3D.cpp +++ b/mapview/3D/MapView3D.cpp @@ -101,12 +101,16 @@ MapView3D::MapView3D(QWidget *parent) : QOpenGLWidget(parent) { grabGesture(Qt::PanGesture); grabGesture(Qt::PinchGesture); - auto format = QSurfaceFormat(); - //format.setVersion(4,3); - format.setSamples(2); - //format.setProfile(QSurfaceFormat::CoreProfile); + auto format = QSurfaceFormat(); + format.setVersion(3,3); + //format.setSamples(2); + auto ver = format.version(); - setFormat(format); + std::cout << ver.first << " " << ver.second << std::endl; + format.setProfile(QSurfaceFormat::CoreProfile); + format.setOption(QSurfaceFormat::DebugContext); + + setFormat(format); } @@ -116,6 +120,7 @@ void MapView3D::initializeGL() { //setFormat(QGLFormat(QGL::SampleBuffers)); QOpenGLWidget::initializeGL(); + initializeOpenGLFunctions(); // this should be the default!! glCullFace(GL_BACK); @@ -124,8 +129,7 @@ void MapView3D::initializeGL() { // additional settings glEnable(GL_DEPTH_TEST); - glClearColor(0.9, 0.9, 1.0, 1.0); - + glClearColor(0.5, 0.5, 0.5, 1.0); } void MapView3D::paintGL() { @@ -283,7 +287,7 @@ void MapView3D::layerChange() { void MapView3D::draw() { - static RenderSettings rs = RenderSettings(new Shader()); + static RenderSettings rs = RenderSettings(new Shader(), this); // view QMatrix4x4 V; diff --git a/mapview/3D/MapView3D.h b/mapview/3D/MapView3D.h index f421026..6092649 100644 --- a/mapview/3D/MapView3D.h +++ b/mapview/3D/MapView3D.h @@ -4,7 +4,8 @@ #include "../../fixC11.h" #include -#include +#include +#include #include @@ -16,7 +17,7 @@ class NavMeshModel; class FloorplanRenderer; class FloorplanRendererModel; -class MapView3D : public QOpenGLWidget { +class MapView3D : public QOpenGLWidget, protected QOpenGLFunctions { Q_OBJECT diff --git a/mapview/3D/floorplan/FloorplanRenderer.h b/mapview/3D/floorplan/FloorplanRenderer.h index 7460ada..c7ed2cf 100644 --- a/mapview/3D/floorplan/FloorplanRenderer.h +++ b/mapview/3D/floorplan/FloorplanRenderer.h @@ -8,6 +8,7 @@ #include #include +#include #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); } diff --git a/mapview/3D/misc/Cube.cpp b/mapview/3D/misc/Cube.cpp index de9010e..1fe2342 100644 --- a/mapview/3D/misc/Cube.cpp +++ b/mapview/3D/misc/Cube.cpp @@ -1,6 +1,5 @@ #include "Cube.h" #include "Shader.h" -#include static float cube_vertices[] = { @@ -76,7 +75,7 @@ void Cube::render(const RenderSettings& rs) { rs.shader->setVertices(cube_vertices); rs.shader->setNormals(cube_normals); - glDrawArrays(GL_TRIANGLES, 0, 12*3); + rs.funcs->glDrawArrays(GL_TRIANGLES, 0, 12*3); //glDrawElements(GL_TRIANGLES, +12, GL_INT, cube_vertex_indices); rs.shader->unsetVertices(); rs.shader->unsetNormals(); diff --git a/mapview/3D/misc/Handrail.cpp b/mapview/3D/misc/Handrail.cpp index 3ac2120..fc52d1c 100644 --- a/mapview/3D/misc/Handrail.cpp +++ b/mapview/3D/misc/Handrail.cpp @@ -54,7 +54,7 @@ void Handrail::render(const RenderSettings& rs) { } rs.shader->setVertices(vertices.data()); - glDrawArrays(GL_LINES, 0, vertices.size() / 3); + rs.funcs->glDrawArrays(GL_LINES, 0, vertices.size() / 3); rs.shader->unsetVertices(); rs.shader->release(); diff --git a/mapview/3D/misc/Outline.cpp b/mapview/3D/misc/Outline.cpp index b11be41..e153acb 100644 --- a/mapview/3D/misc/Outline.cpp +++ b/mapview/3D/misc/Outline.cpp @@ -26,7 +26,7 @@ void Outline::render(const RenderSettings& rs) { rs.shader->setColor(color.x, color.y, color.z); rs.shader->setVertices(triangles.getVertices().data()); rs.shader->setNormals(triangles.getNormals().data()); - glDrawArrays(GL_TRIANGLES, 0, triangles.getVertices().size() / 3); + rs.funcs->glDrawArrays(GL_TRIANGLES, 0, triangles.getVertices().size() / 3); rs.shader->unsetVertices(); rs.shader->unsetNormals(); diff --git a/mapview/3D/misc/Renderable3D.h b/mapview/3D/misc/Renderable3D.h index 21d071d..2489252 100644 --- a/mapview/3D/misc/Renderable3D.h +++ b/mapview/3D/misc/Renderable3D.h @@ -1,11 +1,15 @@ #ifndef RENDERABLE3D_H #define RENDERABLE3D_H +#include + class Shader; struct RenderSettings { - Shader* shader = nullptr; - RenderSettings(Shader* shader) : shader(shader) {;} + Shader* shader = nullptr; + QOpenGLFunctions* funcs = nullptr; + + RenderSettings(Shader* shader, QOpenGLFunctions* f) : shader(shader), funcs(f) {;} }; diff --git a/mapview/3D/misc/Window.cpp b/mapview/3D/misc/Window.cpp index ae4d083..cdccd1b 100644 --- a/mapview/3D/misc/Window.cpp +++ b/mapview/3D/misc/Window.cpp @@ -69,20 +69,20 @@ void Window::render(const RenderSettings& rs) { rs.shader->setColor(0.75, 0.85, 1.0, 0.35); - 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); //glDisable(GL_CULL_FACE); rs.shader->setModelMatrix(mat); rs.shader->setVertices(window_vertices); rs.shader->setNormals(window_normals); - glDrawArrays(GL_TRIANGLES, 0, 12); + rs.funcs->glDrawArrays(GL_TRIANGLES, 0, 12); rs.shader->unsetVertices(); rs.shader->unsetNormals(); //glEnable(GL_CULL_FACE); - glDisable(GL_BLEND); + rs.funcs->glDisable(GL_BLEND); rs.shader->release(); diff --git a/mapview/3D/navMesh/NavMeshRenderer.h b/mapview/3D/navMesh/NavMeshRenderer.h index 734130a..0e24a86 100644 --- a/mapview/3D/navMesh/NavMeshRenderer.h +++ b/mapview/3D/navMesh/NavMeshRenderer.h @@ -10,12 +10,13 @@ #include #include +#include #include "../misc/Renderable3D.h" #include "../misc/Shader.h" #include "../misc/TriangleData.h" -class NavMeshRenderer { +class NavMeshRenderer : protected QOpenGLFunctions { private: From 479f58e7e30cb5bc84b7e12d99dfa995f32769aa Mon Sep 17 00:00:00 2001 From: k-a-z-u Date: Wed, 4 Apr 2018 10:09:22 +0200 Subject: [PATCH 07/12] switched openGL to es --- mapview/3D/MapView3D.cpp | 5 +++-- mapview/3D/misc/Shader.cpp | 37 +++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/mapview/3D/MapView3D.cpp b/mapview/3D/MapView3D.cpp index d3419cc..f737555 100644 --- a/mapview/3D/MapView3D.cpp +++ b/mapview/3D/MapView3D.cpp @@ -101,8 +101,9 @@ MapView3D::MapView3D(QWidget *parent) : QOpenGLWidget(parent) { grabGesture(Qt::PanGesture); grabGesture(Qt::PinchGesture); - auto format = QSurfaceFormat(); - format.setVersion(3,3); + auto format = QSurfaceFormat(); + format.setRenderableType(QSurfaceFormat::OpenGLES); + format.setVersion(3, 0); //format.setSamples(2); auto ver = format.version(); diff --git a/mapview/3D/misc/Shader.cpp b/mapview/3D/misc/Shader.cpp index b3bc206..f9e1657 100644 --- a/mapview/3D/misc/Shader.cpp +++ b/mapview/3D/misc/Shader.cpp @@ -4,16 +4,15 @@ Shader::Shader() { addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, R"( - #version 330 - in highp vec3 a_vertex; - in highp vec3 a_normal; - in lowp vec4 a_color; + attribute highp vec3 a_vertex; + attribute highp vec3 a_normal; + attribute lowp vec4 a_color; uniform highp mat4 M; uniform highp mat4 V; uniform highp mat4 P; - out highp vec3 v_normal; - out lowp vec4 v_color; - out lowp vec4 v_vertex; + varying highp vec3 v_normal; + varying lowp vec4 v_color; + varying lowp vec4 v_vertex; void main() { gl_Position = P * V * M * vec4(a_vertex, 1.0); v_normal = (V * M * vec4(a_normal, 0.0)).xyz; @@ -23,26 +22,24 @@ Shader::Shader() { )"); addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, R"( - #version 330 - uniform vec4 color; + uniform lowp vec4 color; uniform bool useNormal; uniform bool useVertexColor; - in highp vec3 v_normal; - in lowp vec4 v_color; - in lowp vec4 v_vertex; - - layout(location=1) out vec4 fragColor; + varying highp vec3 v_normal; + varying lowp vec4 v_color; + varying lowp vec4 v_vertex; void main() { - vec3 lightPos = vec3(0,0,0); // camera + mediump vec3 lightPos = vec3(0,0,0); // camera //vec3 lightVec = normalize(vec3(0,0,1)); - vec3 lightVec = normalize(lightPos - v_vertex.xyz); - float intensity = useNormal ? 0.3 + 0.7 * dot( normalize(v_normal), lightVec ) : 1.0; // light at camera pos - vec4 col = useVertexColor ? v_color : color; - fragColor.rgb = col.rgb * intensity; - fragColor.a = col.a; + mediump vec3 lightVec = normalize(lightPos - v_vertex.xyz); + lowp float intensity = useNormal ? 0.3 + 0.7 * dot( normalize(v_normal), lightVec ) : 1.0; // light at camera pos + lowp vec4 col = useVertexColor ? v_color : color; + gl_FragColor.rgb = col.rgb * intensity; + gl_FragColor.a = col.a; } )"); + //bindAttributeLocation("vertices", 0); if (!link()) { From d578a60a0ca7685e614830e150dfc2908cdd4f4b Mon Sep 17 00:00:00 2001 From: k-a-z-u Date: Wed, 4 Apr 2018 11:00:57 +0200 Subject: [PATCH 08/12] fixed openGL issues --- mapview/3D/MapView3D.cpp | 19 +++++++++++++++---- mapview/3D/MapView3D.h | 2 ++ mapview/3D/misc/Shader.cpp | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/mapview/3D/MapView3D.cpp b/mapview/3D/MapView3D.cpp index f737555..b0a6c0e 100644 --- a/mapview/3D/MapView3D.cpp +++ b/mapview/3D/MapView3D.cpp @@ -102,17 +102,16 @@ MapView3D::MapView3D(QWidget *parent) : QOpenGLWidget(parent) { grabGesture(Qt::PinchGesture); auto format = QSurfaceFormat(); - format.setRenderableType(QSurfaceFormat::OpenGLES); - format.setVersion(3, 0); + format.setRenderableType(QSurfaceFormat::OpenGL); + format.setVersion(3, 4); //format.setSamples(2); auto ver = format.version(); std::cout << ver.first << " " << ver.second << std::endl; - format.setProfile(QSurfaceFormat::CoreProfile); + format.setProfile(QSurfaceFormat::CompatibilityProfile); format.setOption(QSurfaceFormat::DebugContext); setFormat(format); - } @@ -131,6 +130,18 @@ void MapView3D::initializeGL() { // additional settings glEnable(GL_DEPTH_TEST); glClearColor(0.5, 0.5, 0.5, 1.0); + + //QOpenGLContext* ctx = QOpenGLContext::currentContext(); + logger = new QOpenGLDebugLogger(this); + if (logger->initialize()) { + + connect(logger, &QOpenGLDebugLogger::messageLogged, [] (const QOpenGLDebugMessage& debugMessage) { + std::cout << debugMessage.message().toStdString() << std::endl; + }); + logger->startLogging(QOpenGLDebugLogger::SynchronousLogging); + + } + } void MapView3D::paintGL() { diff --git a/mapview/3D/MapView3D.h b/mapview/3D/MapView3D.h index 6092649..ffe4a2a 100644 --- a/mapview/3D/MapView3D.h +++ b/mapview/3D/MapView3D.h @@ -24,6 +24,8 @@ class MapView3D : public QOpenGLWidget, protected QOpenGLFunctions { bool usePerspectiveProjection = false; bool useWireframe = false; + QOpenGLDebugLogger* logger = nullptr; + public: MapView3D(QWidget* parent = 0); diff --git a/mapview/3D/misc/Shader.cpp b/mapview/3D/misc/Shader.cpp index f9e1657..25460dc 100644 --- a/mapview/3D/misc/Shader.cpp +++ b/mapview/3D/misc/Shader.cpp @@ -51,6 +51,7 @@ Shader::Shader() { void Shader::setModelMatrix(const QMatrix4x4& m) { + //vao.bind();; setUniformValue(getUniform("M"), m); } @@ -78,6 +79,7 @@ int Shader::getUniform(const char* name) { return loc; } int Shader::getAttribute(const char* name) { + vao.bind(); int loc = attributeLocation(name); if (loc == -1) {throw std::runtime_error("error");} return loc; From 90308419109e1af708f0cb85384d2c674df6195c Mon Sep 17 00:00:00 2001 From: Markus Bullmann Date: Wed, 4 Apr 2018 11:41:06 +0200 Subject: [PATCH 09/12] Small OpenGL fixes --- IndoorMap.pro | 1 + mapview/3D/MapView3D.cpp | 47 ++++++++++++++++++++++++-------------- mapview/3D/misc/Shader.cpp | 1 - 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/IndoorMap.pro b/IndoorMap.pro index 39b3a7a..0f01768 100644 --- a/IndoorMap.pro +++ b/IndoorMap.pro @@ -22,6 +22,7 @@ unix { win32 { DEFINES += _USE_MATH_DEFINES + CONFIG += console } INCLUDEPATH += \ diff --git a/mapview/3D/MapView3D.cpp b/mapview/3D/MapView3D.cpp index b0a6c0e..f779bd5 100644 --- a/mapview/3D/MapView3D.cpp +++ b/mapview/3D/MapView3D.cpp @@ -104,14 +104,14 @@ MapView3D::MapView3D(QWidget *parent) : QOpenGLWidget(parent) { auto format = QSurfaceFormat(); format.setRenderableType(QSurfaceFormat::OpenGL); format.setVersion(3, 4); - //format.setSamples(2); - auto ver = format.version(); - - std::cout << ver.first << " " << ver.second << std::endl; + format.setSamples(2); format.setProfile(QSurfaceFormat::CompatibilityProfile); - format.setOption(QSurfaceFormat::DebugContext); + format.setOption(QSurfaceFormat::DebugContext); setFormat(format); + + auto ver = format.version(); + std::cout << "OpenGL Context Version: " << ver.first << "." << ver.second << std::endl; } @@ -122,6 +122,31 @@ void MapView3D::initializeGL() { QOpenGLWidget::initializeGL(); initializeOpenGLFunctions(); + logger = new QOpenGLDebugLogger(this); + if (logger->initialize()) { + connect(logger, &QOpenGLDebugLogger::messageLogged, [] (const QOpenGLDebugMessage& debugMessage) { + std::cout << debugMessage.message().toStdString() << std::endl; + }); + logger->startLogging(QOpenGLDebugLogger::SynchronousLogging); + } + + // Print device info + const GLubyte* vendor = glGetString(GL_VENDOR); + const GLubyte* renderer = glGetString(GL_RENDERER); + const GLubyte* version = glGetString(GL_VERSION); + + std::cout << "Device info: "; + if (vendor) { + std::cout << (const char*) vendor << " "; + } + if (renderer) { + std::cout << (const char*) renderer << " "; + } + if (version) { + std::cout << (const char*) version << " "; + } + std::cout << std::endl; + // this should be the default!! glCullFace(GL_BACK); glFrontFace(GL_CCW); @@ -130,18 +155,6 @@ void MapView3D::initializeGL() { // additional settings glEnable(GL_DEPTH_TEST); glClearColor(0.5, 0.5, 0.5, 1.0); - - //QOpenGLContext* ctx = QOpenGLContext::currentContext(); - logger = new QOpenGLDebugLogger(this); - if (logger->initialize()) { - - connect(logger, &QOpenGLDebugLogger::messageLogged, [] (const QOpenGLDebugMessage& debugMessage) { - std::cout << debugMessage.message().toStdString() << std::endl; - }); - logger->startLogging(QOpenGLDebugLogger::SynchronousLogging); - - } - } void MapView3D::paintGL() { diff --git a/mapview/3D/misc/Shader.cpp b/mapview/3D/misc/Shader.cpp index 25460dc..ab6566c 100644 --- a/mapview/3D/misc/Shader.cpp +++ b/mapview/3D/misc/Shader.cpp @@ -79,7 +79,6 @@ int Shader::getUniform(const char* name) { return loc; } int Shader::getAttribute(const char* name) { - vao.bind(); int loc = attributeLocation(name); if (loc == -1) {throw std::runtime_error("error");} return loc; From 3a4deaf3149c29b92ccff35d03cc52b4c1e47f00 Mon Sep 17 00:00:00 2001 From: Markus Bullmann Date: Wed, 4 Apr 2018 12:13:24 +0200 Subject: [PATCH 10/12] Added try/catch around 3D mesh generation --- mapview/3D/floorplan/FloorplanRendererModel.h | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/mapview/3D/floorplan/FloorplanRendererModel.h b/mapview/3D/floorplan/FloorplanRendererModel.h index 2e1d20e..9a98cd5 100644 --- a/mapview/3D/floorplan/FloorplanRendererModel.h +++ b/mapview/3D/floorplan/FloorplanRendererModel.h @@ -87,26 +87,29 @@ public: void rebuild(Floorplan::IndoorMap* im) { - // rebuild the mesh - Ray3D::ModelFactory fac(im); - mesh = fac.getMesh(); - 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; + } } }; From fe6f4f88f738aa4537f929bdfa8dcc4d62af3031 Mon Sep 17 00:00:00 2001 From: k-a-z-u Date: Wed, 4 Apr 2018 17:14:37 +0200 Subject: [PATCH 11/12] added mouse-up event for moved nodes --- mapview/2D/HasMoveableNodes.h | 4 +++- mapview/2D/MV2DElementAccessPoint.h | 5 +++++ mapview/2D/MV2DElementBeacon.h | 6 +++++ mapview/2D/MV2DElementElevator.h | 6 +++++ mapview/2D/MV2DElementFingerprintLocation.h | 6 +++++ mapview/2D/MV2DElementFloorObstacleDoor.cpp | 6 ++++- mapview/2D/MV2DElementFloorObstacleDoor.h | 3 ++- mapview/2D/MV2DElementFloorObstacleLine.h | 7 ++++++ mapview/2D/MV2DElementFloorObstacleObject.cpp | 5 +++++ mapview/2D/MV2DElementFloorObstacleObject.h | 2 ++ mapview/2D/MV2DElementFloorOutlinePolygon.h | 9 +++++++- mapview/2D/MV2DElementGroundTruthPoint.h | 5 +++++ mapview/2D/MV2DElementPOI.h | 5 +++++ mapview/2D/MV2DElementRegistrationPoint.h | 5 +++++ mapview/2D/MV2DElementStair.h | 6 +++++ mapview/2D/tools/ToolSelector.h | 22 ++++++++++++++++--- mapview/3D/navMesh/NavMeshRenderer.h | 6 ++--- 17 files changed, 98 insertions(+), 10 deletions(-) diff --git a/mapview/2D/HasMoveableNodes.h b/mapview/2D/HasMoveableNodes.h index 610eeee..89e55e7 100644 --- a/mapview/2D/HasMoveableNodes.h +++ b/mapview/2D/HasMoveableNodes.h @@ -36,9 +36,11 @@ public: /** get a list of all nodes that are selectable / moveable */ virtual std::vector getMoveableNodes() const = 0; - /** the given node was moved */ + /** the given node is currently moved */ virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) = 0; + /** the given node was previously moved */ + virtual void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) = 0; /** the given node was selected */ virtual void onNodeSelect(MapView2D* v, const int userIdx) { diff --git a/mapview/2D/MV2DElementAccessPoint.h b/mapview/2D/MV2DElementAccessPoint.h index 3afc9b3..e89388a 100644 --- a/mapview/2D/MV2DElementAccessPoint.h +++ b/mapview/2D/MV2DElementAccessPoint.h @@ -84,6 +84,11 @@ public: if (userIdx == 0) {ap->pos.x = newPos.x; ap->pos.y = newPos.y;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } virtual void mousePressed(MapView2D* v, const Point2 p) override { (void) v; diff --git a/mapview/2D/MV2DElementBeacon.h b/mapview/2D/MV2DElementBeacon.h index d836def..ea329eb 100644 --- a/mapview/2D/MV2DElementBeacon.h +++ b/mapview/2D/MV2DElementBeacon.h @@ -77,6 +77,12 @@ public: if (userIdx == 0) {b->pos.x = newPos.x; b->pos.y = newPos.y;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } + virtual void onFocus() override { ; } diff --git a/mapview/2D/MV2DElementElevator.h b/mapview/2D/MV2DElementElevator.h index 2fe6c6c..3a03257 100644 --- a/mapview/2D/MV2DElementElevator.h +++ b/mapview/2D/MV2DElementElevator.h @@ -94,6 +94,12 @@ public: if (userIdx == 0) {elevator->center.x = newPos.x; elevator->center.y = newPos.y;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } + virtual void mousePressed(MapView2D* v, const Point2 p) override { (void) v; diff --git a/mapview/2D/MV2DElementFingerprintLocation.h b/mapview/2D/MV2DElementFingerprintLocation.h index 89eea4e..1f38b03 100644 --- a/mapview/2D/MV2DElementFingerprintLocation.h +++ b/mapview/2D/MV2DElementFingerprintLocation.h @@ -82,6 +82,12 @@ public: if (userIdx == 0) {fpl->posOnFloor = newPos;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } + virtual void onFocus() override { ; } diff --git a/mapview/2D/MV2DElementFloorObstacleDoor.cpp b/mapview/2D/MV2DElementFloorObstacleDoor.cpp index 18c82a5..fd22f99 100644 --- a/mapview/2D/MV2DElementFloorObstacleDoor.cpp +++ b/mapview/2D/MV2DElementFloorObstacleDoor.cpp @@ -128,12 +128,16 @@ std::vector MV2DElementFloorObstacleDoor::getMoveableNodes() const return nodes; } +void MV2DElementFloorObstacleDoor::onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) { + emit v->onElementChange(this); +} + void MV2DElementFloorObstacleDoor::onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) { switch (userIdx) { case 0: fo->from = newPos; break; case 1: fo->to = newPos; break; } - emit v->onElementChange(this); +// emit v->onElementChange(this); } bool MV2DElementFloorObstacleDoor::keyPressEvent(MapView2D* v, QKeyEvent *e) { diff --git a/mapview/2D/MV2DElementFloorObstacleDoor.h b/mapview/2D/MV2DElementFloorObstacleDoor.h index ba60924..848a930 100644 --- a/mapview/2D/MV2DElementFloorObstacleDoor.h +++ b/mapview/2D/MV2DElementFloorObstacleDoor.h @@ -41,9 +41,10 @@ public: /** get a list of all nodes that are selectable / moveable */ virtual std::vector getMoveableNodes() const override; - /** the given node was moved */ virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override; + virtual void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override; + virtual bool keyPressEvent(MapView2D* v, QKeyEvent *e) override; }; diff --git a/mapview/2D/MV2DElementFloorObstacleLine.h b/mapview/2D/MV2DElementFloorObstacleLine.h index c70da1b..2ac327e 100644 --- a/mapview/2D/MV2DElementFloorObstacleLine.h +++ b/mapview/2D/MV2DElementFloorObstacleLine.h @@ -129,6 +129,13 @@ public: if (userIdx == 1) {fo->to.x = newPos.x; fo->to.y = newPos.y;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } + + }; #endif // MV2DELEMENTFLOOROBSTACLELINE_H diff --git a/mapview/2D/MV2DElementFloorObstacleObject.cpp b/mapview/2D/MV2DElementFloorObstacleObject.cpp index 33f34e1..1ee73cc 100644 --- a/mapview/2D/MV2DElementFloorObstacleObject.cpp +++ b/mapview/2D/MV2DElementFloorObstacleObject.cpp @@ -102,6 +102,11 @@ void MV2DElementFloorObstacleObject::onNodeMove(MapView2D* v, const int userIdx, if (userIdx == 0) {fo->pos.x = newPos.x; fo->pos.y = newPos.y;} } +void MV2DElementFloorObstacleObject::onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); +} void MV2DElementFloorObstacleObject::mousePressed(MapView2D* v, const Point2 p) { (void) v; diff --git a/mapview/2D/MV2DElementFloorObstacleObject.h b/mapview/2D/MV2DElementFloorObstacleObject.h index de64f52..172574d 100644 --- a/mapview/2D/MV2DElementFloorObstacleObject.h +++ b/mapview/2D/MV2DElementFloorObstacleObject.h @@ -34,6 +34,8 @@ public: virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override; + virtual void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override; + virtual void mousePressed(MapView2D* v, const Point2 p) override; virtual void mouseMove(MapView2D* v, const Point2 p) override; diff --git a/mapview/2D/MV2DElementFloorOutlinePolygon.h b/mapview/2D/MV2DElementFloorOutlinePolygon.h index 9211d55..80998db 100644 --- a/mapview/2D/MV2DElementFloorOutlinePolygon.h +++ b/mapview/2D/MV2DElementFloorOutlinePolygon.h @@ -103,12 +103,19 @@ public: } /** the given node was moved */ - virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override { + void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override { (void) v; fo.poly.points[userIdx].x = newPos.x; fo.poly.points[userIdx].y = newPos.y; } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } + + // virtual void mousePressed(MapView2D* v, const Point2 p) override { // (void) v; // (void) p; diff --git a/mapview/2D/MV2DElementGroundTruthPoint.h b/mapview/2D/MV2DElementGroundTruthPoint.h index e5abacf..036a357 100644 --- a/mapview/2D/MV2DElementGroundTruthPoint.h +++ b/mapview/2D/MV2DElementGroundTruthPoint.h @@ -81,6 +81,11 @@ public: if (userIdx == 0) {gtp->pos.x = newPos.x; gtp->pos.y = newPos.y;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } /** mouse pressed at the given point */ virtual void mousePressed(MapView2D* v, const Point2 p) override { diff --git a/mapview/2D/MV2DElementPOI.h b/mapview/2D/MV2DElementPOI.h index a3f6bc9..b79f885 100644 --- a/mapview/2D/MV2DElementPOI.h +++ b/mapview/2D/MV2DElementPOI.h @@ -81,6 +81,11 @@ public: if (userIdx == 0) {poi->pos = newPos;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } /** mouse pressed at the given point */ virtual void mousePressed(MapView2D* v, const Point2 p) override { diff --git a/mapview/2D/MV2DElementRegistrationPoint.h b/mapview/2D/MV2DElementRegistrationPoint.h index 2e56a03..7b21b79 100644 --- a/mapview/2D/MV2DElementRegistrationPoint.h +++ b/mapview/2D/MV2DElementRegistrationPoint.h @@ -77,6 +77,11 @@ public: if (userIdx == 0) {reg->posOnMap_m.x = newPos.x; reg->posOnMap_m.y = newPos.y;} } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } virtual void mousePressed(MapView2D* v, const Point2 p) override { (void) v; diff --git a/mapview/2D/MV2DElementStair.h b/mapview/2D/MV2DElementStair.h index f0465f7..a5b0f5e 100644 --- a/mapview/2D/MV2DElementStair.h +++ b/mapview/2D/MV2DElementStair.h @@ -307,6 +307,12 @@ public: } + void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override { + (void) userIdx; + (void) newPos; + emit v->onElementChange(this); + } + void onNodeSelect(MapView2D* v, const int userIdx) override { HasMoveableNodes::onNodeSelect(v, userIdx); emit v->onElementChange(this); diff --git a/mapview/2D/tools/ToolSelector.h b/mapview/2D/tools/ToolSelector.h index 5fa19bb..dae6238 100644 --- a/mapview/2D/tools/ToolSelector.h +++ b/mapview/2D/tools/ToolSelector.h @@ -120,9 +120,10 @@ private: // // left mouse button? // if (e->button() == Qt::MouseButton::LeftButton) { // // element has selectedable nodes? try to select one -// if (dynamic_cast(me)) { -// if (selectNode(m, p, dynamic_cast(me))) {return;} -// } + if (dynamic_cast(me)) { + //if (selectNode(m, p, dynamic_cast(me))) {return;} + if (nodeMoved(m, p, dynamic_cast(me))) {return;} + } // } // otherwise: let the element itself process all events @@ -173,6 +174,21 @@ private: } + /** moved the currently selected node (now done). true if successful */ + bool nodeMoved(MapView2D* v, Point2 p, HasMoveableNodes* elem) { + + // no node selected? -> done + if (elem->getSelectedNode() == -1) {return false;} + + // snap the node + const Point2 pSnapped = v->getScaler().snap(p); + + // moved (done) + elem->onNodeMoved(v, elem->getSelectedNode(), pSnapped); + return true; + + } + private: diff --git a/mapview/3D/navMesh/NavMeshRenderer.h b/mapview/3D/navMesh/NavMeshRenderer.h index 0e24a86..5b89706 100644 --- a/mapview/3D/navMesh/NavMeshRenderer.h +++ b/mapview/3D/navMesh/NavMeshRenderer.h @@ -16,7 +16,7 @@ #include "../misc/Shader.h" #include "../misc/TriangleData.h" -class NavMeshRenderer : protected QOpenGLFunctions { +class NavMeshRenderer { private: @@ -89,7 +89,7 @@ public: rs.shader->setVertices(data.getVertices().data()); rs.shader->setVertexColor(data.getRGBA().data()); - glDrawArrays(GL_TRIANGLES, 0, data.getVertices().size()/3); + rs.funcs->glDrawArrays(GL_TRIANGLES, 0, data.getVertices().size()/3); rs.shader->unsetVertices(); rs.shader->unsetVertexColor(); @@ -133,7 +133,7 @@ public: rs.shader->setVertices(data.getVertices().data()); rs.shader->setVertexColor(data.getRGBA().data()); - glDrawArrays(GL_LINES, 0, data.getVertices().size()/3); + rs.funcs->glDrawArrays(GL_LINES, 0, data.getVertices().size()/3); rs.shader->unsetVertices(); rs.shader->unsetVertexColor(); From d8442ddb81ead36dca0ea7807466f1fd7c898273 Mon Sep 17 00:00:00 2001 From: Markus Bullmann Date: Thu, 5 Apr 2018 17:26:18 +0200 Subject: [PATCH 12/12] Added new material 'metal' --- mapview/2D/MapViewElementHelper.h | 1 + params/ElementParamWidget.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mapview/2D/MapViewElementHelper.h b/mapview/2D/MapViewElementHelper.h index 40a00f0..f84daf0 100644 --- a/mapview/2D/MapViewElementHelper.h +++ b/mapview/2D/MapViewElementHelper.h @@ -79,6 +79,7 @@ public: if (focus) {pen.setColor(Qt::black);} if (mat == Material::CONCRETE) {;} if (mat == Material::GLASS) {pen.setStyle(Qt::PenStyle::DotLine);} + if (mat == Material::METAL) {pen.setColor(QColor(50, 50, 50));} if (type == ObstacleType::HANDRAIL) {pen.setStyle(Qt::PenStyle::DashLine);} if (type == ObstacleType::UNKNOWN) {pen.setColor(Qt::red);} if (type == ObstacleType::PILLAR) {pen.setColor(Qt::red);} diff --git a/params/ElementParamWidget.cpp b/params/ElementParamWidget.cpp index 80c04a0..c5fb866 100644 --- a/params/ElementParamWidget.cpp +++ b/params/ElementParamWidget.cpp @@ -30,6 +30,7 @@ QComboBox* getMaterials() { case Material::DRYWALL: cmbMaterial->addItem("Drywall", i); break; case Material::WOOD: cmbMaterial->addItem("Wood", i); break; case Material::GLASS: cmbMaterial->addItem("Glass", i); break; + case Material::METAL: cmbMaterial->addItem("Metal", i); break; case Material::_END: throw 1; } } @@ -128,7 +129,6 @@ void ElementParamWidget::refresh() { } } - // has outline method? { MMFloorOutlinePolygon* elem = dynamic_cast(el);