Initial commit

This commit is contained in:
2022-10-22 11:03:43 -04:00
commit 48bd114e4b
10 changed files with 8276 additions and 0 deletions

10
include/Base.h Normal file
View File

@@ -0,0 +1,10 @@
//#ifndef BASE
//#define BASE
//#include "NodeRenderer.h"
#include "MapBlock.h"
class NodeManager;
extern NodeManager nodeManager;
//#endif

66
include/MapBlock.h Normal file
View File

@@ -0,0 +1,66 @@
#ifndef MAPBLOCK_H
#define MAPBLOCK_H
#include <cstdio>
#include "Base.h"
class NodeManager
{
public:
NodeManager()
{
}
virtual ~NodeManager()
{
}
//8191
void printMapBlock()
{
for(int i = 0; i < 10536; i++)
{
printf("\n[%i] %i", i, mapBlock[i]);
}
}
void addNode(int id, int meta, int x, int y, int z)
{
mapBlock[256 * y + z * 16 + x] = id;
}
bool isAir(int x, int y, int z)
{
return getNodeAt(x, y, z) == 0;
}
int getNodeAt(int x, int y, int z)
{
return x < 16 && z < 16 && x >= 0 && z >= 0 ? mapBlock[256 * y + z * 16 + x] : 0;
}
protected:
private:
int mapBlock[65536];
};
class Block
{
public:
Block(int x, int z)
{
}
int getBlockFromNodeCoordinates(int x, int z)
{
}
};
#endif

131
include/NodeRenderer.h Normal file
View File

@@ -0,0 +1,131 @@
#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

6
include/TextureHandler.h Normal file
View File

@@ -0,0 +1,6 @@
#include <png.h>
#ifndef TEXTURE_HANDLER
#define TEXTURE_HANDLER
#endif

7898
include/stb_image.h Normal file

File diff suppressed because it is too large Load Diff