Change Scene to World

This commit is contained in:
4VRDriver
2020-09-14 21:59:13 +02:00
parent 9d93d6efc3
commit b957e4a5ee
5 changed files with 42 additions and 41 deletions

View File

@@ -1,48 +0,0 @@
#include "Scene.h"
#include <iostream>
// At this moment, I don't have any idea how to implement the initializer list
// with an array of objects that don't have an default contructor. So the default
// constructors for Light and PointLight have only this reason to exist.
Scene::Scene(ShaderProgram *shaderProgram)
: shaderProgram(shaderProgram) {
for(unsigned int i = 0; i < NUM_POINT_LIGHTS; i++) {
pointLights[i].setId(i);
pointLights[i].setShaderProgram(shaderProgram);
}
}
void Scene::addEntity(Entity entity) {
uint32_t new_id = entities.size();
entity.setId(new_id);
entities.push_back(entity);
}
void Scene::removeEntity(uint32_t id) {
for(auto it = entities.begin(); it != entities.end(); it++) {
if(it->getId() == id) {
entities.erase(it);
}
}
std::cout << "[Warning] Entity with ID " << id << " could not be removed." << std::endl;
}
void Scene::updateLight(unsigned int lightId, glm::vec3 position, glm::vec3 color) {
pointLights[lightId].setActive(true);
pointLights[lightId].setPosition(position);
pointLights[lightId].setColor(color);
}
void Scene::drawScene(glm::mat4 viewProjMatrix, glm::vec3 viewPosition) {
for(auto it = entities.begin(); it != entities.end(); it++) {
it->draw(viewProjMatrix, viewPosition);
}
}