-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.h
71 lines (62 loc) · 1.41 KB
/
model.h
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
/*
* model.h
* (c) 2012 ViRVIG (http://www.virvig.eu)
* This source code is licensed under the creative commons CC BY-NC-SA 3.0
* license (see http://creativecommons.org/licenses/by-nc-sa/3.0/)
*
*/
#ifndef MODEL_H
#define MODEL_H
#include <vector>
#include <string>
struct Material {
std::string name;
float ambient[4];
float diffuse[4];
float specular[4];
float shininess;
Material();
};
#ifndef __MODEL__DEF__
extern
#endif
std::vector<Material> Materials
#ifdef __MODEL__DEF__
(1);
#else
;
#endif
typedef double Vertex;
typedef double Normal;
struct Face{
std::vector<int> v; // Model::load() only generates triangles, though.
std::vector<int> n;
int mat;
double normalC[3];
};
class Model {
public:
Model();
~Model();
void load(std::string filename);
const std::vector<Vertex>& vertices() const {
return _vertices;
}
const std::vector<Normal>& normals() const {
return _normals;
}
const std::vector<Face>& faces() const {
return _faces;
}
void dumpStats() const;
void dumpModel() const;
private:
std::vector<Vertex> _vertices;
std::vector<Normal> _normals;
std::vector<Face> _faces;
void parseVOnly(std::stringstream & ss, std::string & block);
void parseVN(std::stringstream & ss, std::string & block);
void parseVT(std::stringstream & ss, std::string & block);
void parseVTN(std::stringstream & ss, std::string & block);
};
#endif // MODEL_H