2014-10-30 22:54:19 +00:00
|
|
|
#include "level.hh"
|
|
|
|
|
|
|
|
Level::Level(std::string filePath){
|
|
|
|
this->filePath = filePath;
|
2014-11-07 15:55:56 +00:00
|
|
|
this->terrain = Terrain(filePath + "/terrain");
|
2014-10-30 22:54:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Level::Level() {
|
|
|
|
}
|
|
|
|
|
|
|
|
Level::~Level() {
|
|
|
|
}
|
|
|
|
|
2014-11-08 01:45:32 +00:00
|
|
|
void Level::load(ACGL::OpenGL::SharedShaderProgram shader) {
|
2014-10-30 22:54:19 +00:00
|
|
|
// currently hard coded should later read this stuff out of a file
|
2014-11-14 17:32:16 +00:00
|
|
|
this->camera = Camera(glm::vec2(-0.8f, 0.0f), 3.0f);
|
2014-10-30 22:54:19 +00:00
|
|
|
// load the geometry of the stanford bunny and build a VAO:
|
2014-11-13 00:22:33 +00:00
|
|
|
Model model = Model("Bunny.obj", 0.25f);
|
2014-10-30 22:54:19 +00:00
|
|
|
// load a texture:
|
2014-11-08 00:44:24 +00:00
|
|
|
Material material = Material("clownfishBunny.png", 0.1f, 0.5f, 0.5f, 3.0f);
|
2014-10-30 22:54:19 +00:00
|
|
|
//Create object
|
2014-11-13 00:22:33 +00:00
|
|
|
Object object = Object(model, material, glm::vec3(0.0f, -1.0f, -2.0f),
|
|
|
|
glm::vec3(0.0f, 1.0472f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f),
|
2014-10-30 22:54:19 +00:00
|
|
|
glm::vec3(0.0f, 0.0f, 0.0f), shader);
|
|
|
|
objects.push_back(object);
|
2014-11-13 00:22:33 +00:00
|
|
|
cameraCenter = &objects[0];
|
2014-10-31 09:38:57 +00:00
|
|
|
//set lighting parameters
|
2014-11-08 00:15:09 +00:00
|
|
|
ambientLight = glm::vec3(1.0f, 1.0f, 1.0f);
|
2014-11-03 23:46:49 +00:00
|
|
|
Light light = Light(glm::vec3(-3.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 0.0f, 0.0f), 2.0f);
|
2014-10-31 11:56:09 +00:00
|
|
|
lights.push_back(light);
|
2014-11-03 23:46:49 +00:00
|
|
|
Light light2 = Light(glm::vec3(3.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), 2.0f);
|
2014-10-31 11:56:09 +00:00
|
|
|
lights.push_back(light2);
|
2014-11-13 00:22:33 +00:00
|
|
|
// load terrain
|
|
|
|
this->terrain.load();
|
2014-10-30 22:54:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Level::render() {
|
2014-11-08 01:45:32 +00:00
|
|
|
for(unsigned int i = 0; i<objects.size(); i++) {
|
2014-10-30 22:54:19 +00:00
|
|
|
objects[i].render();
|
|
|
|
}
|
2014-11-11 11:22:47 +00:00
|
|
|
this->terrain.render();
|
2014-10-30 22:54:19 +00:00
|
|
|
}
|
2014-10-30 22:59:03 +00:00
|
|
|
|
2014-11-12 23:40:28 +00:00
|
|
|
void Level::update(float runTime) {
|
|
|
|
// rotate bunny
|
2014-11-13 00:22:33 +00:00
|
|
|
cameraCenter->setRotation(glm::vec3(0.0f, 1.0472f * runTime, 0.0f));
|
2014-11-12 23:40:28 +00:00
|
|
|
}
|
|
|
|
|
2014-10-30 22:59:03 +00:00
|
|
|
glm::vec3 Level::getAmbientLight() {
|
|
|
|
return ambientLight;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<Light> Level::getLights() {
|
|
|
|
return lights;
|
|
|
|
}
|
2014-11-13 00:22:33 +00:00
|
|
|
|
2014-11-13 16:19:56 +00:00
|
|
|
Camera Level::getCamera() {
|
|
|
|
return camera;
|
2014-11-13 00:22:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Object* Level::getCameraCenter() {
|
|
|
|
return cameraCenter;
|
|
|
|
}
|