Compare commits

..

No commits in common. "1d1aad04cf34d8df4ac5ba5d6973ae532f5a9b4b" and "1965b97c197f7380225b124619324b97e38c2547" have entirely different histories.

7 changed files with 48 additions and 46 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
XtreemMiner.cbp
XtreemMiner.depend
XtreemMiner.layout
bin
obj

View File

@ -1,5 +1,5 @@
# depslib dependency file v1.0
1667141044 source:c:\development\xtreemminer\main.cpp
1667085219 source:c:\development\xtreemminer\main.cpp
<stdlib.h>
<GL/glut.h>
"Utilities.h"
@ -12,12 +12,12 @@
"FastNoiseLite.h"
<random>
1667140765 c:\development\xtreemminer\include\noderenderer.h
1667067326 c:\development\xtreemminer\include\noderenderer.h
"Base.h"
"MapBlock.h"
<GL/glut.h>
1667141085 c:\development\xtreemminer\include\mapblock.h
1667014762 c:\development\xtreemminer\include\mapblock.h
"Base.h"
<math.h>
@ -27,7 +27,7 @@
"MapBlock.h"
"Base.h"
1667096344 c:\development\xtreemminer\include\texturehandler.h
1667088753 c:\development\xtreemminer\include\texturehandler.h
"stb_image.h"
"Base.h"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 877 B

After

Width:  |  Height:  |  Size: 744 B

View File

@ -7,18 +7,22 @@
class MapBlock
class NodeManager
{
public:
int blockX;
int blockZ;
MapBlock()
NodeManager()
{
}
virtual ~NodeManager()
{
}
void addNode(int id, int meta, int x, int y, int z)
{
@ -32,7 +36,7 @@ class MapBlock
int getNodeAt(int x, int y, int z)
{
return x < 16 && z < 16 && x >= 0 && z >= 0 ? mapBlock[256 * y + z * 16 + x] : 1;
return x < 16 && z < 16 && x >= 0 && z >= 0 ? mapBlock[256 * y + z * 16 + x] : 0;
}
protected:
@ -44,7 +48,7 @@ class MapBlock
class BlockManager
{
public:
MapBlock mapBlocks[16][16]; // 8 x 8 blocks
NodeManager mapBlocks[8][8]; // 8 x 8 blocks
BlockManager()
{

View File

@ -21,7 +21,6 @@ class NodeRenderer
{
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
@ -36,13 +35,10 @@ class NodeRenderer
glTexCoord2f(1.0F, 1.0F);
glVertex3f(x + 1.0F, y + .0F, z + .0F);
//glColor3f(.0F, .0F, .8F);
glTexCoord2f(.0F, 1.0F);
glVertex3f(x + .0F, y + .0F, z + .0F);
}
glColor3f(1.0F, 1.0F, 1.0F);
// Back
if(blockManager.mapBlocks[block.x][block.z].isAir(x - block.x * 16, y, z - block.z * 16 + 1))
{

View File

@ -39,7 +39,7 @@ class TextureHandler
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, imageData);
imageData1 = loadTexture("data/img/oak.png");
imageData1 = loadTexture("data/img/iron.png");
glGenTextures(1, &textures1);
glBindTexture(GL_TEXTURE_2D, textures1);
@ -52,16 +52,17 @@ class TextureHandler
void getTextureForNode(int x, int y, int z)
{
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16) == 1)
{
glBindTexture(GL_TEXTURE_2D, textures);
}
else if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16) == 2)
{
glBindTexture(GL_TEXTURE_2D, textures1);
}
//if(nodeManager.getNodeAt(x, y, z) == 1)
//{
glBindTexture(GL_TEXTURE_2D, textures);
//}
//else if(nodeManager.getNodeAt(x, y, z) == 2)
//{
//glBindTexture(GL_TEXTURE_2D, textures1);
//}
}

View File

@ -14,13 +14,14 @@
NodeRenderer renderer;
//BlockManager blockManager;
NodeManager nodeManager;
NodeManager nodeManager1;
BlockManager blockManager;
TextureHandler textureHandler;
GLfloat playerX = 0;
GLfloat playerY = -30;
GLfloat playerZ = -100;
GLfloat playerY = 30;
GLfloat playerZ = 100;
GLfloat playerRotX = 0;
GLfloat playerRotY = 0;
@ -31,13 +32,12 @@ void display()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-playerX, -playerY, -playerZ);
glRotatef(playerRotX, 1.0F, .0F, .0F);
glRotatef(playerRotY, .0F, 1.0F, .0F);
glTranslatef(playerX, playerY, playerZ);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glBegin(GL_QUADS);
@ -73,7 +73,7 @@ void display()
const sf::Window& window = nullptr;
sf::Vector2i mouseDelta = sf::Mouse::getPosition(window) - lastMousePos;
lastMousePos = sf::Mouse::getPosition(window);*/
//glutPostRedisplay();
glutPostRedisplay();
}
@ -90,10 +90,9 @@ void reshape(int width, int height)
glutPostRedisplay();
}
void updateTimer(int time)
void updateTimer()
{
glutPostRedisplay();
glutTimerFunc(30, &updateTimer, 0);
//glutTimerFunc(30, &updateTimer, 0);
}
void KeyboardFunc(unsigned char key, int x, int y)
@ -110,22 +109,24 @@ void KeyboardFunc(unsigned char key, int x, int y)
if(key == 'w')
{
playerZ += .8;
playerX += .8;
}
if(key == 's')
{
playerZ -= .8;
playerX -= sin(Utilities::degToRad(playerRotY));
playerY += sin(Utilities::degToRad(playerRotX));
playerZ += cos(Utilities::degToRad(playerRotY));
}
if(key == 'q')
{
playerY += .8F;
playerY += .1F;
}
if(key == 'e')
{
playerY -= .8F;
playerY -= .1F;
}
if(key == 't')
@ -174,10 +175,7 @@ int main(int argc, char **argv)
glClearColor(.2, .7, .8 , 255);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
/*glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glFrontFace(GL_CCW);*/
// Load textures
textureHandler.loadAllTextures();
@ -185,12 +183,12 @@ int main(int argc, char **argv)
FastNoiseLite fnl;
fnl.SetSeed(1337);
fnl.SetNoiseType(FastNoiseLite::NoiseType_OpenSimplex2);
fnl.SetNoiseType(FastNoiseLite::NoiseType_Value);
fnl.SetFrequency(.01F);
for(int bx = 0; bx < 16; bx++)
for(int bx = 0; bx < 8; bx++)
{
for(int bz = 0; bz < 16; bz++)
for(int bz = 0; bz < 8; bz++)
{
for(int x = 0; x < 16; x++)
{
@ -198,7 +196,7 @@ int main(int argc, char **argv)
{
for(int y = 0; y < 48 * abs(fnl.GetNoise((float)x + (16 * bx), (float)z + (16 * bz))) + 2; y++)
{
blockManager.mapBlocks[bx][bz].addNode(y > 30 ? 1 : 2, 0, x, y, z);
blockManager.mapBlocks[bx][bz].addNode(1, 0, x, y, z);
}
}
}
@ -227,7 +225,7 @@ int main(int argc, char **argv)
updateTimer(0);
updateTimer();
glutDisplayFunc(&display);
glutReshapeFunc(&reshape);
glutKeyboardFunc(&KeyboardFunc);