Still dealing with a very strange issue (Mind fixing it, Kacperks?)
This commit is contained in:
parent
4c76fd1144
commit
3aa203bac9
@ -1,5 +1,5 @@
|
|||||||
# depslib dependency file v1.0
|
# depslib dependency file v1.0
|
||||||
1667147634 source:c:\development\xtreemminer\main.cpp
|
1667158149 source:c:\development\xtreemminer\main.cpp
|
||||||
<stdlib.h>
|
<stdlib.h>
|
||||||
<GL/glut.h>
|
<GL/glut.h>
|
||||||
"Utilities.h"
|
"Utilities.h"
|
||||||
@ -12,14 +12,15 @@
|
|||||||
"FastNoiseLite.h"
|
"FastNoiseLite.h"
|
||||||
<random>
|
<random>
|
||||||
|
|
||||||
1667148817 c:\development\xtreemminer\include\noderenderer.h
|
1667158420 c:\development\xtreemminer\include\noderenderer.h
|
||||||
"Base.h"
|
"Base.h"
|
||||||
"MapBlock.h"
|
"MapBlock.h"
|
||||||
<GL/glut.h>
|
<GL/glut.h>
|
||||||
|
|
||||||
1667148643 c:\development\xtreemminer\include\mapblock.h
|
1667156676 c:\development\xtreemminer\include\mapblock.h
|
||||||
"Base.h"
|
"Base.h"
|
||||||
<math.h>
|
<math.h>
|
||||||
|
<cstdio>
|
||||||
|
|
||||||
1667069440 c:\development\xtreemminer\include\base.h
|
1667069440 c:\development\xtreemminer\include\base.h
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define MAPBLOCK_H
|
#define MAPBLOCK_H
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -18,6 +19,10 @@ class MapBlock
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getNodeAt(int x, int y, int z) // Deprecated; only used internally.
|
||||||
|
{
|
||||||
|
return x < 16 && z < 16 && x >= 0 && z >= 0 ? mapBlock[256 * y + z * 16 + x] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
void addNode(int id, int meta, int x, int y, int z)
|
void addNode(int id, int meta, int x, int y, int z)
|
||||||
{
|
{
|
||||||
@ -58,15 +63,18 @@ class BlockManager
|
|||||||
{
|
{
|
||||||
//if(x < 16 && x >= 0 && z < 16 && z >= 0)
|
//if(x < 16 && x >= 0 && z < 16 && z >= 0)
|
||||||
//{
|
//{
|
||||||
|
if(x < 0 || z < 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
|
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
|
||||||
return mapBlocks[block.x][block.z].mapBlock[256 * y + z * 16 + x];
|
//printf("\n\nold x: %i, old z: %i", x, z);
|
||||||
|
//int localX = x - block.x * 16;
|
||||||
|
//int localZ = z - block.z * 16;
|
||||||
// else
|
//printf("\nnew x: %i, new z: %i", x, z);
|
||||||
// {
|
//return mapBlocks[block.x][block.z].mapBlock[256 * y + localZ * 16 + localX];
|
||||||
//return mapBlocks[BlockUtilities::getBlockFromNodeCoordinates(x, z).x][BlockUtilities::getBlockFromNodeCoordinates(x, z).z];
|
return mapBlocks[block.x][block.z].getNodeAt(x, y, z);
|
||||||
//return 0;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAir(int x, int y, int z)
|
bool isAir(int x, int y, int z)
|
||||||
|
@ -19,13 +19,13 @@ class NodeRenderer
|
|||||||
|
|
||||||
int renderNode(int x, int y, int z)
|
int renderNode(int x, int y, int z)
|
||||||
{
|
{
|
||||||
//Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z); // The block the node at (x, y, z) is in
|
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z); // The block the node at (x, y, z) is in
|
||||||
|
|
||||||
glColor3f(1.0F, 1.0F, 1.0F);
|
glColor3f(1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
// Front
|
// Front
|
||||||
if(blockManager.getNodeAt(x, y, z - 1))
|
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16 - 1) == 0)
|
||||||
{
|
{
|
||||||
glTexCoord2f(.0F, .0F);
|
glTexCoord2f(.0F, .0F);
|
||||||
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
||||||
@ -42,11 +42,10 @@ class NodeRenderer
|
|||||||
glColor3f(1.0F, 1.0F, 1.0F);
|
glColor3f(1.0F, 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Back
|
// Back
|
||||||
if(blockManager.getNodeAt(x, y, z + 1))
|
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16 + 1) == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
glTexCoord2f(.0F, .0F);
|
glTexCoord2f(.0F, .0F);
|
||||||
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
||||||
|
|
||||||
@ -63,7 +62,7 @@ class NodeRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Right
|
// Right
|
||||||
if(blockManager.getNodeAt(x + 1, y, z));
|
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16 + 1, y, z - block.z * 16) == 0);
|
||||||
{
|
{
|
||||||
glTexCoord2f(1.0F, .0F);
|
glTexCoord2f(1.0F, .0F);
|
||||||
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
||||||
@ -80,10 +79,8 @@ class NodeRenderer
|
|||||||
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Left
|
// Left
|
||||||
if(blockManager.getNodeAt(x - 1, y, z));
|
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16 - 1, y, z - block.z * 16) == 0);
|
||||||
{
|
{
|
||||||
glTexCoord2f(1.0F, .0F);
|
glTexCoord2f(1.0F, .0F);
|
||||||
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
||||||
@ -101,7 +98,7 @@ class NodeRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bottom
|
// Bottom
|
||||||
if(blockManager.getNodeAt(x, y - 1, z));
|
if(blockManager.getNodeAt(x, y - 1, z) == 0);
|
||||||
{
|
{
|
||||||
glTexCoord2f(.0F, .0F);
|
glTexCoord2f(.0F, .0F);
|
||||||
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
||||||
@ -117,7 +114,7 @@ class NodeRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Top
|
// Top
|
||||||
if(blockManager.getNodeAt(x, y + 1, z));
|
/*if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y + 1, z - block.z * 16) == 0);
|
||||||
{
|
{
|
||||||
glTexCoord2f(.0F, .0F);
|
glTexCoord2f(.0F, .0F);
|
||||||
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
||||||
@ -130,7 +127,7 @@ class NodeRenderer
|
|||||||
|
|
||||||
glTexCoord2f(.0F, 1.0F);
|
glTexCoord2f(.0F, 1.0F);
|
||||||
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
return 1;
|
return 1;
|
||||||
|
24
main.cpp
24
main.cpp
@ -43,13 +43,13 @@ void display()
|
|||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
|
|
||||||
for(int x = 0; x < 128; x++)
|
for(int x = 0; x < 16; x++)
|
||||||
{
|
|
||||||
for(int z = 0; z < 128; z++)
|
|
||||||
{
|
{
|
||||||
for(int y = 0; y < 64; y++)
|
for(int y = 0; y < 64; y++)
|
||||||
{
|
{
|
||||||
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
|
for(int z = 0; z < 16; z++)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
// Math explanation for future reference:
|
// Math explanation for future reference:
|
||||||
// The if statement below checks if the node at the coordinate is greater than 0 (0 = air), the x and z coordinates
|
// The if statement below checks if the node at the coordinate is greater than 0 (0 = air), the x and z coordinates
|
||||||
@ -83,7 +83,7 @@ void reshape(int width, int height)
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective(20, width / (float) height, 5, 512.0F);
|
gluPerspective(30, width / (float) height, 5, 512.0F);
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
@ -184,7 +184,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
|
|
||||||
FastNoiseLite perlin, os, cellular;
|
FastNoiseLite perlin, os, cellular;
|
||||||
int seed = 1338;
|
int seed = 138;
|
||||||
perlin.SetSeed(seed);
|
perlin.SetSeed(seed);
|
||||||
perlin.SetNoiseType(FastNoiseLite::NoiseType_Perlin);
|
perlin.SetNoiseType(FastNoiseLite::NoiseType_Perlin);
|
||||||
perlin.SetFrequency(.01F);
|
perlin.SetFrequency(.01F);
|
||||||
@ -207,7 +207,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
float cX = (float)x + (16 * bx);
|
float cX = (float)x + (16 * bx);
|
||||||
float cZ = (float)z + (16 * bz);
|
float cZ = (float)z + (16 * bz);
|
||||||
for(int y = 0; y < 48 * abs(perlin.GetNoise(cX, cZ)) + (cellular.GetNoise(cX, cZ)) + 2; y++)
|
for(int y = 0; y < 48 * abs(perlin.GetNoise(cX, cZ)) + (cellular.GetNoise(cX, cZ)) + 3; y++)
|
||||||
{
|
{
|
||||||
blockManager.mapBlocks[bx][bz].addNode(y > 30 ? 1 : 2, 0, x, y, z);
|
blockManager.mapBlocks[bx][bz].addNode(y > 30 ? 1 : 2, 0, x, y, z);
|
||||||
}
|
}
|
||||||
@ -220,24 +220,24 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for(int x = 0; x < 32; x++)
|
for(int y = 0; y < 16; y++)
|
||||||
|
{
|
||||||
|
for(int x = 0; x < 16; x++)
|
||||||
{
|
{
|
||||||
for(int z = 0; z < 16; z++)
|
for(int z = 0; z < 16; z++)
|
||||||
{
|
|
||||||
for(int y = 0; y < 16; y++)
|
|
||||||
{
|
{
|
||||||
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
|
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
|
||||||
printf("x - (blockX * 16): %i | X: %i, Y: %i, Z: %i, blockX: %i, blockZ: %i nodeAt: %i\n", x - (block.x * 16), x, y, z, block.x, block.z, blockManager.mapBlocks[block.x][block.z].getNodeAt(x - (block.x * 16), y, z));
|
printf("\n|x: %i |y: %i | z: %i | id: %i", x, y, z, blockManager.getNodeAt(x, y, z));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
updateTimer(0);
|
updateTimer(0);
|
||||||
glutDisplayFunc(&display);
|
glutDisplayFunc(&display);
|
||||||
glutReshapeFunc(&reshape);
|
glutReshapeFunc(&reshape);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user