-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMesh.cpp
More file actions
36 lines (30 loc) · 770 Bytes
/
Copy pathMesh.cpp
File metadata and controls
36 lines (30 loc) · 770 Bytes
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
#include "Mesh.h"
using namespace ae;
Mesh::Mesh()
{
}
void Mesh::loadFromFile(const std::string &file)
{
bool triangles;
FileReader::ReadOBJ(file.c_str(), pos, uvs, normals, triangles);
vao.addVBO("position", pos);
vao.addVBO("normal", normals);
vao.addVBO("uv", uvs);
//Get bounding box /////////
minx = miny = minz = 99999;
maxx = maxy = maxz = -99999;
for(unsigned int i = 0; i < pos.size(); ++i)
{
minx = std::min(minx, pos[i].x);
maxx = std::max(maxx, pos[i].x);
miny = std::min(miny, pos[i].y);
maxy = std::max(maxy, pos[i].y);
minz = std::min(minz, pos[i].z);
maxz = std::max(maxz, pos[i].z);
}
////////////////////////////
}
agl::VAO *Mesh::getVAO()
{
return &vao;
}