123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #ifndef CHUNK_H
- #define CHUNK_H
- #include "../engine/Mesh.h"
- #include "../engine/Shader.h"
- #include "../engine/DirectRenderer.h"
- class Chunk
- {
- public:
- Chunk(int chunkX, int chunkZ);
- virtual ~Chunk();
-
- void setBlock(int x, int y, int z, unsigned short block);
- unsigned short getBlock(int x, int y, int z);
-
- void renderTick(Shader& shader, DirectRenderer& dr, float lag);
-
- // chunk constants
- static const int PARTION_HEIGHT = 16;
- static const int HEIGHT_PARTIONS = 16;
-
- static const int WIDTH = 16;
- static const int HEIGHT = PARTION_HEIGHT * HEIGHT_PARTIONS;
- static const int DEPTH = 16;
-
- static const int BITMASK_WIDTH = WIDTH - 1;
- static const int BITMASK_HEIGHT = HEIGHT - 1;
- static const int BITMASK_DEPTH = DEPTH - 1;
- private:
- void buildChunk(int partionY);
-
- int chunkX;
- int chunkZ;
-
- unsigned short blocks[HEIGHT][WIDTH][DEPTH];
- bool dirty[HEIGHT_PARTIONS];
- ChunkMesh* mesh;
- };
- #endif
|