diff --git a/SQCSim2021/chunk.cpp b/SQCSim2021/chunk.cpp index 356d5b6..8bd383a 100644 --- a/SQCSim2021/chunk.cpp +++ b/SQCSim2021/chunk.cpp @@ -1,6 +1,6 @@ #include "chunk.h" -Chunk::Chunk() { m_blocks.Reset(BTYPE_AIR); } +Chunk::Chunk(int x, int y) : m_posX(x), m_posY(y) { m_blocks.Reset(BTYPE_AIR); } Chunk::~Chunk() { } diff --git a/SQCSim2021/chunk.h b/SQCSim2021/chunk.h index ec0e9b6..6b52fcc 100644 --- a/SQCSim2021/chunk.h +++ b/SQCSim2021/chunk.h @@ -2,6 +2,7 @@ #define CHUNK_H__ #include "define.h" #include "array3d.h" +#include "array2d.h" #include "vertexbuffer.h" #include "blockinfo.h" @@ -11,10 +12,13 @@ class Chunk { VertexBuffer m_vertexBuffer; bool m_isDirty = true; + int m_posX; // Position du chunk dans l'array constituant le monde. + int m_posY; + void AddBlockToMesh(VertexBuffer::VertexData* vd, int& count, BlockType bt, int x, int y, int z, float u, float v, float s); public: - Chunk(); + Chunk(int x, int y); ~Chunk(); void RemoveBlock(int x, int y, int z); diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index df1d566..e6811d6 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -48,16 +48,24 @@ void Engine::Init() m_audio.ToggleMusicState(); // Init Chunks - for (int x = 0; x < CHUNK_SIZE_X; ++x) + /*for (int x = 0; x < CHUNK_SIZE_X; ++x) for (int z = 0; z < CHUNK_SIZE_Z; ++z) for (int y = 0; y < 32; ++y) - m_testChunk.SetBlock(x, y, z, BTYPE_DIRT); + m_testChunk->SetBlock(x, y, z, BTYPE_DIRT);*/ for (int chx = 0; chx < VIEW_DISTANCE; ++chx) - for (int chy = 0; chy < VIEW_DISTANCE; ++chy) - m_chunks.Set(chx, chy, &m_testChunk); + for (int chy = 0; chy < VIEW_DISTANCE; ++chy) { + + m_chunks.Set(chx, chy, new Chunk(chx, chy)); - //m_chunks.Set(0, 0, &m_testChunk); + for (int x = 0; x < CHUNK_SIZE_X; ++x) + for (int z = 0; z < CHUNK_SIZE_Z; ++z) + for (int y = 0; y < 32; ++y) + m_chunks.Get(chx,chy)->SetBlock(x, y, z, BTYPE_DIRT); + + m_chunks.Get(chx,chy)->SetBlock(8, chx+32, 8, BTYPE_DIRT); + + } // Gestion de souris. CenterMouse(); diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 05acf17..4b8cf2a 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -50,7 +50,7 @@ private: Skybox m_skybox; Shader m_shader01; - Chunk m_testChunk; + Chunk* m_testChunk; Audio m_audio = Audio(AUDIO_PATH "music01.wav"); Player m_player = Player(Vector3f(0, 0, 0));