From f0eb6a7b101afba52f33c5286e15a862ee68c64e Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 7 May 2011 16:06:08 +0200 Subject: Replace static heightmap with perlin noise using libnoise and noiseutils. --- scene.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'scene.cpp') diff --git a/scene.cpp b/scene.cpp index 6cb6cc7..28f4fcc 100644 --- a/scene.cpp +++ b/scene.cpp @@ -1,5 +1,6 @@ #include "scene.h" #include "video.h" +#include "terrain.h" #include #include @@ -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 */ -- cgit v1.2.3