Chunk.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. Chunk(const Chunk& orig);
  11. virtual ~Chunk();
  12. void setBlock(int x, int y, int z, unsigned short block);
  13. unsigned short getBlock(int x, int y, int z);
  14. void renderTick(Shader& shader, DirectRenderer& dr, float lag);
  15. // chunk constants
  16. static const int PARTION_HEIGHT = 16;
  17. static const int HEIGHT_PARTIONS = 1;
  18. static const int WIDTH = 16;
  19. static const int HEIGHT = PARTION_HEIGHT * HEIGHT_PARTIONS;
  20. static const int DEPTH = 16;
  21. static const int BITMASK_WIDTH = WIDTH - 1;
  22. static const int BITMASK_HEIGHT = HEIGHT - 1;
  23. static const int BITMASK_DEPTH = DEPTH - 1;
  24. private:
  25. void buildChunk(int partionY);
  26. int chunkX;
  27. int chunkZ;
  28. unsigned short blocks[HEIGHT][WIDTH][DEPTH];
  29. bool dirty[HEIGHT_PARTIONS];
  30. Mesh** mesh;
  31. };
  32. #endif