79 lines
1.9 KiB
C++
79 lines
1.9 KiB
C++
#ifndef RENDERTRIANGLE_H
|
|
#define RENDERTRIANGLE_H
|
|
|
|
|
|
#include <vector>
|
|
#include <Indoor/geo/Point3.h>
|
|
|
|
class RenderTriangle {
|
|
|
|
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 clear() {
|
|
vertices.clear();
|
|
normals.clear();
|
|
rgba.clear();
|
|
}
|
|
|
|
const std::vector<float>& getVertices() const {return vertices;}
|
|
|
|
const std::vector<float>& getNormals() const {return normals;}
|
|
|
|
const std::vector<float>& getRGBA() const {return rgba;}
|
|
|
|
};
|
|
|
|
|
|
#endif // RENDERTRIANGLE_H
|