diff --git a/data/game-models b/data/game-models index 40364e6..d1d1c19 160000 --- a/data/game-models +++ b/data/game-models @@ -1 +1 @@ -Subproject commit 40364e65f0acfcd74effad083c94a179f765678a +Subproject commit d1d1c195d789a9815e1585f29b74515b3fd32c72 diff --git a/src/Model.cpp b/src/Model.cpp index ef329b9..353cbf2 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -33,7 +33,7 @@ void Model::resize(glm::vec3 scale) { // Return model to position. this->setPosition(pos); - this->scale = scale; + this->scale = this->scale * scale; } void Model::rotate(float angle, glm::vec3 axis) { this->model = glm::rotate(this->model, angle, axis); diff --git a/src/Terrain.cpp b/src/Terrain.cpp index bd9d45f..e4e6ea4 100644 --- a/src/Terrain.cpp +++ b/src/Terrain.cpp @@ -14,19 +14,38 @@ Terrain::Terrain() : renderer(nullptr) { chunks.push_back(Chunk(fnGenerator, ti)); - // Create chunks renderer. - models = {new Model(ROOT_DIR "data/game-models/12/MetalFloor.obj")}; - models.at(0)->resize(glm::vec3(0.5f)); + // Create models for chunk renderer to use. + models = { + new Model(ROOT_DIR "data/game-models/1/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/2/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/3/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/4/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/5/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/6/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/7/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/8/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/9/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/10/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/11/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/12/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/13/MetalFloor.obj"), + new Model(ROOT_DIR "data/game-models/14/MetalFloor.obj"), + }; + // Resize models to fit in coordinate system. + for (int i = 0; i < models.size(); i++) { + models.at(i)->resize(glm::vec3(0.5f)); + } + // Create chunk renderer. renderer = new MarchingCubeChunkRenderer(this->chunks, models); } Terrain::~Terrain() { - // Since we created our renderer member in our constructer it has to be a - // nullptr before being updated to the created object, which means it's - // lifecycle needs to be managed by this class. + // Since we created our renderer member in our constructer and defined it in + // the header file it has to be a nullptr before being updated to the created + // object, which means it's lifecycle needs to be managed by this class. delete renderer; - // Creating models here for OPENGL purposes means that we can't duplicate the + // Creating models here for OpenGL purposes means that we can't duplicate the // data, so we need to delete them after creating them as pointers. for (int i = 0; i < models.size(); i++) { delete models.at(i);