-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApplication.cpp
61 lines (44 loc) · 1.67 KB
/
Application.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
#include "Application.h"
#include "defs.h"
Application::Application() {
windowManager.init(WIDTH, HEIGHT);
CoreInitInfo coreInitInfo = {};
coreInitInfo.windowManager = windowManager;
coreInitInfo.diffuseShader = Shader(SHADERS_DIR + "simpleDiffuse.vert", SHADERS_DIR + "simpleDiffuse.frag");
coreInitInfo.diffuseModels = ⊧
coreInitInfo.cubemapShader = Shader(SHADERS_DIR + "scene.vert", SHADERS_DIR + "scene.frag");
coreInitInfo.singleColorShader = Shader(SHADERS_DIR + "debug.vert", SHADERS_DIR + "debug.frag");
coreInitInfo.cubemapFaces = {
std::string(TEXTURES_DIR) + "skybox/right.jpg",
std::string(TEXTURES_DIR) + "skybox/left.jpg",
std::string(TEXTURES_DIR) + "skybox/top.jpg",
std::string(TEXTURES_DIR) + "skybox/bottom.jpg",
std::string(TEXTURES_DIR) + "skybox/front.jpg",
std::string(TEXTURES_DIR) + "skybox/back.jpg"
};
gameCore.init(coreInitInfo);
loadModels();
}
Application::~Application() {
gameCore.destroy();
windowManager.destroy();
}
void Application::start() {
gameCore.mainLoop();
}
void Application::loadModels() {
std::fstream istream(MODELS_INPUT_PATH);
std::string name;
float x, y, z, sx, sy, sz, yaw, pitch, roll;
int num;
istream >> num;
for (size_t i = 0; i < num; i++) {
istream >> name >> x >> y >> z >> sx >> sy >> sz >> roll >> yaw >> pitch;
models.emplace_back();
auto &model = models[models.size() - 1];
Model::ModelHandler::loadFromPath(&model, name);
model.translate({x, y, z});
model.scale({sx, sy, sz});
model.rotate(roll, yaw, pitch);
}
}