Archived

This topic is now archived and is closed to further replies.

Terrain Generator Theory

This topic is 6113 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites