/
OBJ.h
50 lines (40 loc) · 1.36 KB
/
OBJ.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
//////////////////////////////////////////////////////////////////////////////////////
// Copyright © Charalambos "Charis" Poullis, charalambos@poullis.org //
// http://www.poullis.org //
//////////////////////////////////////////////////////////////////////////////////////
#ifndef __OBJ_H__
#define __OBJ_H__
#include <stdarg.h>
#include <stdio.h>
#include <Eigen/Eigen>
using namespace Eigen;
#include <vector>
using namespace std;
///Face structure has a set of vertex, normal and texture indices.
typedef struct Face {
std::vector<int> vertex_indices;
std::vector<int> normal_indices;
std::vector<int> texture_indices;
} Face;
///The OBJ class which is used by the parser to populate the information in the structures.
class OBJ {
public:
OBJ();
~OBJ();
void AddVertex(double vx,double vy,double vz);
void AddNormal(double nx, double ny,double nz);
void AddTextureCoord(double tx,double ty);
void AddFace(std::vector<int> const &vertexIndices,
std::vector<int> const &normalIndices,
std::vector<int> const &textureIndices);
void Print(void);
bool has_tex_coords;
bool has_normals;
private:
//structures
std::vector<Vector3d> vertices;
std::vector<Vector3d> normals;
std::vector<Vector2d> texture_coords;
std::vector<Face *> faces;
};
#endif