diff options
Diffstat (limited to '')
-rw-r--r-- | src/chunk.hpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/chunk.hpp b/src/chunk.hpp index d10adc9..e2cfab5 100644 --- a/src/chunk.hpp +++ b/src/chunk.hpp @@ -1,6 +1,9 @@ #pragma once #include "xe_model.hpp" +#include "xe_engine.hpp" +#include "xe_image.hpp" + #include "PerlinNoise.hpp" #include <glm/common.hpp> @@ -11,19 +14,30 @@ #include <string> #include <map> -#define INVALID 0 -#define AIR 1 -#define DIRT 2 -#define GRASS 3 +#define INVALID -1 +#define AIR 0 +#define DIRT 1 +#define GRASS 2 + +#define DIRT_TEXTURE "res/image/dirt.png" +#define GRASS_TEXTURE "res/image/grass.png" +#define GRASS_TOP_TEXTURE "res/image/grass_top.png" namespace app { +struct Block { + uint32_t textures[6]; +}; + class Chunk { public: + static void load(); + static void unload(); + static std::vector<xe::Image*>& getTextures(); + static Chunk* newChunk(int32_t gridX, int32_t gridZ, uint32_t world_seed); - static void reset(); Chunk(int32_t gridX, int32_t gridZ, uint32_t world_seed); ~Chunk() {}; @@ -43,16 +57,16 @@ class Chunk { private: void generate(); - void addVerticies(uint8_t side, int32_t x, int32_t y, int32_t z); + void addVerticies(uint8_t side, int32_t x, int32_t y, int32_t z, uint8_t block); bool reloadRequired{false}; bool working{false}; std::shared_ptr<xe::Model> chunkMesh; - std::vector<float> vertexData; - std::vector<uint8_t> blocks; + xe::Model::Data vertexData; + std::vector<uint8_t> cubes; std::thread worker; - + }; const float px[36][3] = { |