blob: d8479eba25b66aecc1ad64f19670167736f7a06b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/*
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(Type type, const Material *material)
{
fragment_type = type;
fragment_index = VertexArray::instance()->index() / 3;
fragment_material = material;
fragment_structural_size = 0;
fragment_detail_size = 0;
}
size_t Fragment::add_vertex(math::Vector3f const & vertex, math::Vector3f const &normal, math::Color const & color, bool detail)
{
size_t n = VertexArray::instance()->add_vertex(vertex, normal, color);
if (n) {
if (detail)
fragment_detail_size += n;
else
fragment_structural_size += n;
}
return n;
}
/* ---- class FragmentGroup ---------------------------------------- */
FragmentGroup::FragmentGroup()
{
group_type = None;
}
FragmentGroup::~FragmentGroup()
{
clear();
}
void FragmentGroup::clear() {
for (iterator it = group_fragments.begin(); it != group_fragments.end(); it++) {
delete(*it);
}
group_fragments.clear();
}
}
|