diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index fc03441..431897a 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -35,7 +35,7 @@ void Engine::Init() { m_skybox.Init(0.00013f); // Objet de musique! - m_audio.ToggleMusicState(); + //m_audio.ToggleMusicState(); // Init Chunks m_world.GetChunks().Reset(nullptr); @@ -52,9 +52,9 @@ void Engine::LoadResource() { LoadTexture(m_textureCrosshair, TEXTURE_PATH "cross.bmp"); LoadTexture(m_textureFont, TEXTURE_PATH "font.bmp"); TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png"); - TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png"); + TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png"); TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png"); - TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal.png"); + TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal1.png"); if (!m_textureAtlas.Generate(512, false)) { std::cout << " Unable to generate texture atlas ..." << std::endl; diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 1eeff0d..e1e4626 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -47,7 +47,7 @@ private: TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST); World m_world = World(); - Perlin m_perlin = Perlin(4,32.f,7.f,12345); + Perlin m_perlin = Perlin(8,45.f,7.f,12345); Texture m_textureSkybox; Texture m_textureFont; diff --git a/SQCSim2021/media/chunks/16357_16343.chunk b/SQCSim2021/media/chunks/16357_16343.chunk deleted file mode 100644 index 96cfa40..0000000 --- a/SQCSim2021/media/chunks/16357_16343.chunk +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/SQCSim2021/media/chunks/16382_16360.chunk b/SQCSim2021/media/chunks/16382_16360.chunk deleted file mode 100644 index 7f5c474..0000000 Binary files a/SQCSim2021/media/chunks/16382_16360.chunk and /dev/null differ diff --git a/SQCSim2021/media/chunks/16382_16377.chunk b/SQCSim2021/media/chunks/16382_16377.chunk deleted file mode 100644 index a62d18d..0000000 Binary files a/SQCSim2021/media/chunks/16382_16377.chunk and /dev/null differ diff --git a/SQCSim2021/media/chunks/16382_16382.chunk b/SQCSim2021/media/chunks/16382_16382.chunk deleted file mode 100644 index 21daccc..0000000 Binary files a/SQCSim2021/media/chunks/16382_16382.chunk and /dev/null differ diff --git a/SQCSim2021/media/chunks/16382_16383.chunk b/SQCSim2021/media/chunks/16382_16383.chunk deleted file mode 100644 index 63cd548..0000000 Binary files a/SQCSim2021/media/chunks/16382_16383.chunk and /dev/null differ diff --git a/SQCSim2021/media/chunks/16383_16382.chunk b/SQCSim2021/media/chunks/16383_16382.chunk deleted file mode 100644 index 2868119..0000000 Binary files a/SQCSim2021/media/chunks/16383_16382.chunk and /dev/null differ diff --git a/SQCSim2021/media/chunks/16383_16383.chunk b/SQCSim2021/media/chunks/16383_16383.chunk deleted file mode 100644 index 5781824..0000000 Binary files a/SQCSim2021/media/chunks/16383_16383.chunk and /dev/null differ diff --git a/SQCSim2021/world.cpp b/SQCSim2021/world.cpp index 7dd8012..eadf6c8 100644 --- a/SQCSim2021/world.cpp +++ b/SQCSim2021/world.cpp @@ -148,8 +148,8 @@ bool World::GenerateChunk(int chx, int chy, Perlin& perlin) { float xnoiz, ynoiz; xnoiz = (double)(x + (chx / CHUNK_SIZE_X + m_center[0]) * CHUNK_SIZE_X) / (double)INT16_MAX; ynoiz = (double)(z + (chy / CHUNK_SIZE_Z + m_center[1]) * CHUNK_SIZE_Z) / (double)INT16_MAX; - float height = (perlin.Get(xnoiz, ynoiz)) * 10.f; - for (int y = 0; y <= (int)height; ++y) + float height = (perlin.Get(xnoiz, ynoiz)) * 20.f + 5.f; + for (int y = 0; y <= (int)height % CHUNK_SIZE_Y; ++y) chunk->SetBlock(x, y, z, BTYPE_METAL, this); } @@ -158,7 +158,7 @@ bool World::GenerateChunk(int chx, int chy, Perlin& perlin) { float xnoiz, ynoiz; xnoiz = (double)(x + (chx / CHUNK_SIZE_X + m_center[0]) * CHUNK_SIZE_X) / (double)INT16_MAX; ynoiz = (double)(z + (chy / CHUNK_SIZE_Z + m_center[1]) * CHUNK_SIZE_Z) / (double)INT16_MAX; - float height = (perlin.Get(xnoiz, ynoiz) + 16.f); + float height = perlin.Get(xnoiz, ynoiz) * 5.f + 16.f; for (int y = 0; y <= (int)height % CHUNK_SIZE_Y; ++y) { if (chunk->GetBlock(x, y, z) == BTYPE_AIR) chunk->SetBlock(x, y, z, BTYPE_GRASS, this); @@ -272,14 +272,14 @@ void World::RenderWorld(int& rendercount, int& badhitcount, Player& player, Tran direct.Normalize(); pos.y = 1; - static Vector3i renderManifest[VIEW_DISTANCE * 4]; + static Vector3f renderManifest[VIEW_DISTANCE * 4]; for (int dist = VIEW_DISTANCE; dist >= 0; dist -= CHUNK_SIZE_X) { // Configuration du radar. float sinus, cosinus; int echantillons; - if (dist > VIEW_DISTANCE * .375f) { + if (dist > VIEW_DISTANCE * .625f) { sinus = .01745240643; // sin(1 degré) cosinus = .99984769515; // cos(1 degré) echantillons = 90; @@ -289,7 +289,7 @@ void World::RenderWorld(int& rendercount, int& badhitcount, Player& player, Tran cosinus = .99965732497; echantillons = 60; } - else if (dist > VIEW_DISTANCE * .625f) { + else if (dist > VIEW_DISTANCE * .375f) { sinus = .0348994967; cosinus = .99939082701; echantillons = 45; @@ -313,7 +313,7 @@ void World::RenderWorld(int& rendercount, int& badhitcount, Player& player, Tran angle.Normalize(); cursor = pos - direct * CHUNK_SIZE_X * 2 + angle * dist; - if (cursor.y >= 128.f || cursor.y >= 0.f) cursor.y = 1; + if (cursor.y >= 128.f || cursor.y >= 0.f) cursor.y = CHUNK_SIZE_Y / 2.f; bool valide = true; @@ -321,24 +321,25 @@ void World::RenderWorld(int& rendercount, int& badhitcount, Player& player, Tran int chx, chy; ChunkAt(cursor)->GetPosition(chx, chy); for (int index = 0; index < rendercount; ++index) // Permet de vérifier seulement contre celles ajoutées dans la frame, et ne pas avoir à refaire l'array à chaque frame. - if (renderManifest[index] == Vector3i(chx, 0, chy)) { + if (renderManifest[index].x == chx && renderManifest[index].z == chy) { valide = false; ++badhitcount; } - if (valide) { - world.ApplyTranslation((chx - m_center[0]) * CHUNK_SIZE_X, 0, (chy - m_center[1]) * CHUNK_SIZE_Z); - world.Use(); - float dist = (pos - cursor).Length(); - float blend = ((float)VIEW_DISTANCE - dist * 2.f + 128.f) / (float)VIEW_DISTANCE; - glBlendColor(0.f, 0.f, 0.f, blend); - ChunkAt(cursor)->Render(); - world.ApplyTranslation(-(chx - m_center[0]) * CHUNK_SIZE_X, 0, -(chy - m_center[1]) * CHUNK_SIZE_Z); - renderManifest[++rendercount] = Vector3i(chx, 0, chy); - } + float ray = (pos - cursor).Length(); + if (valide) renderManifest[rendercount++] = Vector3f(chx, (VIEW_DISTANCE - ray * 2 + 128) / (float)VIEW_DISTANCE, chy); } } } + for (int index = 0; index < rendercount; ++index) { + int chx = (renderManifest[index].x - m_center[0]) * CHUNK_SIZE_X, chy = (renderManifest[index].z - m_center[1]) * CHUNK_SIZE_Z; + + world.ApplyTranslation(chx, 0, chy); + world.Use(); + glBlendColor(0.f, 0.f, 0.f, renderManifest[index].y); + ChunkAt(chx, 1, chy)->Render(); + world.ApplyTranslation(-chx, 0, -chy); + } shader.Disable(); };