Suppression du plancher, plaçage des chunks, et remixage de la trame

This commit is contained in:
Marc-Eric Martel 2021-11-02 12:07:56 -04:00
parent 96ea7614f9
commit eee251dabf
3 changed files with 6 additions and 22 deletions

View File

@ -10,10 +10,9 @@
#include <GL/glew.h> #include <GL/glew.h>
#include <gl/GL.h> #include <gl/GL.h>
#include <gl/GLU.h> #include <gl/GLU.h>
#endif #endif
#define VIEW_DISTANCE 32 #define VIEW_DISTANCE 64
#define CHUNK_SIZE_X 16 #define CHUNK_SIZE_X 16
#define CHUNK_SIZE_Y 128 #define CHUNK_SIZE_Y 128
#define CHUNK_SIZE_Z 16 #define CHUNK_SIZE_Z 16
@ -21,7 +20,6 @@
typedef uint8_t BlockType; typedef uint8_t BlockType;
enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_LAST }; enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_LAST };
#define TEXTURE_PATH "../SQCSim2021/media/textures/" #define TEXTURE_PATH "../SQCSim2021/media/textures/"
#define SHADER_PATH "../SQCSim2021/media/shaders/" #define SHADER_PATH "../SQCSim2021/media/shaders/"
#define AUDIO_PATH "../SQCSim2021/media/audio/" #define AUDIO_PATH "../SQCSim2021/media/audio/"

View File

@ -203,35 +203,21 @@ void Engine::Render(float elapsedTime) {
glDisable(GL_LIGHT0); glDisable(GL_LIGHT0);
m_skybox.Render(skybox); m_skybox.Render(skybox);
// Plancher
// Les vertex doivent etre affiches dans le sens anti-horaire (CCW)
// Chunks
all.Use(); all.Use();
glEnable(GL_LIGHT0); glEnable(GL_LIGHT0);
m_shader01.Use(); m_shader01.Use();
m_textureFloor.Bind();
float nbRep = 10.f;
glBegin(GL_QUADS);
glNormal3f(0, 1, 0); // Normal vector
glTexCoord2f(0, 0);
glVertex3f(-100.f, -2.f, 100.f);
glTexCoord2f(nbRep, 0);
glVertex3f(100.f, -2.f, 100.f);
glTexCoord2f(nbRep, nbRep);
glVertex3f(100.f, -2.f, -100.f);
glTexCoord2f(0, nbRep);
glVertex3f(-100.f, -2.f, -100.f);
glEnd();
// Chunks
m_textureAtlas.Bind(); m_textureAtlas.Bind();
for (int chx = 0; chx < VIEW_DISTANCE; chx++) for (int chx = 0; chx < VIEW_DISTANCE; chx++)
for (int chy = 0; chy < VIEW_DISTANCE; chy++) { for (int chy = 0; chy < VIEW_DISTANCE; chy++) {
all.ApplyTranslation(chx * CHUNK_SIZE_X, 0, chy * CHUNK_SIZE_Z); all.ApplyTranslation(chx * CHUNK_SIZE_X - (VIEW_DISTANCE * CHUNK_SIZE_X / 2), -(CHUNK_SIZE_Y / 2), chy * CHUNK_SIZE_Z - (VIEW_DISTANCE * CHUNK_SIZE_Z / 2));
all.Use(); all.Use();
if (m_chunks.Get(chx, chy)->IsDirty()) if (m_chunks.Get(chx, chy)->IsDirty())
m_chunks.Get(chx, chy)->Update(m_blockinfo); m_chunks.Get(chx, chy)->Update(m_blockinfo);
m_chunks.Get(chx, chy)->Render(); m_chunks.Get(chx, chy)->Render();
all.ApplyTranslation(-(chx * CHUNK_SIZE_X), 0, -(chy * CHUNK_SIZE_Z)); all.ApplyTranslation(-(chx * CHUNK_SIZE_X - (VIEW_DISTANCE * CHUNK_SIZE_X / 2)), CHUNK_SIZE_Y / 2, -(chy * CHUNK_SIZE_Z - (VIEW_DISTANCE * CHUNK_SIZE_Z / 2)));
} }
m_shader01.Disable(); m_shader01.Disable();

Binary file not shown.