Repository navigation
Expand file tree
/
Copy pathModels.hxx
More file actions
73 lines (60 loc) · 1.64 KB
/
Copy pathModels.hxx
File metadata and controls
73 lines (60 loc) · 1.64 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
#ifndef MODELS_HXX
#define MODELS_HXX
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <fstream>
#include <iostream>
#include <limits>
#include "portable.h"
#include "RgbImage.h"
struct Material
{
GLfloat Ka[4], Kd[4], Ks[4], Ns;
Material();
void setKa(GLfloat r, GLfloat g, GLfloat b);
void setKd(GLfloat r, GLfloat g, GLfloat b);
void setKs(GLfloat r, GLfloat g, GLfloat b);
void setNs(GLfloat ns);
};
struct Model
{
int numVertex, numNormals, numTexPoints, numFaces;
int** faces;
GLfloat height, width;
float **vertex, **normals, **texPoints;
unsigned int textureMode, hWrap, vWrap;
Model();
~Model();
void allocSpace();
void draw();
void assignTexture(GLuint id);
void assignMaterial(Material* mat);
void createBBox(GLfloat _height, GLfloat _width);
void setTextureEnvironment(void);
private:
GLuint texId;
GLuint matId;
Material* material;
int *_faces;
float *_vertex, *_normals, *_texPoints;
};
class ModelsManager
{
public:
ModelsManager(std::string dir, std::string modelsList);
~ModelsManager();
Model* getModel(const std::string name);
private:
std::vector<Model*> modelsVector;
std::map<std::string, int> modelIndexMap;
std::map<std::string, GLuint> texIdMap;
std::map<std::string, Material*> materialMap;
void loadModel(const std::string& objFile, const std::string& modelName, int objNum);
void countObjFileSizes(std::ifstream& objFile, Model* count);
void loadTexture(std::string dir, std::string name);
void loadMaterial(std::string dir, std::string file);
};
#endif