Loaded all marching cube models into marching cube renderer.

This commit is contained in:
Warwick 2022-08-15 11:33:16 +01:00
parent 8a699ae422
commit bb349e9994
3 changed files with 28 additions and 9 deletions

@ -1 +1 @@
Subproject commit 40364e65f0acfcd74effad083c94a179f765678a
Subproject commit d1d1c195d789a9815e1585f29b74515b3fd32c72

View file

@ -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);

View file

@ -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);