28#include "primitive.hpp"
42 std::vector<Vertex> _vertices;
60 Polygon(
const std::vector<Vertex> &vertices,
62 :
Primitive(), _vertices(vertices), _rotation(rotation), _translation() {}
68 :
Primitive(), _rotation(rotation), _translation() {
70 for (
const auto &p : points) {
71 _vertices.emplace_back(p,
Color(1.0f, 1.0f, 1.0f));
88 _vertices.push_back(vertex);
97 const std::vector<Vertex> &
getVertices(
void)
const {
return _vertices; }
121 _rotation = rotation;
133 _translation = translation;
140 void setVertices(
const std::vector<Vertex> &vertices) { _vertices = vertices; }
146 std::vector<Point> pts;
147 pts.reserve(_vertices.size());
148 for (
const auto &v : _vertices) {
149 pts.push_back(v.position);
Represents an RGBA color with floating-point channels in [0, 1].
Represents a point in 3D space.
Represents a polygon primitive for 3D rendering.
Polygon(const std::vector< Point > &points, const Point &rotation=Point())
Construct polygon from a list of Points (converts to vertices with default color)
Polygon & addVertex(const Vertex &vertex)
Adds a vertex to the polygon.
Polygon(void)
Default constructor - initializes an empty polygon.
Polygon(const std::vector< Vertex > &vertices, const Point &rotation=Point())
Constructor from a list of vertices.
Polygon & setRotation(const Point &rotation)
Sets the rotation of the polygon in Euler angles (radians)
const std::vector< Vertex > & getVertices(void) const
Gets the vertices defining the polygon.
const Point & getTranslation(void) const
Gets the translation of the polygon in 3D space.
~Polygon(void) override=default
Destroy the Polygon object.
void setVertices(const std::vector< Vertex > &vertices)
Replace the internal vertex list.
const Point & getRotation(void) const
Gets the rotation of the polygon in Euler angles (radians)
Polygon & setTranslation(const Point &translation)
Sets the translation of the polygon in 3D space.
std::vector< Point > getPoints(void) const
Return the polygon corner positions as Points.
Base class for all drawing primitives.