Browse Source

Moved headers to include and removed terrain gen

testing
= 3 years ago
parent
commit
6087d8a8cf

+ 1
- 1
CMakeLists.txt View File

@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 3.6)
project ("voxeltronik")
file (GLOB_RECURSE SOURCES "src/*.cpp")
include_directories("include")
include_directories("./include")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
add_executable(vtk ${SOURCES})

src/bitmap.h → include/bitmap.h View File


src/camera.h → include/camera.h View File


src/chunk.h → include/chunk.h View File


src/chunkrenderer.h → include/chunkrenderer.h View File


src/config.h → include/config.h View File


src/game.h → include/game.h View File


src/graphics/drawable.h → include/graphics/drawable.h View File


src/graphics/mesh.h → include/graphics/mesh.h View File


src/graphics/shader.h → include/graphics/shader.h View File


src/graphics/skybox.h → include/graphics/skybox.h View File

@@ -2,7 +2,7 @@

#include <GL/glew.h>
#include <GL/gl.h>
#include "../camera.h"
#include "camera.h"

namespace vtk {


src/inputhandler.h → include/inputhandler.h View File


src/loadShader.h → include/loadShader.h View File


src/mathfuncs.h → include/mathfuncs.h View File


src/mathplus.h → include/mathplus.h View File


src/nano_signal_slot.hpp → include/nano_signal_slot.hpp View File


src/scene.h → include/scene.h View File


src/terraingen.h → include/terraingen.h View File

@@ -22,8 +22,6 @@
#include <map>
#include <utility>

#include "customnoise/gradientnoise.h"
#include "customnoise/yturbulence.h"

namespace vtk {

@@ -40,9 +38,7 @@ public:
noise::module::Const const1Mod;
noise::module::Const const0Mod;
noise::module::Const constNeg1Mod;
YTurbulence terrainTurb;
noise::module::Perlin terrainShape;
GradientNoise gradientMod;

//variables (replace by config)
double terrainScale;

src/tilemap.h → include/tilemap.h View File


src/tileset.h → include/tileset.h View File


src/voxelinfo.h → include/voxelinfo.h View File


src/voxelmath.h → include/voxelmath.h View File


src/voxelutils.h → include/voxelutils.h View File


src/window.h → include/window.h View File


src/world.h → include/world.h View File


+ 0
- 47
src/customnoise/gradientnoise.cpp View File

@@ -1,47 +0,0 @@
/*
* =====================================================================================
*
* Filename: gradientnoise.cpp
*
* Description:
*
* Version: 1.0
* Created: 05/10/2014 03:47:54 PM
* Revision: none
* Compiler: gcc
*
* Author: YOUR NAME (),
* Organization:
*
* =====================================================================================
*/
#include "gradientnoise.h"

namespace vtk {

GradientNoise::GradientNoise() : Module(GetSourceModuleCount()){

}

int GradientNoise::GetSourceModuleCount() const {
return 0;
}

double GradientNoise::GetValue(double x, double y, double z) const {
//We don't need x and z, so we suppress the warnings about it
(void)x;
(void)z;

if (y <= stop0) return -1.0;
if (y >= stop1) return 1.0;

return ((y - stop0) / (stop1 - stop0)) * 2 - 1;
}

void GradientNoise::setStop(const int& index, const double& value) {
if (index == 0) stop0 = value;
else if (index == 1) stop1 = value;
}

}


+ 0
- 43
src/customnoise/gradientnoise.h View File

@@ -1,43 +0,0 @@
/*
* =====================================================================================
*
* Filename: gradientnoise.h
*
* Description: Produces a vertical gradient
*
* Version: 1.0
* Created: 05/10/2014 03:42:45 PM
* Revision: none
* Compiler: gcc
*
* Author: YOUR NAME (),
* Organization:
*
* =====================================================================================
*/

#pragma once

#include <noise/noise.h>


//TODO: Add support for more than 2 stops

namespace vtk {

class GradientNoise : public noise::module::Module {
public:
GradientNoise();

virtual int GetSourceModuleCount() const;
virtual double GetValue(double x, double y, double z) const;

void setStop(const int& index, const double& value);

protected:
double stop0;
double stop1;
};


}

+ 0
- 40
src/customnoise/yturbulence.cpp View File

@@ -1,40 +0,0 @@
/*
* =====================================================================================
*
* Filename: yturbulence.cpp
*
* Description:
*
* Version: 1.0
* Created: 05/10/2014 06:17:38 PM
* Revision: none
* Compiler: gcc
*
* Author: YOUR NAME (),
* Organization:
*
* =====================================================================================
*/
#include "yturbulence.h"

namespace vtk {
YTurbulence::YTurbulence() : Module(GetSourceModuleCount()){

}

int YTurbulence::GetSourceModuleCount() const {
return 1;
}

double YTurbulence::GetValue(double x, double y, double z) const {
double xOff, yOff, zOff;
xOff = x + (12414.0 / 65536.0);
yOff = y + (65124.0 / 65536.0);
zOff = z + (31337.0 / 65536.0);

double distortion = y + (yNoise.GetValue(xOff, yOff, zOff) * power);

return m_pSourceModule[0]->GetValue(x, distortion, z);
}

}

+ 0
- 43
src/customnoise/yturbulence.h View File

@@ -1,43 +0,0 @@
/*
* =====================================================================================
*
* Filename: yturbulence.h
*
* Description: Y axis turbulence using perlin,
* Basically just normal turbulence, but only on Y.
*
* Version: 1.0
* Created: 05/10/2014 06:11:09 PM
* Revision: none
* Compiler: gcc
*
* Author: YOUR NAME (),
* Organization:
*
* =====================================================================================
*/

#pragma once

#include <noise/noise.h>


//TODO: Add support for more than 2 stops

namespace vtk {

class YTurbulence : public noise::module::Module {
public:
YTurbulence();

virtual int GetSourceModuleCount() const;
virtual double GetValue(double x, double y, double z) const;

noise::module::Perlin yNoise;
double power;
protected:

};


}

+ 2
- 2
src/graphics/skybox.cpp View File

@@ -2,9 +2,9 @@
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/transform.hpp>

#include "../loadShader.h"
#include "loadShader.h"

#include "skybox.h"
#include "graphics/skybox.h"

namespace vtk {


+ 7
- 7
src/scenes/testscene.cpp View File

@@ -16,11 +16,11 @@
* =====================================================================================
*/
#include "testscene.h"
#include "../loadShader.h"
#include "../game.h"
#include "../tileset.h"
#include "../world.h"
#include "../mathplus.h"
#include "loadShader.h"
#include "game.h"
#include "tileset.h"
#include "world.h"
#include "mathplus.h"


#include <GL/glew.h>
@@ -124,9 +124,9 @@ void TestScene::init() {
std::cout << std::endl;

int chunkCount = 1;
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
for (int k = 0; k < 10; k++) {
for (int k = 0; k < 30; k++) {
std::cout << "\rGenerating chunks (" << chunkCount << "/" << 8*8*8 << ")" << std::flush;
world.generateChunk(i,j,k);
chunkCount++;

+ 5
- 5
src/scenes/testscene.h View File

@@ -19,11 +19,11 @@

#pragma once

#include "../scene.h"
#include "../camera.h"
#include "../inputhandler.h"
#include "../world.h"
#include "../graphics/skybox.h"
#include "scene.h"
#include "camera.h"
#include "inputhandler.h"
#include "world.h"
#include "graphics/skybox.h"


#include <SDL2/SDL.h>

+ 2
- 19
src/terraingen.cpp View File

@@ -27,25 +27,6 @@
namespace vtk {

TerrainGen::TerrainGen() {
const1Mod.SetConstValue(1.0);
const0Mod.SetConstValue(0.0);
constNeg1Mod.SetConstValue(-1.0);

gradientMod.setStop(0, 0.0);
gradientMod.setStop(1, 1.0);

terrainTurb.SetSourceModule(0, gradientMod);
terrainTurb.power = .3;
terrainTurb.yNoise.SetOctaveCount(3);
terrainTurb.yNoise.SetFrequency(1.5);
terrainTurb.yNoise.SetSeed(time(0));

selectorMod.SetControlModule(terrainTurb);
selectorMod.SetSourceModule(0, constNeg1Mod);
selectorMod.SetSourceModule(1, const1Mod);
selectorMod.SetBounds(0.0, 1000.0);

terrainScale = 1.0 / 128.0;
}

void TerrainGen::generateChunk(Chunk* chunk) {
@@ -53,6 +34,7 @@ void TerrainGen::generateChunk(Chunk* chunk) {
for (int i = 0; i < 16; i++) { //x
for (int j = 0; j < 16; j++) { //y
for (int k = 0; k < 16; k++) { //z
/*
glm::dvec3 pos((double)(chunk->chunkPos.x * 16 + i) * terrainScale,
(double)(chunk->chunkPos.y * 16 + j) * terrainScale,
(double)(chunk->chunkPos.z * 16 + k) * terrainScale);
@@ -63,6 +45,7 @@ void TerrainGen::generateChunk(Chunk* chunk) {
chunk->setVoxelType(i,j,k,1);
}
}
*/
}
}
}

+ 1
- 1
todo.txt View File

@@ -1,7 +1,7 @@
REFACTOR:
Make real scene graph
Convert to smart pointers
Doxygen docs and comment source
Document what I've got


Input handling

Loading…
Cancel
Save