worked on 3D display
some ui changes refactoring new icons
This commit is contained in:
73
mapview/3D/misc/Outline.cpp
Normal file
73
mapview/3D/misc/Outline.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "Outline.h"
|
||||
|
||||
#include <QMatrix4x4>
|
||||
#include <Indoor/geo/Point3.h>
|
||||
#include <QOpenGLWidget>
|
||||
#include "Shader.h"
|
||||
|
||||
Outline::Outline() {
|
||||
|
||||
}
|
||||
|
||||
void Outline::render(const RenderSettings& rs) {
|
||||
|
||||
rs.shader->bind();
|
||||
|
||||
// identity
|
||||
QMatrix4x4 mat;
|
||||
rs.shader->setModelMatrix(mat);
|
||||
|
||||
// show both sides
|
||||
//glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
rs.shader->setColor(color.x, color.y, color.z);
|
||||
rs.shader->setVertices(vertices.data());
|
||||
rs.shader->setNormals(normals.data());
|
||||
glDrawArrays(GL_TRIANGLES, 0, vertices.size() / 3);
|
||||
rs.shader->unsetVertices();
|
||||
rs.shader->unsetNormals();
|
||||
|
||||
|
||||
|
||||
rs.shader->release();
|
||||
|
||||
}
|
||||
|
||||
void Outline::setColor(float r, float g, float b) {
|
||||
color = Point3(r,g,b);
|
||||
}
|
||||
|
||||
void Outline::clear() {
|
||||
normals.clear();
|
||||
vertices.clear();
|
||||
}
|
||||
|
||||
void Outline::add(std::vector<std::vector<Point3>>& triangles) {
|
||||
|
||||
for (const std::vector<Point3>& tria : triangles) {
|
||||
for (size_t i = 2; i < tria.size(); ++i) {
|
||||
|
||||
const Point3 p1 = tria[i-2];
|
||||
const Point3 p2 = tria[i-1];
|
||||
const Point3 p3 = tria[i-0];
|
||||
|
||||
const Point3 n = cross(p2-p1, p3-p1);
|
||||
if (n.z < 0) {
|
||||
vertices.push_back(p1.x); vertices.push_back(p1.y); vertices.push_back(p1.z);
|
||||
vertices.push_back(p3.x); vertices.push_back(p3.y); vertices.push_back(p3.z);
|
||||
vertices.push_back(p2.x); vertices.push_back(p2.y); vertices.push_back(p2.z);
|
||||
} else {
|
||||
vertices.push_back(p1.x); vertices.push_back(p1.y); vertices.push_back(p1.z);
|
||||
vertices.push_back(p2.x); vertices.push_back(p2.y); vertices.push_back(p2.z);
|
||||
vertices.push_back(p3.x); vertices.push_back(p3.y); vertices.push_back(p3.z);
|
||||
}
|
||||
|
||||
normals.push_back(0); normals.push_back(0); normals.push_back(1);
|
||||
normals.push_back(0); normals.push_back(0); normals.push_back(1);
|
||||
normals.push_back(0); normals.push_back(0); normals.push_back(1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user