-
Notifications
You must be signed in to change notification settings - Fork 0
/
objreader.h
72 lines (62 loc) · 1.56 KB
/
objreader.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
#ifndef OBJREADER
#define OBJREADER
#include <memory>
#include "cs314_math.hpp"
namespace akj
{
class cVertexArray;
}
namespace cs314
{
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% class objReader %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
class cObjReader
{
public:
cObjReader(const char *filename);
~cObjReader();
void loadObj(const char *filename);
void getBoundingVolume(float *minX, float *maxX,
float *minY, float *maxY,
float *minZ, float *maxZ);
int getVertexCount();
int getTriangleCount();
void centerObject();
void resizeObject();
akj::cVertexArray* GetNextVertexArray(const char* prefix = "" );
private:
struct face
{
int v[3]; // vertices
int n[3]; // normals
int t[3]; // texture coords
};
struct cFaceGroup
{
cFaceGroup(){}
~cFaceGroup(){}
cFaceGroup(const char* name, int reserved_size)
: mGroupName(name)
{
mFaceList.reserve(reserved_size);
}
std::string mGroupName;
std::vector<face> mFaceList;
};
std::vector<cCoord3> mVertexList; // loaded vertex data
std::vector<cCoord3> mNormalList; // loaded normal data
std::vector<cCoord3> mTexcoordList; // loaded texture coordinate data
std::vector<cFaceGroup> mFaceGroups;
int mFaceGroupIndex;
float m_maxX; // maximum and mininum x, y and z values
float m_minX; // for loaded object
float m_maxY; //
float m_minY; //
float m_maxZ; //
float m_minZ; //
};
}
#endif