#ifndef NODERENDERER_H #define NODERENDERER_H #include "Base.h" #include "MapBlock.h" #include class NodeRenderer { public: NodeRenderer() { } virtual ~NodeRenderer() { } int renderNode(int x, int y, int z) { Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z); // The block the node at (x, y, z) is in glColor3f(1.0F, 1.0F, 1.0F); glBegin(GL_QUADS); // Front if(blockManager.isAir(x, y, z + 1)) { glTexCoord2f(.0F, .0F); glVertex3f(x + .0F, y + 1.0F, z + .0F); glTexCoord2f(1.0F, .0F); glVertex3f(x + 1.0F, y + 1.0F, z + .0F); glColor3f(.6F, .6F, .6F); // Bottom vertices glTexCoord2f(1.0F, 1.0F); glVertex3f(x + 1.0F, y + .0F, z + .0F); glTexCoord2f(.0F, 1.0F); glVertex3f(x + .0F, y + .0F, z + .0F); glColor3f(1.0F, 1.0F, 1.0F); } // Back if(blockManager.isAir(x, y, z - 1)) { glTexCoord2f(.0F, .0F); glVertex3f(x + .0F, y + 1.0F, z + 1.0F); glTexCoord2f(1.0F, .0F); glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F); glColor3f(.6F, .6F, .6F); glTexCoord2f(1.0F, 1.0F); glVertex3f(x + 1.0F, y + .0F, z + 1.0F); glTexCoord2f(.0F, 1.0F); glVertex3f(x + .0F, y + .0F, z + 1.0F); glColor3f(1.0F, 1.0F, 1.0F); } // Right if(blockManager.isAir(x + 1, y, z)) { glTexCoord2f(1.0F, .0F); glVertex3f(x + 1.0F, y + 1.0F, z + .0F); glColor3f(.6F, .6F, .6F); glTexCoord2f(1.0F, 1.0F); glVertex3f(x + 1.0F, y + .0F, z + .0F); glTexCoord2f(.0F, 1.0F); glVertex3f(x + 1.0F, y + .0F, z + 1.0F); glColor3f(1.0F, 1.0F, 1.0F); glTexCoord2f(.0F, .0F); glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F); } // Left if(blockManager.isAir(x - 1, y, z)) { glTexCoord2f(1.0F, .0F); glVertex3f(x + .0F, y + 1.0F, z + .0F); glColor3f(.6F, .6F, .6F); glTexCoord2f(1.0F, 1.0F); glVertex3f(x + .0F, y + .0F, z + .0F); glTexCoord2f(.0F, 1.0F); glVertex3f(x + .0F, y + .0F, z + 1.0F); glColor3f(1.0F, 1.0F, 1.0F); glTexCoord2f(.0F, .0F); glVertex3f(x + .0F, y + 1.0F, z + 1.0F); } // Bottom //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); glTexCoord2f(1.0F, .0F); glVertex3f(x + .0F, y + .0F, z + .0F); glTexCoord2f(1.0F, 1.0F); glVertex3f(x + .0F, y + .0F, z + 1.0F); glTexCoord2f(.0F, 1.0F); glVertex3f(x + 1.0F, y + .0F, z + 1.0F); } // Top if(blockManager.isAir(x, y + 1, z)) { glTexCoord2f(.0F, .0F); glVertex3f(x + 1.0F, y + 1.0F, z + .0F); glTexCoord2f(1.0F, .0F); glVertex3f(x + .0F, y + 1.0F, z + .0F); glTexCoord2f(1.0F, 1.0F); glVertex3f(x + .0F, y + 1.0F, z + 1.0F); glTexCoord2f(.0F, 1.0F); glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F); } glEnd(); return 1; } protected: private: }; #endif