Terrain Generator Theory

Started by
-1 comments, last by cooldaddyk 23 years, 1 month ago
Hey, About a week or two ago I was thinking about how to make a terrain generator. I couldn''t grasp the concept on how to do it. So I started searching for tuturials until I found one. When I was about to read it the idea hit me all of a sudden. So I closed the browser, disconnected and opened up my IDE. I quickly typed up the code that was in my head: (hmap is a class I made for loading and retriving pixels values) //terrain variables float terx=0.0,tery=0.0,terz=0.0; int imgx=0.0,imgy=0.0; for(imgy=1;imgy<=256;imgx++) { for(imgx=1;imgx<=256;imgy++) { //check to see if pixel on heightmap is equal to previous if(hmap.Pixel(imgx,imgy) = hmap.Pixel(imgx-1,imgy)) { //Add 1.5 to x coordinate terx+=1.5f //add vertex to polygon } else if(hmap.Pixel(imgx,imgy) < hmap.Pixel(imgx-1,imgy)) { terx+=1.5f tery+=1.5f //add vertex to polygon } else if(hmap.Pixel(imgx,imgy) > hmap.Pixel(imgx-1,imgy)) { terx+=1.5f tery-=1.5f //add to polygon } } } When I ran the code I got a decent looking terrain(it could be antialiased). This technique made have been made up already(it could be the one used today). I don''t know for sure. Oh well. Tell me what you think. email: platinum61@lycos.com

This topic is closed to new replies.

Advertisement