diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-05-07 16:06:08 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-05-07 16:06:08 +0200 |
commit | f0eb6a7b101afba52f33c5286e15a862ee68c64e (patch) | |
tree | 7de0b92e167b25d5ffe0e4843f213e5ad108df4a /scene.cpp | |
parent | 6d5df2a42e09f4561f976c6f994471c1d5dba7ce (diff) |
Replace static heightmap with perlin noise using libnoise and noiseutils.
Diffstat (limited to 'scene.cpp')
-rw-r--r-- | scene.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -1,5 +1,6 @@ #include "scene.h" #include "video.h" +#include "terrain.h" #include <SDL_image.h> #include <boost/format.hpp> @@ -46,18 +47,10 @@ Scene::Scene() { soil_texture = load_texture("textures/zooboing-469-sand-modified.jpg"); marker_texture = load_texture("textures/cross.png"); - /* load heightmap */ - SDL_Surface *hm = IMG_Load("heightmap.png"); - float *heightmap = new float[hm->w * hm->h]; - for(int x = 0; x < hm->w; x++) { - for(int y = 0; y < hm->h; y++) { - Uint8 *p = (Uint8*)hm->pixels + y * hm->pitch + x * hm->format->BytesPerPixel; - heightmap[y*hm->w + x] = ((float)(*p) / 256) * 20; - } - } - int w = hm->w; - int h = hm->h; - SDL_FreeSurface(hm); + /* init quadtree */ + int w = 1025; + int h = 1025; + float *heightmap = Terrain::generate_heights(0, 0, w, h); qt = new Quadtree(w, h, heightmap); /* load font */ |