blob: 409bb977ea6243beddd923f954c4a7ed2eb15203 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/*
model/fragment.h
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
#ifndef __INCLUDED_MODEL_FRAGMENT_H__
#define __INCLUDED_MODEL_FRAGMENT_H__
#include <list>
#include "math/vector3f.h"
#include "math/color.h"
namespace model
{
/// a fragment of a model, a pointer into a continuous part of the VertexArray containing tris or quads
class Fragment
{
public:
/// fragment primitive type: triangles or quads
enum Type {Triangles, Quads};
/// create a new fragment
Fragment(Type type, unsigned int material);
/// add a vertex to the fragment
size_t add_vertex(math::Vector3f const & vertex, math::Vector3f const &normal, math::Color const & color, bool detail);
/// the type of primitives this fragment consists of
inline Type type() const
{
return fragment_type;
}
/// VertexArray index of the start of the fragment
inline size_t index() const
{
return fragment_index;
}
/// number of structural vertices in the fragment
inline size_t structural_size() const
{
return fragment_structural_size;
}
/// number of detail vertices in the fragment
inline size_t detail_size() const
{
return fragment_detail_size;
}
/// material flags
inline unsigned int material()
{
return fragment_material;
}
private:
Type fragment_type;
size_t fragment_index;
size_t fragment_structural_size;
size_t fragment_detail_size;
unsigned int fragment_material;
};
/// a collection of fragments
/**
* a FragmentGroup contains the model fragments for one class in the .map file.
* worldspawn is a FragmentGroup
*/
class FragmentGroup
{
public:
typedef std::list<Fragment *>::iterator iterator;
FragmentGroup();
~FragmentGroup();
void clear();
inline iterator begin() { return group_fragments.begin(); }
inline iterator end() { return group_fragments.end(); }
inline size_t size() const { return group_fragments.size(); }
inline void push_back(Fragment *fragment) { group_fragments.push_back(fragment); }
private:
/// type definition for a list of model fragments
typedef std::list<Fragment *> Fragments;
Fragments group_fragments;
};
}
#endif // __INCLUDED_MODEL_FRAGMENT_H__
|