diff options
Diffstat (limited to 'src/model/primitives.cc')
-rw-r--r-- | src/model/primitives.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/model/primitives.cc b/src/model/primitives.cc new file mode 100644 index 0000000..1b9d216 --- /dev/null +++ b/src/model/primitives.cc @@ -0,0 +1,44 @@ +/* + model/primitives.cc + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#include "model/primitives.h" + +namespace model +{ + +Primitives::Primitives(unsigned int material) +{ + primitives_material = material; +} + +Primitives::~Primitives() +{ + // clear list of triangles + for (std::list<Triangle *>::iterator tris_it = primitives_triangles.begin(); tris_it != primitives_triangles.end(); tris_it++) + delete(*tris_it); + primitives_triangles.clear(); + + // clear list of quads + for (std::list<Quad *>::iterator quad_it = primitives_quads.begin(); quad_it != primitives_quads.end(); quad_it++) + delete(*quad_it); + primitives_quads.clear(); +} + +void Primitives::add_triangle(math::Vector3f const &v0, math::Vector3f const &v1, math::Vector3f const &v2, + math::Vector3f const &normal, math::Color const &color, bool detail) +{ + Triangle *triangle = new Triangle(v0, v1, v2, normal, color, detail); + primitives_triangles.push_back(triangle); +} + +void Primitives::add_quad(math::Vector3f const &v0, math::Vector3f const &v1, math::Vector3f const &v2, math::Vector3f const &v3, + math::Vector3f const &normal, math::Color const &color, bool detail) +{ + Quad *quad = new Quad(v0, v1, v2, v3, normal, color, detail); + primitives_quads.push_back(quad); +} + +} |