-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjLoader.h
More file actions
87 lines (68 loc) · 2.3 KB
/
objLoader.h
File metadata and controls
87 lines (68 loc) · 2.3 KB
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
#ifndef COLOR_STRUCT_H
#define COLOR_STRUCT_H
#include <bits/stdc++.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <unistd.h>
#include <glm/glm.hpp>
#include "primitive_structs.h"
using namespace std;
class Object
{
/* Class for handling blender generated obj and mtl files and
drawing and rendering these models on the OpengGL scene */
public:
/* Function to read .obj file and parse vertices, normals and faces
from it. These vertices and normals are stored in the vector arrays as per
the indexing used in the face vector
Parameters:
----------
path: char*
path for the obj file
out_vertices : vector<gln::vec3>
vector array to store the vertices
out_normals : vector<glm::vec3>
vector array to store the norrmals
color_material : vector<string>
vector to store the string defining the color material to be used for each face
*/
bool loadOBJ(
const char * path,
vector<glm::vec3> & out_vertices,
vector<glm::vec3> & out_normals,
vector<string> & color_material);
/* Function to Draw the blender object model using the loaded vertices and normal
vector arrays using openGL. The generated faces are all triangulated and the vertices and
normal arrays are presorted in the order of the faces they belong to
Parameters:
----------
vertices : vector< glm::vec3 >
vector that has the vertices stored for the object
normals : vector< glm::vec3 >
vector that has the normals store for the object
colors : <vector <string>
vector that has the color string used for each face
colorMap : map
map between the color string and Color struct for setting the color of the faces
*/
void drawOBJ(
vector< glm::vec3 > vertices,
vector< glm::vec3 > normals,
vector< string > colors,
map<string, Color> colorMap,
double x, double y, double z,
double angle, double rx, double ry, double rz,
double sx, double sy, double sz);
/* Function to read .mtl Material file and create a string to struct Color map
to be later referenced for coloring the faces of the blender generated model in
the OpenGL scene
Parameters:
----------
filename : string
filename for the mtl material file
colorMap : map
Map for storing the color name string and the RGB struct contaiing the corresponding RGB values
*/
bool loadColors(string filename, map<string, Color> &colorMap);
};
#endif