-
Notifications
You must be signed in to change notification settings - Fork 0
/
SOff.cpp
80 lines (60 loc) · 1.02 KB
/
SOff.cpp
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
#include "SOff.h"
CSOff::CSOff()
{
}
CSOff::~CSOff()
{
}
bool CSOff::load(string path)
{
fstream file;
string token, v1, v2, v3;
float vx, vy, vz;
file.open(path, std::ios::in);
file >> token;
if (token != "SOFF")
{
file.close();
return false;
}
else
{
tipo = token;
file >> token;
mNumOfVertices = atoi(token.c_str());
file >> v1;
file >> v2;
file >> v3;
vx = atof(v1.c_str());
vy = atof(v2.c_str());
vz = atof(v3.c_str());
xMin = xMax = vx;
yMin = yMax = vy;
zMin = zMax = vz;
mVertices.push_back(glm::vec3(vx, vy, vz));
for (int i = 0; i < mNumOfVertices - 1; i++)
{
file >> v1;
file >> v2;
file >> v3;
vx = atof(v1.c_str());
vy = atof(v2.c_str());
vz = atof(v3.c_str());
mVertices.push_back(glm::vec3(vx, vy, vz));
if (vx <= xMin)
xMin = vx;
if (vy <= yMin)
yMin = vy;
if (vz <= zMin)
zMin = vz;
if (vx >= xMax)
xMax = vx;
if (vy >= yMax)
yMax = vy;
if (vz >= zMax)
zMax = vz;
}
file.close();
return true;
}
}