CMake build added. Basic OpenGL 3.3 Mesh Rendering

This commit is contained in:
2023-03-01 07:22:50 +01:00
parent 1215e7d8a5
commit 76c7e1808c
46 changed files with 960 additions and 912 deletions

View File

@@ -1,67 +0,0 @@
#include "MapBlock.h"
int mapBlock[65536];
MapBlock::MapBlock()
{
}
// TODO; Make this function work with global coordinates and move it to BlockManager
void MapBlock::addNode(int id, int meta, int x, int y, int z)
{
mapBlock[256 * y + z * 16 + x] = id;
}
MapBlock mapBlocks[16][16];
BlockManager::BlockManager()
{
}
int BlockManager::getNodeAt(int x, int y, int z)
{
// Math explanation for future reference:
// The x and z coordinates need to be have block.[AXIS] * 16 subtracted from them
// so that the coordinates passed to the function are local block coordinates instead
// of global node coordinates (e.g. 1, and not 17)
if(x < 0 || y < 0 || z < 0)
{
return 0;
}
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
int localX = x - block.x * 16;
int localZ = z - block.z * 16;
return mapBlocks[block.x][block.z].mapBlock[256 * y + localZ * 16 + localX];
}
bool BlockManager::isAir(int x, int y, int z)
{
return getNodeAt(x, y, z) == 0;
}
BlockUtilities::BlockUtilities()
{
}
Position2D BlockUtilities::getBlockFromNodeCoordinates(int x, int z)
{
Position2D pos2d;
pos2d.x = floor(x / 16);
pos2d.z = floor(z / 16);
return pos2d;
}