nuclear@1: #include "level.h" nuclear@1: nuclear@1: #include "opt.h" nuclear@1: nuclear@1: Level::Level() nuclear@1: { nuclear@1: terrain = 0; nuclear@1: } nuclear@1: nuclear@1: Level::~Level() nuclear@1: { nuclear@1: delete terrain; nuclear@1: } nuclear@1: nuclear@3: static float terrain_func(float x, float y, float z) nuclear@3: { nuclear@3: float nx = (x * 2.0 - 1.0) * 0.9; nuclear@3: float ny = (y * 2.0 - 1.0) * 0.9; nuclear@3: float valley = nx * nx + ny * ny; nuclear@3: nuclear@3: float s = opt.gen_noise_scale; nuclear@3: float noise = 0.2 * fbm2(x * s, y * s, 3) * (valley + 0.25); nuclear@3: float grad = 0.75 - z + noise + valley * 0.4; nuclear@3: nuclear@3: return grad; nuclear@3: } nuclear@3: nuclear@1: void Level::generate() nuclear@1: { nuclear@1: delete terrain; nuclear@1: nuclear@1: int xsz = opt.world_size[0]; nuclear@1: int ysz = opt.world_size[1]; nuclear@1: int zsz = opt.world_size[2]; nuclear@1: nuclear@1: terrain = new Volume(xsz, ysz, zsz); nuclear@1: nuclear@1: for(int i=0; iset_voxel(i, j, k, voxel); nuclear@1: } nuclear@1: } nuclear@1: } nuclear@1: } nuclear@1: nuclear@1: bool Level::load(const char *fname) nuclear@1: { nuclear@1: return false; nuclear@1: } nuclear@1: nuclear@1: bool Level::save(const char *fname) const nuclear@1: { nuclear@1: return false; nuclear@1: }