63 lines
1.2 KiB
C++
63 lines
1.2 KiB
C++
/*
|
||
* © Copyright 2014 – Urheberrechtshinweis
|
||
* Alle Rechte vorbehalten / All Rights Reserved
|
||
*
|
||
* Programmcode ist urheberrechtlich geschuetzt.
|
||
* Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner.
|
||
* Keine Verwendung ohne explizite Genehmigung.
|
||
* (vgl. § 106 ff UrhG / § 97 UrhG)
|
||
*/
|
||
|
||
#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
|