/* model/fragment.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/fragment.h" #include "model/vertexarray.h" namespace model { /* ---- class Fragment --------------------------------------------- */ /* Triangles: the number of triangles is size/3 Quads: the number of Quads is size/4 */ Fragment::Fragment(const Fragment &other) { fragment_type = other.fragment_type; fragment_index = other.fragment_index; fragment_structural_size = other.fragment_structural_size; fragment_detail_size = other.fragment_detail_size; fragment_material = other.fragment_material; } Fragment::Fragment(Type type, const Material *material) { fragment_type = type; fragment_index = VertexArray::instance()->index() / 8; fragment_material = material; fragment_structural_size = 0; fragment_detail_size = 0; } size_t Fragment::add_vertex(math::Vector3f const & vertex, math::Vector3f const &normal, bool detail) { size_t n = VertexArray::instance()->add_vertex(vertex, normal); if (n) { if (detail) fragment_detail_size += n; else fragment_structural_size += n; } return n; } size_t Fragment::add_vertex(math::Vector3f const & vertex, math::Vector3f const &normal, math::Vector2f const &texcoord, bool detail) { size_t n = VertexArray::instance()->add_vertex(vertex, normal, texcoord.x(), texcoord.y()); if (n) { if (detail) fragment_detail_size += n; else fragment_structural_size += n; } return n; } /* ---- class FragmentGroup ---------------------------------------- */ FragmentGroup::FragmentGroup() { group_type = None; group_scale = 1.0f; group_distance = 0.0f; group_speed = 0.0f; group_engine = false; } FragmentGroup::~FragmentGroup() { clear(); } void FragmentGroup::clear() { for (Fragments::iterator it = group_fragments.begin(); it != group_fragments.end(); it++) { delete(*it); } group_fragments.clear(); } }