98 lines
2.5 KiB
C++
98 lines
2.5 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 TRIANGLEDATA_H
|
||
#define TRIANGLEDATA_H
|
||
|
||
#include <vector>
|
||
#include <Indoor/geo/Point3.h>
|
||
|
||
class TriangleData {
|
||
|
||
std::vector<float> vertices;
|
||
std::vector<float> normals;
|
||
std::vector<float> rgba;
|
||
|
||
public:
|
||
|
||
void addTriangle(Point3 p1, Point3 p2, Point3 p3) {
|
||
|
||
vertices.insert(vertices.end(), {p1.x, p1.y, p1.z});
|
||
vertices.insert(vertices.end(), {p2.x, p2.y, p2.z});
|
||
vertices.insert(vertices.end(), {p3.x, p3.y, p3.z});
|
||
|
||
}
|
||
|
||
void addTriangle(Point3 p1, Point3 p2, Point3 p3, const Point3 n) {
|
||
|
||
vertices.insert(vertices.end(), {p1.x, p1.y, p1.z});
|
||
vertices.insert(vertices.end(), {p2.x, p2.y, p2.z});
|
||
vertices.insert(vertices.end(), {p3.x, p3.y, p3.z});
|
||
|
||
normals.insert(normals.end(), {n.x, n.y, n.z});
|
||
normals.insert(normals.end(), {n.x, n.y, n.z});
|
||
normals.insert(normals.end(), {n.x, n.y, n.z});
|
||
|
||
}
|
||
|
||
void addTriangle(Point3 p1, Point3 p2, Point3 p3, const Point3 n, const float r, const float g, const float b, const float a) {
|
||
|
||
vertices.insert(vertices.end(), {p1.x, p1.y, p1.z});
|
||
vertices.insert(vertices.end(), {p2.x, p2.y, p2.z});
|
||
vertices.insert(vertices.end(), {p3.x, p3.y, p3.z});
|
||
|
||
normals.insert(normals.end(), {n.x, n.y, n.z});
|
||
normals.insert(normals.end(), {n.x, n.y, n.z});
|
||
normals.insert(normals.end(), {n.x, n.y, n.z});
|
||
|
||
rgba.insert(rgba.end(), {r,g,b,a});
|
||
rgba.insert(rgba.end(), {r,g,b,a});
|
||
rgba.insert(rgba.end(), {r,g,b,a});
|
||
|
||
}
|
||
|
||
|
||
void addLine(Point3 p1, Point3 p2, const float r, const float g, const float b, const float a) {
|
||
|
||
vertices.insert(vertices.end(), {p1.x, p1.y, p1.z});
|
||
vertices.insert(vertices.end(), {p2.x, p2.y, p2.z});
|
||
|
||
rgba.insert(rgba.end(), {r,g,b,a});
|
||
rgba.insert(rgba.end(), {r,g,b,a});
|
||
|
||
}
|
||
|
||
void addPoint(Point3 p, const float r, const float g, const float b, const float a) {
|
||
|
||
vertices.insert(vertices.end(), {p.x, p.y, p.z});
|
||
rgba.insert(rgba.end(), {r,g,b,a});
|
||
|
||
}
|
||
|
||
bool empty() const {
|
||
return vertices.empty();
|
||
}
|
||
|
||
void clear() {
|
||
vertices.clear();
|
||
normals.clear();
|
||
rgba.clear();
|
||
}
|
||
|
||
const std::vector<float>& getVertices() {return vertices;}
|
||
|
||
const std::vector<float>& getNormals() {return normals;}
|
||
|
||
const std::vector<float>& getRGBA() {return rgba;}
|
||
|
||
};
|
||
|
||
#endif // TRIANGLEDATA_H
|