#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) { glBegin(GL_QUADS); // Front if(nodeManager.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); glTexCoord2f(1.0F, 1.0F); glVertex3f(x + 1.0F, y + .0F, z + .0F); glTexCoord2f(.0F, 1.0F); glVertex3f(x + .0F, y + .0F, z + .0F); } // Back if(nodeManager.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); 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); } // Right if(nodeManager.isAir(x + 1, y, z)) { glTexCoord2f(1.0F, .0F); glVertex3f(x + 1.0F, y + 1.0F, z + .0F); 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); glTexCoord2f(.0F, .0F); glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F); } // Left if(nodeManager.isAir(x - 1, y, z)) { glTexCoord2f(1.0F, .0F); glVertex3f(x + .0F, y + 1.0F, z + .0F); glTexCoord2f(1.0F, 1.0F); glVertex3f(x + .0F, y + .0F, z + .0F); glTexCoord2f(.0F, 1.0F); glVertex3f(x + .0F, y + .0F, z + 1.0F); glTexCoord2f(.0F, .0F); glVertex3f(x + .0F, y + 1.0F, z + 1.0F); } // Bottom if(nodeManager.getNodeAt(x, y - 1, z) == 0) { 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(nodeManager.getNodeAt(x, y + 1, z) == 0) { 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