Simplified the code for checking nodes and added simple shading
This commit is contained in:
31
main.cpp
31
main.cpp
@@ -55,7 +55,7 @@ void display()
|
||||
// The if statement below checks if the node at the coordinate is greater than 0 (0 = air), 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(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16) > 0)
|
||||
if(blockManager.getNodeAt(x, y, z) > 0)
|
||||
{
|
||||
textureHandler.getTextureForNode(x, y, z);
|
||||
renderer.renderNode(x, y, z);
|
||||
@@ -172,21 +172,30 @@ int main(int argc, char **argv)
|
||||
glutInitWindowSize(800, 600);
|
||||
glutCreateWindow("XtreemNodes Engine - By MCL Software and Cube Software");
|
||||
|
||||
glClearColor(.2, .7, .8 , 255);
|
||||
glClearColor(.4, .7, .8 , 255);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
/*glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_FRONT);
|
||||
glFrontFace(GL_CCW);*/
|
||||
//glEnable(GL_CULL_FACE);
|
||||
//glCullFace(GL_FRONT);
|
||||
//glFrontFace(GL_CCW);
|
||||
|
||||
// Load textures
|
||||
textureHandler.loadAllTextures();
|
||||
|
||||
|
||||
FastNoiseLite fnl;
|
||||
fnl.SetSeed(1337);
|
||||
fnl.SetNoiseType(FastNoiseLite::NoiseType_OpenSimplex2);
|
||||
fnl.SetFrequency(.01F);
|
||||
FastNoiseLite perlin, os, cellular;
|
||||
int seed = 1338;
|
||||
perlin.SetSeed(seed);
|
||||
perlin.SetNoiseType(FastNoiseLite::NoiseType_Perlin);
|
||||
perlin.SetFrequency(.01F);
|
||||
|
||||
os.SetSeed(seed);
|
||||
os.SetNoiseType(FastNoiseLite::NoiseType_OpenSimplex2);
|
||||
os.SetFrequency(.01F);
|
||||
|
||||
cellular.SetSeed(seed);
|
||||
cellular.SetNoiseType(FastNoiseLite::NoiseType_Cellular);
|
||||
cellular.SetFrequency(.1F);
|
||||
|
||||
for(int bx = 0; bx < 16; bx++)
|
||||
{
|
||||
@@ -196,7 +205,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++)
|
||||
float cX = (float)x + (16 * bx);
|
||||
float cZ = (float)z + (16 * bz);
|
||||
for(int y = 0; y < 48 * abs(perlin.GetNoise(cX, cZ)) + (cellular.GetNoise(cX, cZ)) + 2; y++)
|
||||
{
|
||||
blockManager.mapBlocks[bx][bz].addNode(y > 30 ? 1 : 2, 0, x, y, z);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user