Jump to content
  • Advertisement
Sign in to follow this  
suliman

how to "smooth out a line"?

This topic is 4351 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

Hi I have a terrain drawn from the side (like cannongames/worms) defined by a set of heights (simple floats) like this 20 30 40 30 20 Everything below this points is filled (i use quads). This would be a small hill. Any good way to smooth such a "line" out, making it less spiky? Like a math-thing going through them and sort of even them out? Any good ideas? Thanks Suli

Share this post


Link to post
Share on other sites
Advertisement
Median filtering should do the trick. It's used in image processing to smooth and remove noise (any really sharp spikes could be considered noise).

Share this post


Link to post
Share on other sites
Thanks, checked it up.

This might be a primitive way to do it, but this works great for my simple architecture. Just the average of the surroundings. Nice smooth, rolling hills.

//smooth
if(ppp->keyClick(HGEK_S))
for(int ii=0;ii<MAPSIZE;ii++){

int count=0;
float p=0;
for(int iii=ii-3;iii<ii+3;iii++){
if(within(iii,0,MAPSIZE)){
count++;
p+=mmm.terrainNode[iii];
}
}
if(count)
mmm.terrainNode[ii]=p/(float)count;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!