diff --git a/XtreemNodes.depend b/XtreemNodes.depend index 7415824..9858aa3 100644 --- a/XtreemNodes.depend +++ b/XtreemNodes.depend @@ -1,5 +1,5 @@ # depslib dependency file v1.0 -1667158149 source:c:\development\xtreemminer\main.cpp +1667160902 source:c:\development\xtreemminer\main.cpp "Utilities.h" @@ -12,12 +12,12 @@ "FastNoiseLite.h" -1667158420 c:\development\xtreemminer\include\noderenderer.h +1667163770 c:\development\xtreemminer\include\noderenderer.h "Base.h" "MapBlock.h" -1667156676 c:\development\xtreemminer\include\mapblock.h +1667161818 c:\development\xtreemminer\include\mapblock.h "Base.h" diff --git a/include/MapBlock.h b/include/MapBlock.h index e54e505..ab14168 100644 --- a/include/MapBlock.h +++ b/include/MapBlock.h @@ -63,18 +63,18 @@ class BlockManager { //if(x < 16 && x >= 0 && z < 16 && z >= 0) //{ - if(x < 0 || z < 0) + if(x < 0 || y < 0 || z < 0) { return 0; } Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z); //printf("\n\nold x: %i, old z: %i", x, z); - //int localX = x - block.x * 16; - //int localZ = z - block.z * 16; + int localX = x - block.x * 16; + int localZ = z - block.z * 16; //printf("\nnew x: %i, new z: %i", x, z); - //return mapBlocks[block.x][block.z].mapBlock[256 * y + localZ * 16 + localX]; - return mapBlocks[block.x][block.z].getNodeAt(x, y, z); + return mapBlocks[block.x][block.z].mapBlock[256 * y + localZ * 16 + localX]; + //return mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16); } bool isAir(int x, int y, int z) diff --git a/include/NodeRenderer.h b/include/NodeRenderer.h index 11918da..235d02d 100644 --- a/include/NodeRenderer.h +++ b/include/NodeRenderer.h @@ -25,7 +25,7 @@ class NodeRenderer glBegin(GL_QUADS); // Front - if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16 - 1) == 0) + if(blockManager.isAir(x, y, z + 1)) { glTexCoord2f(.0F, .0F); glVertex3f(x + .0F, y + 1.0F, z + .0F); @@ -43,7 +43,7 @@ class NodeRenderer } // Back - if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16 + 1) == 0) + if(blockManager.isAir(x, y, z - 1)) { glTexCoord2f(.0F, .0F); @@ -62,7 +62,7 @@ class NodeRenderer } // Right - if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16 + 1, y, z - block.z * 16) == 0); + if(blockManager.isAir(x + 1, y, z)) { glTexCoord2f(1.0F, .0F); glVertex3f(x + 1.0F, y + 1.0F, z + .0F); @@ -80,7 +80,7 @@ class NodeRenderer } // Left - if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16 - 1, y, z - block.z * 16) == 0); + if(blockManager.isAir(x - 1, y, z)) { glTexCoord2f(1.0F, .0F); glVertex3f(x + .0F, y + 1.0F, z + .0F); @@ -98,8 +98,10 @@ class NodeRenderer } // Bottom - if(blockManager.getNodeAt(x, y - 1, z) == 0); + //printf("\n\nx: %i, y: %i, z: %i, VALUE: %s", x, y, z, blockManager.isAir(x, y - 1, z) ? "true" : "false"); + if(blockManager.isAir(x, y - 1, z)) { + //printf("\nWUT? x: %i, y: %i, z: %i, VALUE: %s", x, y, z, blockManager.isAir(x, y - 1, z) ? "true" : "false"); glTexCoord2f(.0F, .0F); glVertex3f(x + 1.0F, y + .0F, z + .0F); @@ -114,7 +116,7 @@ class NodeRenderer } // Top - /*if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y + 1, z - block.z * 16) == 0); + if(blockManager.isAir(x, y + 1, z)) { glTexCoord2f(.0F, .0F); glVertex3f(x + 1.0F, y + 1.0F, z + .0F); @@ -127,7 +129,7 @@ class NodeRenderer glTexCoord2f(.0F, 1.0F); glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F); - }*/ + } glEnd(); return 1; diff --git a/main.cpp b/main.cpp index 206417e..e6119fb 100644 --- a/main.cpp +++ b/main.cpp @@ -197,9 +197,9 @@ int main(int argc, char **argv) cellular.SetNoiseType(FastNoiseLite::NoiseType_Cellular); cellular.SetFrequency(.1F); - for(int bx = 0; bx < 16; bx++) + for(int bx = 0; bx < 1; bx++) { - for(int bz = 0; bz < 16; bz++) + for(int bz = 0; bz < 1; bz++) { for(int x = 0; x < 16; x++) { @@ -216,7 +216,7 @@ int main(int argc, char **argv) } } - + printf("\n0, 2, 0: %i", blockManager.isAir(0, 1, 0)); /*