Remove some comments and commit MeshChunk.cpp (accident)

master
aurailus 2018-12-16 00:04:55 -08:00
parent 188f6ff20e
commit 9f53d17fc0
2 changed files with 36 additions and 37 deletions

View File

@ -3,31 +3,21 @@
#define STB_IMAGE_IMPLEMENTATION
#include <iostream>
#include <vector>
#include <glew.h>
#include <glfw3.h>
#include <glm.hpp>
#include <gtc/matrix_transform.hpp>
#include <gtc/type_ptr.hpp>
#include "engine/Window.h"
#include "engine/Camera.h"
#include "engine/graphics/Texture.h"
#include "mesh/BlockModel.h"
#include "engine/graphics/Shader.h"
#include "mesh/MeshGenerator.h"
#include "engine/Entity.h"
#include "engine/Timer.h"
#include "engine/TextureAtlas.h"
#include "UDP.h"
#include "engine/PerlinNoise.h"
#include "blocks/BlockAtlas.h"
#include "world/World.h"
#include "engine/PerlinNoise.h"
#include "engine/helpers/ArrayTrans3D.h"
#include "engine/Timer.h"
Window* window;
Shader* shader;
std::vector<Entity*> entities;
Camera* camera;
TextureAtlas* textureAtlas;
@ -136,8 +126,6 @@ void genChunks(World* world) {
double val = p.noise(pos.x / (double) 32, pos.z / (double) 32, pos.y / (double) 16) - pos.y * 0.08;
std::cout << (int)(val > 0.5) << std::endl;
blocks->push_back((int)(val > 0.5));
}
@ -148,34 +136,19 @@ void genChunks(World* world) {
}
int main(int argc, char* argv[]) {
// UDP().start(argc, argv);
// return 0;
Timer boot("Initialization");
//Window
window = new Window(1366, 768);
window->initialize();
//Create camera
camera = new Camera(glm::vec3(0.0f, 16.0f, 0.0f), glm::vec3(0, 1, 0), -90.0f, -45.0f, 10.0f, 0.1f);
//Load Textures
textureAtlas = new TextureAtlas("../Textures");
//Create model
blockAtlas = createAtlas();
//Create world
world = new World(blockAtlas);
// for (int i = 0; i < 17; i++) {
// world->newChunk(new glm::vec3(i, 0, 0), nullptr);
// }
//Generate Chunks
genChunks(world);
//Create shader
shader = new Shader();
shader->createFromFile("../GlProject/shader/world.vs", "../GlProject/shader/world.fs");
@ -215,11 +188,6 @@ int main(int argc, char* argv[]) {
textureAtlas->getTexture()->use();
// for (auto &entity : entities) {
// glUniformMatrix4fv(shader->getModelLocation(), 1, GL_FALSE, glm::value_ptr(entity->getModelMatrix()));
// entity->draw();
// }
world->draw(shader->getModelLocation());
Shader::clearShader();

View File

@ -0,0 +1,31 @@
//
// Created by aurailus on 15/12/18.
//
#include "MeshChunk.h"
MeshChunk::MeshChunk() {
ready = false;
}
MeshChunk::MeshChunk(BlockChunk *blockChunk) {
this->blockChunk = blockChunk;
ready = false;
}
bool MeshChunk::isReady() {
return ready;
}
void MeshChunk::build(BlockAtlas* atlas) {
std::vector<float> vertices;
std::vector<unsigned int> indices;
MeshGenerator mg;
mg.build(blockChunk, atlas, vertices, indices);
auto *mesh = new Mesh();
mesh->create(&vertices, &indices);
this->create(mesh);
}