-
Notifications
You must be signed in to change notification settings - Fork 5
/
WavefrontLoader.hpp
89 lines (66 loc) · 1.9 KB
/
WavefrontLoader.hpp
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
/*
* WavefrontLoader.hpp
*
* Created on: 2014/11/12
* Author: Dimitri Kourkoulis
* http://dimitros.be
* License: BSD 3-Clause License (see LICENSE file)
*/
#pragma once
#include "ModelLoader.hpp"
#include <vector>
using namespace std;
namespace small3d {
/**
* @class WavefrontLoader
*
* @brief Class that loads a model from a wavefront .obj file, into a Model object.
*
*/
class WavefrontLoader : public ModelLoader {
private:
// The model to which the data is loaded
Model* model;
// Data read from .obj file
vector< vector<float> > vertices;
vector<vector<int> > facesVertexIndices;
vector<vector<float> > normals;
vector<vector<int> > facesNormalIndices;
vector<vector<float> > textureCoords;
vector<vector<int> > textureCoordsIndices;
void loadVertexData();
void loadIndexData();
void loadNormalsData();
void loadTextureCoordsData();
// Make sure that no texture coordinate information is lost when the data buffers get created (vertexData,
// indexData, normalsData and textureCoordsData) by realigning the data vectors, in order to ensure unique
// vertex - texture coordinates pairs
void correctDataVectors();
void init();
void clear();
public:
/**
* @fn WavefrontLoader::WavefrontLoader();
*
* @brief Default constructor.
*
*/
WavefrontLoader();
/**
* @fn WavefrontLoader::~WavefrontLoader();
*
* @brief Destructor.
*
*/
~WavefrontLoader();
/**
* @fn void WavefrontLoader::load(const string &filename, shared_ptr<Model> model);
*
* @brief Loads a model from the given wavefront .obj file into the model object.
*
* @param fileLocation Path to the file in which the model is stored.
* @param model The model.
*/
void load(const string &fileLocation, Model &model);
};
}