Smoothing Terrains???

Blitz3D Forums/Blitz3D Programming/Smoothing Terrains???

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hey Guys...

This is a code sample that I got from the CSP Terrain editor
But when I use it... It just flattens my terrains as soon as I press the corresponding key that activates this code?!

Here's the code:

Dim feld#(140,140)
weich#=100.0


If KeyDown(31)=True
If smtogg=0
 For j=0 To 128
  For i=0 To 128
 w#=0
  wold#=feld#(i,j)
   For j2=0 To 2
    For i2=0 To 2
     w#=w#+feld#(i+i2,j+j2)
    Next
   Next
   w#=((wold#*weich#)+w#)/(weich#+9)
   ModifyTerrain terrain,(i),(j),w#
   feld#(i,j)=w#
  Next
 Next
 smtogg=1
Else
 For j=128 To 2 Step -1
  For i=128 To 2 Step -1
  w#=0
  wold#=feld#(i,j)
   For j2=2 To 0 Step -1
    For i2=2 To 0 Step -1
     w#=w#+feld#(i-i2,j-j2)
    Next
   Next
   w#=((wold#*weich#)+w#)/(weich#+9)
   ModifyTerrain terrain,(i),(j),w#
   feld#(i,j)=w#
  Next
 Next
 smtogg=0
EndIf
EndIf


Still trying to work with this to get it to work.. But any suggestions on the proper direction I should go would be greatly appreciated very much so!

Thank's Guys in advance!