worked on 3D display
some ui changes refactoring new icons
This commit is contained in:
101
mapview/3D/misc/Handrail.cpp
Normal file
101
mapview/3D/misc/Handrail.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#include "Handrail.h"
|
||||
|
||||
#include <Indoor/geo/Point3.h>
|
||||
#include "Shader.h"
|
||||
|
||||
Handrail::Handrail(const Point2 from, const Point2 to, float atHeight, float height) :
|
||||
from(from), to(to), atHeight(atHeight), height(height) {
|
||||
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
void Handrail::render(const RenderSettings& rs) {
|
||||
|
||||
rs.shader->bind();
|
||||
rs.shader->setColor(0.8, 0.8, 0.8);
|
||||
rs.shader->setModelMatrix(QMatrix4x4());
|
||||
|
||||
const float z1 = atHeight;
|
||||
const float z2 = atHeight + height;
|
||||
|
||||
// polygon edges
|
||||
Point3 p1 = Point3(from.x, from.y, z1);
|
||||
Point3 p2 = Point3(to.x, to.y, z1);
|
||||
|
||||
Point3 p3 = Point3(from.x, from.y, z2);
|
||||
Point3 p4 = Point3(to.x, to.y, z2);
|
||||
|
||||
std::vector<float> vertices;
|
||||
|
||||
// top
|
||||
vertices.insert( vertices.end(), {p3.x, p3.y, p3.z} );
|
||||
vertices.insert( vertices.end(), {p4.x, p4.y, p4.z} );
|
||||
|
||||
// start bar
|
||||
vertices.insert( vertices.end(), {p1.x, p1.y, p1.z} );
|
||||
vertices.insert( vertices.end(), {p3.x, p3.y, p3.z} );
|
||||
|
||||
// end bar
|
||||
vertices.insert( vertices.end(), {p2.x, p2.y, p2.z} );
|
||||
vertices.insert( vertices.end(), {p4.x, p4.y, p4.z} );
|
||||
|
||||
// intermediate bars
|
||||
const Point3 d1 = p2-p1;
|
||||
const Point3 d2 = p4-p3;
|
||||
const int numBars = d2.length() / 1;
|
||||
for (int i = 1; i < numBars; ++i) {
|
||||
const Point3 s = p1 + d1 * i / numBars;
|
||||
const Point3 e = p3 + d2 * i / numBars;
|
||||
vertices.insert( vertices.end(), {s.x, s.y, s.z} );
|
||||
vertices.insert( vertices.end(), {e.x, e.y, e.z} );
|
||||
}
|
||||
|
||||
rs.shader->setVertices(vertices.data());
|
||||
glDrawArrays(GL_LINES, 0, vertices.size() / 3);
|
||||
rs.shader->unsetVertices();
|
||||
|
||||
rs.shader->release();
|
||||
|
||||
/*
|
||||
|
||||
TODO_GL
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glBegin(GL_LINES);
|
||||
|
||||
glColor3f(0.9, 0.9, 0.9);
|
||||
|
||||
// top
|
||||
glVertex3f(p3.x, p3.y, p3.z);
|
||||
glVertex3f(p4.x, p4.y, p4.z);
|
||||
|
||||
// start bar
|
||||
glVertex3f(p1.x, p1.y, p1.z);
|
||||
glVertex3f(p3.x, p3.y, p3.z);
|
||||
|
||||
// end bar
|
||||
glVertex3f(p2.x, p2.y, p2.z);
|
||||
glVertex3f(p4.x, p4.y, p4.z);
|
||||
|
||||
glColor3f(0.6, 0.6, 0.6);
|
||||
|
||||
// intermediate bars
|
||||
const Point3 d1 = p2-p1;
|
||||
const Point3 d2 = p4-p3;
|
||||
const int numBars = d2.length() / 1;
|
||||
for (int i = 1; i < numBars; ++i) {
|
||||
const Point3 s = p1 + d1 * i / numBars;
|
||||
const Point3 e = p3 + d2 * i / numBars;
|
||||
glVertex3f(s.x, s.y, s.z);
|
||||
glVertex3f(e.x, e.y, e.z);
|
||||
}
|
||||
|
||||
glEnd();
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user