blob: 9e3fea685a123599f046fba90fe717e8811683ba (
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/*
model/asefile.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_ASEFILE_H__
#define __INCLUDED_MODEL_ASEFILE_H__
#include "math/vector3f.h"
#include "model/model.h"
#include "model/material.h"
#include "model/fragment.h"
#include "model/triangle.h"
#include "filesystem/filestream.h"
#include <string>
#include <map>
#include <vector>
namespace model
{
/// class to parse the .ase file structure and load geometry data into a model
class ASEFile
{
public:
/**
* @brief load a .ase file into a Model
* @param name name of the model to be loaded, without .ase extension or models/ prefix
* If the file can not be read, load() returns the NULL-pointer
*/
static Model *load(std::string const &name);
private:
/**
* @brief type definition for a list of submaterials in the ASE file
*/
typedef std::map<size_t, Material *> SubMaterialList;
/**
* @brief type definition for a list of materials in the ASE file
*/
typedef std::map<size_t, SubMaterialList *> MaterialList;
/**
* @brief type definition for a list of vertices in a GEOMOBJECT
*/
typedef std::map<size_t, math::Vector3f *> VertexList;
/**
* @brief type definition for a list of faces in a GEOMOBJECT
*/
typedef std::map<size_t, Triangle *> FaceList;
ASEFile(std::string const &name);
~ASEFile();
/**
* @brief read *SUBMATERIAL
*/
Material *read_submaterial(std::istream &is);
/**
* @brief read *MATERIAL
*/
SubMaterialList *read_material(std::istream &is);
/**
* @brief read *MATERIAL_LIST
*/
bool read_material_list(std::istream &is);
/**
* @brief read *MESH_NORMALS
*/
bool read_mesh_normals(std::istream &is);
/**
* @brief read *MESH_FACE_LIST
*/
bool read_mesh_face_list(std::istream &is);
/**
* @brief read *MESH_VERTEX_LIST
*/
bool read_mesh_vertex_list(std::istream &is);
/**
* @brief read *MESH_TVERTLIST
*/
bool read_mesh_tvertex_list(std::istream &is);
/**
* @brief read *MESH_TFACELIST
*/
bool read_mesh_tface_list(std::istream &is);
/**
* @brief read *MESH
*/
bool read_mesh(std::istream &is);
/**
* @brief read *GEOMOBJECT
*/
bool read_geom(std::istream &is);
/**
* @brief clear *GEOMOBJECT
*/
bool clear_geom();
/**
* @brief read the .ase header
*/
bool read_header(std::istream &is);
/**
* @brief read the .ase file
*/
bool read();
inline const std::string &name() const {
return asefile_name;
}
inline bool is_open() {
return asefile_ifs.is_open();
}
inline size_t vertexcount() const {
return ase_vertexcount;
}
inline size_t facecount() const {
return ase_facecount;
}
inline FragmentGroup *fragmentgroup() {
return ase_fragmentgroup;
}
std::string asefile_name;
filesystem::IFileStream asefile_ifs;
VertexList ase_vertexlist;
VertexList ase_tvertexlist;
FaceList ase_facelist;
MaterialList ase_materials;
math::Vector3f ase_maxbbox;
math::Vector3f ase_minbbox;
FragmentGroup *ase_fragmentgroup;
size_t ase_vertexcount;
size_t ase_facecount;
};
} // namespace model
#endif // __INCLUDED_MODEL_ASEFILE_H__
|