132 lines
3.6 KiB
C++
132 lines
3.6 KiB
C++
#ifndef NODERENDERER_H
|
|
#define NODERENDERER_H
|
|
#include "Base.h"
|
|
#include "MapBlock.h"
|
|
#include <GL/glut.h>
|
|
|
|
|
|
|
|
|
|
class NodeRenderer
|
|
{
|
|
public:
|
|
NodeRenderer()
|
|
{
|
|
|
|
}
|
|
|
|
virtual ~NodeRenderer()
|
|
{
|
|
|
|
}
|
|
|
|
renderNode(int x, int y, int z)
|
|
{
|
|
glBegin(GL_QUADS);
|
|
// Front
|
|
if(nodeManager.isAir(x, y, z - 1))
|
|
{
|
|
glColor3f(1.0F, 1.0F, 1.0F);
|
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
|
|
|
glColor3f(1.0F, 1.0F, 1.0F);
|
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
|
|
|
glColor3f(1.0F, 1.0F, 1.0F);
|
|
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
|
|
|
glColor3f(1.0F, 1.0F, 1.0F);
|
|
glVertex3f(x + .0F, y + .0F, z + .0F);
|
|
}
|
|
|
|
// Back
|
|
if(nodeManager.isAir(x, y, z + 1))
|
|
{
|
|
glColor3f(.0F, 1.0F, 1.0F);
|
|
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
|
|
|
glColor3f(.0F, 1.0F, 1.0F);
|
|
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
|
|
|
glColor3f(.0F, 1.0F, 1.0F);
|
|
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
|
|
|
glColor3f(.0F, 1.0F, 1.0F);
|
|
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
|
}
|
|
|
|
// Right
|
|
if(nodeManager.isAir(x + 1, y, z))
|
|
{
|
|
glColor3f(.0F, 1.0F, .0F);
|
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
|
|
|
glColor3f(.0F, 1.0F, .0F);
|
|
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
|
|
|
glColor3f(.0F, 1.0F, .0F);
|
|
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
|
|
|
glColor3f(.0F, 1.0F, .0F);
|
|
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
|
}
|
|
|
|
// Left
|
|
if(nodeManager.isAir(x - 1, y, z))
|
|
{
|
|
glColor3f(1.0F, .0F, .0F);
|
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
|
|
|
glColor3f(1.0F, .0F, .0F);
|
|
glVertex3f(x + .0F, y + .0F, z + .0F);
|
|
|
|
glColor3f(1.0F, .0F, .0F);
|
|
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
|
|
|
glColor3f(1.0F, .0F, .0F);
|
|
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
|
}
|
|
|
|
// Bottom
|
|
if(nodeManager.getNodeAt(x, y - 1, z) == 0)
|
|
{
|
|
glColor3f(1.0F, 1.0F, .0F);
|
|
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
|
|
|
glColor3f(1.0F, 1.0F, .0F);
|
|
glVertex3f(x + .0F, y + .0F, z + .0F);
|
|
|
|
glColor3f(1.0F, 1.0F, .0F);
|
|
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
|
|
|
glColor3f(1.0F, 1.0F, .0F);
|
|
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
|
}
|
|
|
|
// Top
|
|
if(nodeManager.getNodeAt(x, y + 1, z) == 0)
|
|
{
|
|
glColor3f(.0F, .0F, 1.0F);
|
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
|
|
|
glColor3f(.0F, .0F, 1.0F);
|
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
|
|
|
glColor3f(.0F, .0F, 1.0F);
|
|
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
|
|
|
glColor3f(.0F, .0F, 1.0F);
|
|
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
|
}
|
|
|
|
glEnd();
|
|
}
|
|
|
|
protected:
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
#endif
|