-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTriangleMesh.h
executable file
·54 lines (42 loc) · 1.21 KB
/
TriangleMesh.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
#ifndef MIRO_TRIANGLE_MESH_H_INCLUDED
#define MIRO_TRIANGLE_MESH_H_INCLUDED
#include "Matrix4x4.h"
class TriangleMesh
{
public:
TriangleMesh();
~TriangleMesh();
// load from an OBJ file
bool load(char* file, const Matrix4x4& ctm = Matrix4x4());
// for single triangles
void createSingleTriangle();
inline void setV1(const Vector3& v) {m_vertices[0] = v;}
inline void setV2(const Vector3& v) {m_vertices[1] = v;}
inline void setV3(const Vector3& v) {m_vertices[2] = v;}
inline void setN1(const Vector3& n) {m_normals[0] = n;}
inline void setN2(const Vector3& n) {m_normals[1] = n;}
inline void setN3(const Vector3& n) {m_normals[2] = n;}
struct TupleI3
{
unsigned int x, y, z;
};
struct VectorR2
{
float x, y;
};
Vector3* vertices() {return m_vertices;}
Vector3* normals() {return m_normals;}
TupleI3* vIndices() {return m_vertexIndices;}
TupleI3* nIndices() {return m_normalIndices;}
int numTris() {return m_numTris;}
protected:
void loadObj(FILE* fp, const Matrix4x4& ctm);
Vector3* m_normals;
Vector3* m_vertices;
VectorR2* m_texCoords;
TupleI3* m_normalIndices;
TupleI3* m_vertexIndices;
TupleI3* m_texCoordIndices;
unsigned int m_numTris;
};
#endif // MIRO_TRIANGLE_MESH_H_INCLUDED