This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
IndoorMap/mapview/3D/misc/Plane.h
2016-07-04 15:11:10 +02:00

53 lines
877 B
C++

#ifndef PLANE_H
#define PLANE_H
#include <Indoor/geo/Point3.h>
#include <QtOpenGL>
class Plane {
private:
Point3 p1;
Point3 p2;
Point3 p3;
Point3 p4;
Point3 n;
public:
/** construct from 2D line and heights */
Plane(const Point2 from, const Point2 to, const float atHeight, const float height) {
p1 = Point3(from.x, from.y, atHeight);
p2 = Point3(to.x, to.y, atHeight);
p3 = Point3(to.x, to.y, atHeight+height);
p4 = Point3(from.x, from.y, atHeight+height);
const Point2 perp = (to-from).perpendicular();
n = Point3(perp.x, perp.y, 0);
}
void paintGL() {
glDisable(GL_CULL_FACE);
glBegin(GL_QUADS);
// bottom
glNormal3f(n.x, n.z, n.y);
glVertex3f(p1.x, p1.z, p1.y);
glVertex3f(p2.x, p2.z, p2.y);
glVertex3f(p3.x, p3.z, p3.y);
glVertex3f(p4.x, p4.z, p4.y);
glEnd();
glEnable(GL_CULL_FACE);
}
};
#endif // PLANE_H