forked from swayfreeda/ImageBasedModellingEduV1.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobj_model.h
executable file
·87 lines (72 loc) · 1.81 KB
/
obj_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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* Copyright (C) 2015, Nils Moehrle
* TU Darmstadt - Graphics, Capture and Massively Parallel Computing
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the BSD 3-Clause license. See the LICENSE.txt file for details.
*/
#ifndef TEX_OBJMODEL_HEADER
#define TEX_OBJMODEL_HEADER
#include "material_lib.h"
/**
* Class representing a obj model.
*/
class ObjModel {
public:
struct Face {
std::size_t vertex_ids[3];
std::size_t texcoord_ids[3];
std::size_t normal_ids[3];
};
struct Group {
std::string material_name;
std::vector<Face> faces;
};
typedef std::vector<math::Vec3f> Vertices;
typedef std::vector<math::Vec2f> TexCoords;
typedef std::vector<math::Vec3f> Normals;
typedef std::vector<Group> Groups;
private:
Vertices vertices;
TexCoords texcoords;
Normals normals;
Groups groups;
MaterialLib material_lib;
public:
/** Saves the obj model to an .obj file, its material lib and the materials with the given prefix. */
void save_to_files(std::string const & prefix) const;
ObjModel();
MaterialLib & get_material_lib(void);
Vertices & get_vertices(void);
TexCoords & get_texcoords(void);
Normals & get_normals(void);
Groups & get_groups(void);
static void save(ObjModel const & model, std::string const & prefix);
};
inline
MaterialLib &
ObjModel::get_material_lib(void) {
return material_lib;
}
inline
ObjModel::Vertices &
ObjModel::get_vertices(void) {
return vertices;
}
inline
ObjModel::TexCoords &
ObjModel::get_texcoords(void) {
return texcoords;
}
inline
ObjModel::Normals &
ObjModel::get_normals(void) {
return normals;
}
inline
ObjModel::Groups &
ObjModel::get_groups(void) {
return groups;
}
#endif /* TEX_OBJMODEL_HEADER */