void Program saveSceneState const char path const std ofstream st path

 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
void Program::saveSceneState(const char *path) const {
std::ofstream st(path);
st << winWidth << " " << winHeight << std::endl;
st << moveFigure << " " << animationOn << " " << textureOn << " " << polygonMode << std::endl;
st << trianglesNum << std::endl;
st << speedVec.x << " " << speedVec.y << " " << speedVec.z << std::endl;
st << lightModel.l(GL_LIGHT0).isOn() << " " << lightModel.l(GL_LIGHT1).isOn() << std::endl;
Point p = lightModel.l(GL_LIGHT1).getPosition();
st << p.x << " " << p.y << " " << p.z << std::endl;
st << parbl.center.x << " " << parbl.center.y << " " << parbl.center.z << std::endl;
st << parbl.height << std::endl << parbl.scale << std::endl << parbl.rots.size() << std::endl;
for (const auto &r: parbl.rots) {
st << r.first << " " << r.second << std::endl;
}
st.close();
}
void Program::loadSceneState(const char *path) {
std::ifstream st(path);
Point pos{};
int rotsNum, axis;
float angle;
st >> winWidth >> winHeight;
st >> moveFigure >> animationOn >> textureOn >> polygonMode;
st >> trianglesNum;
st >> speedVec.x >> speedVec.y >> speedVec.z;
st >> l0 >> l1;
st >> pos.x >> pos.y >> pos.z;
st >> parbl.center.x >> parbl.center.y >> parbl.center.z;
st >> parbl.height >> parbl.scale;
st >> rotsNum;
glfwSetWindowSize(window, winWidth, winHeight);
project(winWidth, winHeight);
if (l0) lightModel.l(GL_LIGHT0).enable(); else lightModel.l(GL_LIGHT0).disable();
if (l1) lightModel.l(GL_LIGHT1).enable(); else lightModel.l(GL_LIGHT1).disable();
lamp.setPosition(pos);
parbl.rots.clear();
for (int i = 0; i < rotsNum; i++) {
st >> axis >> angle;
parbl.rots.emplace_back(axis, angle);
}
st.close();
parbl.buildFrame(trianglesNum);
parbl.mat.textureOn = textureOn;
}