-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuadMesh.h
executable file
·59 lines (48 loc) · 1.36 KB
/
QuadMesh.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
// Jared Rand
// 500683609
#ifndef QUADMESH_H
#define QUADMESH_H
#define GL_SILENCE_DEPRECATION
#ifdef __APPLE__
#include <glut/glut.h>
#else
#include <gl/glut.h>
#endif
#include <stdbool.h>
#include "Vector3D.h"
#include "Util.h"
// Data structure for a vertex
typedef struct MeshVertex
{
Vector3D position;
Vector3D normal;
} MeshVertex;
// Data structure for a quad (4-sided polygon)
typedef struct MeshQuad
{
// pointers to vertices of each quad in the array of vertices
MeshVertex *vertices[4];
} MeshQuad;
typedef struct
{
int maxMeshSize;
float meshDim;
int numVertices;
MeshVertex *vertices; // Dynamic array of all vertices
int numQuads;
MeshQuad *quads; // Dynamic array of all quads
int numFacesDrawn;
GLfloat mat_ambient[4];
GLfloat mat_specular[4];
GLfloat mat_diffuse[4];
GLfloat mat_shininess[1];
Texture* texture;
} QuadMesh;
QuadMesh NewQuadMesh(int maxMeshSize, Texture* texture);
void SetMaterialQM(QuadMesh* qm, Vector3D ambient, Vector3D diffuse, Vector3D specular, double shininess);
bool CreateMemoryQM(QuadMesh* qm);
bool InitMeshQM(QuadMesh* qm, int meshSize, Vector3D origin, double meshLength, double meshWidth, Vector3D dir1, Vector3D dir2);
void DrawMeshQM(QuadMesh* qm, int meshSize);
void FreeMemoryQM(QuadMesh* qm);
void ComputeNormalsQM(QuadMesh* qm);
#endif