-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathmodel.h
26 lines (24 loc) · 1.45 KB
/
model.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
#include "geometry.h"
#include "tgaimage.h"
class Model {
std::vector<vec3> verts = {}; // array of vertices ┐ generally speaking, these arrays
std::vector<vec3> norms = {}; // array of normal vectors │ do not have the same size
std::vector<vec2> tex = {}; // array of tex coords ┘ check the logs of the Model() constructor
std::vector<int> facet_vrt = {}; // ┐ per-triangle indices in the above arrays,
std::vector<int> facet_nrm = {}; // │ the size is supposed to be
std::vector<int> facet_tex = {}; // ┘ nfaces()*3
TGAImage diffusemap = {}; // diffuse color texture
TGAImage normalmap = {}; // normal map texture
TGAImage specularmap = {}; // specular texture
public:
Model(const std::string filename);
int nverts() const; // number of vertices
int nfaces() const; // number of triangles
vec3 vert(const int i) const; // 0 <= i < nverts()
vec3 vert(const int iface, const int nthvert) const; // 0 <= iface <= nfaces(), 0 <= nthvert < 3
vec3 normal(const int iface, const int nthvert) const; // normal coming from the "vn x y z" entries in the .obj file
vec3 normal(const vec2 &uv) const; // normal vector from the normal map texture
vec2 uv(const int iface, const int nthvert) const; // uv coordinates of triangle corners
const TGAImage& diffuse() const;
const TGAImage& specular() const;
};