Compare commits

..

No commits in common. "171c890aa45f3cd12170dd477a6856db95ef2fb5" and "8365b148d06e9f3906ab2ff01782983057134c6d" have entirely different histories.

6 changed files with 18 additions and 2648 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 423 B

After

Width:  |  Height:  |  Size: 778 B

View File

@ -11,6 +11,7 @@ extern NodeManager nodeManager;
extern BlockManager blockManager;
struct Position2D
{
int x;

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@ class TextureHandler
void loadAllTextures()
{
int textureIndex = 0;
imageData = loadTexture("data/img/grass.png");
imageData = loadTexture("data/img/gold.png");
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

View File

@ -1,24 +0,0 @@
#ifndef UTILITIES
#define UTILITIES
class Utilities
{
public:
Utilities()
{
}
static float degToRad(int degrees)
{
return 3.14 / 180 * degrees; // Only the first three digits of pi
}
protected:
private:
};
#endif

View File

@ -1,13 +1,11 @@
#include <stdlib.h>
#include <GL/glut.h>
#include "Utilities.h"
#include "MapBlock.h"
#include "Base.h"
#include "NodeRenderer.h"
#include "TextureHandler.h"
#include <math.h>
#include <cstdio>
#include "FastNoiseLite.h"
#include <random>
//#include <SFML/System.hpp>
//#include <SFML/Window.hpp>
@ -20,10 +18,9 @@ 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;
@ -32,10 +29,9 @@ 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);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glTranslatef(playerX, playerY, playerZ);
glRotatef(playerRotX, .0F, 1.0F, .0F);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
@ -43,11 +39,11 @@ void display()
glBegin(GL_QUADS);
for(int x = 0; x < 128; x++)
for(int x = 0; x < 64; x++)
{
for(int z = 0; z < 128; z++)
for(int z = 0; z < 64; z++)
{
for(int y = 0; y < 64; y++)
for(int y = 0; y < 256; y++)
{
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
@ -73,8 +69,8 @@ void display()
const sf::Window& window = nullptr;
sf::Vector2i mouseDelta = sf::Mouse::getPosition(window) - lastMousePos;
lastMousePos = sf::Mouse::getPosition(window);*/
glutPostRedisplay();
glutPostRedisplay();
}
@ -83,7 +79,7 @@ void reshape(int width, int height)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(20, width / (float) height, 5, 512.0F);
gluPerspective(20, width / (float) height, 5, 150);
glViewport(0, 0, width, height);
glMatrixMode(GL_MODELVIEW);
@ -109,14 +105,12 @@ void KeyboardFunc(unsigned char key, int x, int y)
if(key == 'w')
{
playerX += .8;
playerZ += .8F;
}
if(key == 's')
{
playerX -= sin(Utilities::degToRad(playerRotY));
playerY += sin(Utilities::degToRad(playerRotX));
playerZ += cos(Utilities::degToRad(playerRotY));
playerZ -= .8F;
}
if(key == 'q')
@ -129,24 +123,14 @@ void KeyboardFunc(unsigned char key, int x, int y)
playerY -= .1F;
}
if(key == 't')
if(key == 'f')
{
playerRotX -= .8F;
}
if(key == 'g')
{
playerRotX += .8F;
}
if(key == 'f')
{
playerRotY -= .8F;
}
if(key == 'h')
{
playerRotY += .8F;
playerRotX += .8F;
}
@ -181,10 +165,6 @@ int main(int argc, char **argv)
textureHandler.loadAllTextures();
FastNoiseLite fnl;
fnl.SetSeed(1337);
fnl.SetNoiseType(FastNoiseLite::NoiseType_Value);
fnl.SetFrequency(.01F);
for(int bx = 0; bx < 8; bx++)
{
@ -194,10 +174,9 @@ int main(int argc, char **argv)
{
for(int z = 0; z < 16; z++)
{
for(int y = 0; y < 48 * abs(fnl.GetNoise((float)x + (16 * bx), (float)z + (16 * bz))) + 2; y++)
for(int y = 0; y < 16; y++)
{
blockManager.mapBlocks[bx][bz].addNode(1, 0, x, y, z);
//printf("\nx: %i, z: %i", x + (16 * bx), z + (16 * bz));
//printf("\nGet node at: %i\n Is air: %i", nodeManager.getNodeAt(x, y + 1, z) == 0, nodeManager.isAir(x, y + 1, z));
}
}