Chunk.h 999 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef CHUNK_H
  2. #define CHUNK_H
  3. #include "../engine/Mesh.h"
  4. #include "../engine/Shader.h"
  5. #include "../engine/DirectRenderer.h"
  6. class Chunk
  7. {
  8. public:
  9. Chunk(int chunkX, int chunkZ);
  10. virtual ~Chunk();
  11. void setBlock(int x, int y, int z, unsigned short block);
  12. unsigned short getBlock(int x, int y, int z);
  13. void renderTick(Shader& shader, DirectRenderer& dr, float lag);
  14. // chunk constants
  15. static const int PARTION_HEIGHT = 16;
  16. static const int HEIGHT_PARTIONS = 16;
  17. static const int WIDTH = 16;
  18. static const int HEIGHT = PARTION_HEIGHT * HEIGHT_PARTIONS;
  19. static const int DEPTH = 16;
  20. static const int BITMASK_WIDTH = WIDTH - 1;
  21. static const int BITMASK_HEIGHT = HEIGHT - 1;
  22. static const int BITMASK_DEPTH = DEPTH - 1;
  23. private:
  24. void buildChunk(int partionY);
  25. int chunkX;
  26. int chunkZ;
  27. unsigned short blocks[HEIGHT][WIDTH][DEPTH];
  28. bool dirty[HEIGHT_PARTIONS];
  29. ChunkMesh* mesh;
  30. };
  31. #endif