12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #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);
- Chunk(const Chunk& orig);
- 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 = 1;
-
- 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];
- Mesh** mesh;
- };
- #endif
|