Octothorpe is right ... not quite a paint program .. more procedural. Here's the sourse ... very messy but did it's job .... I used the red color for heightmap, green for object type and blue for ground type ...
Graphics3D 800,600,16,3
Global Camera = CreateCamera()
Const size = 256
Global maxheight=0
Type TerrainType
Field LandIndex
Field ObjectIndex
Field Height#
Field r,g,b
End Type
Dim Terrain.TerrainType( size-1, size-1 )
TERRAINinit()
TERRAINcreate( 427, 300 , 200, "TestMap5.bmp" )
;TERRAINload( "TestMap3.bmp" )
;===========================
;===========================
;===========================
Function TERRAINinit()
For z = 0 To size -1
For x =0 To size -1
terrain( x, z ) = New TerrainType
terrain(x,z)\landindex = 0
terrain(x,z)\objectindex = 0
terrain(x,z)\height = 0
Next
Next
End Function
;===========================
;===========================
;===========================
Function TERRAINload( file$ )
map = LoadImage( file$ )
SetBuffer ImageBuffer( map )
;get heights
For z =0 To size -1
For x =0 To size -1
GetColor x, z
terrain(x,z)\Height = ColorRed()
terrain(x,z)\Landindex = Floor( ColorBlue() / 50 )
terrain(x,z)\ObjectIndex = Floor( ColorGreen()/25)
Next
Next
;color terrain
For z = 0 To size -1
For x =0 To size -1
GetColor x, z
LandIndex# = Floor( ColorBlue() / 50.0 )
ObjectIndex# = Floor( ColorGreen() / 25.0 )
t.TerrainType = Terrain( x, z )
th#=GetHeight( x+.5 , z+.5 )
Select LandIndex
Case 0
t\r=60+Rand(40)
t\g=60+Rand(40)
t\b=200+Rand(40)
Case 1
t\r=th *10 + 30 + Rand(30)
t\g=th *10 + 30+ Rand(30)
t\b=200-th *10+Rand(40)
Case 2, 3
t\r = th+Rand(60)
t\g = limit( th+60+Rand(60), 0, 255 )
t\b = th+Rand(60)
If th > 64
t\r = limit( th+ Rand(80), 0, 255)
t\g = limit( th+ 60 + Rand (60),0,255 )
t\b = limit( th + Rand(80),0 , 255)
EndIf
Case 4
detail = ( ( z>125 And z< 131 ) And ( x = 125 Or x = 129) ) Or ( x>125 And x<129 And z=128 )
col= ( detail * 155 ) + ( ( Not detail ) * Rand(100) ) + 100
t\r=col
t\g=col
t\b=col
End Select
Next
Next
FreeImage map
test = CreateImage ( size, size )
SetBuffer ImageBuffer(test)
For z = 0 To size-1
For x =0 To size -1
t.terraintype = terrain( x, z )
Color t\r, t\g, t\b
Plot x, z
Next
Next
SetBuffer BackBuffer()
heightmap = CreateImage( size, size )
SetBuffer ImageBuffer( heightmap )
Color 0,0,0:Rect 0,0,size,size,1
For z =0 To size -1
For x =0 To size -1
red = terrain(x,z)\height
Color red,0,0
Plot x,z
Next
Next
objectmap = CreateImage( size, size )
SetBuffer ImageBuffer( objectmap )
Color 0,0,0:Rect 0,0,size,size,1
For z =0 To size -1
For x =0 To size -1
green = terrain(x,z)\objectindex * 25
If green > 0
Color green,green,green
Plot x,z
EndIf
Next
Next
landmap = CreateImage( size, size )
SetBuffer ImageBuffer( landmap )
Color 0,0,0:Rect 0,0,size,size,1
For z =0 To size -1
For x =0 To size -1
blue = terrain(x,z)\landindex * 50
Color 0,0,blue
Plot x,z
Next
Next
SetBuffer BackBuffer()
DrawImage test,0,0
DrawImage heightmap,400,0
DrawImage landmap,0,300
DrawImage objectmap,400,300
Flip
MouseWait
End Function
;===========================
;===========================
;===========================
Function TERRAINcreate( Seed , Passes , Rocks, file$ )
SeedRnd Seed
;do heights
For Parts =1 To Passes
StartX = Rand(0,size)
StartZ = Rand(0,size)
SlopeType = Rand(0,1)
If Parts > ( Passes - Rocks )
IsARock = 5
StartY# = Rnd( 4, 8 )
Radius# = Rand( 4,8 )
Else
IsARock = 0
StartY# = Rnd(4,32)
Radius# = Rand(4,32)
EndIf
For z=-radius To radius
For x=-radius To radius
Distance# = Sqr( x*x + z*z )
If Distance < Radius
If SlopeType = 0 py#=Cos( Distance / Radius * 90) * StartY * 2.0
If SlopeType = 1 py#=( 1.0 - Sin( ( Distance / Radius ) *90 ) ) * StartY *3.0
px = WRAP( StartX + X , Size)
pz = WRAP( StartZ + Z, Size)
nh# = LIMIT( terrain( px, pz)\height + py , 0, 255 )
Terrain( px , pz )\height = nh
Terrain( px,pz)\LandIndex = IsARock
EndIf
Next
Next
Next
;Colour Landscape
For z = size-1 To 0 Step -1
For x = 0 To size-1
th#=GetHeight( x+.5 , z+.5 )
If terrain( x, z )\LandIndex = 0
;beach
If th < 13 terrain(x,z)\LandIndex = 1
;water
If th < 3 terrain(x,z)\LandIndex = 0
;land
If th > 12 terrain(x,z)\LandIndex = 2 + ( th > 16 )
EndIf
Next
Next
;Color Landing Pad
For z=-5 To 4
For x=-5 To 4
col=Rnd(100)+100
xp=wrap(size*.5+x,size):zp=wrap(size*.5+z,size)
If x >-5 And z >-5
terrain(xp,zp)\height=30
EndIf
terrain(xp,zp)\LandIndex=4
Next
Next
;position objects
For z=size-1 To 0 Step -1
For x=0 To size-1
terrain(x,z)\ObjectIndex=0
If terrain(x,z)\LandIndex = 3
If (x Mod 2)=0 And (z Mod 2)=0 And Rand(0,20)=0
If Rand( 0,4 ) < 4
;trees
terrain(x,z)\ObjectIndex=Rand(1,4)
Else
;buildings
terrain(x,z)\ObjectIndex=Rand(0,2)+5
EndIf
If Rand(0,16)=0
;windmills
terrain(x,z)\ObjectIndex=9
EndIf
EndIf
EndIf
Next
Next
;rockets
For z=127 To 131 Step 2
terrain(131,z)\ObjectIndex=10
Next
;radar towers
For z=0 To 7:For x=0 To 7
px=wrap(x*32+Rand(-4,4)*2,size)
pz=wrap(z*32+Rand(-4,4)*2,size)
If z=4 And x=4 px=130:pz=125
terrain(px,pz)\ObjectIndex=8
Next:Next
;bonus crates
crates=0:cratesno = 9
Repeat
x=Rand(0,size-1)
z=Rand(0,size-1)
If (x Mod 2)=0 And (z Mod 2)=0 And terrain(x,z)\landindex = 3 And terrain(x,z)\ObjectIndex = 0
terrain(x,z)\ObjectIndex=11
crates=crates+1
EndIf
Until crates = cratesno
terrain(125,125)\ObjectIndex=11
;test it works
heightmap = CreateImage( size, size )
SetBuffer ImageBuffer( heightmap )
Color 0,0,0:Rect 0,0,size,size,1
For z =0 To size -1
For x =0 To size -1
green# = terrain(x,z)\height
blue = terrain(x,z)\landindex * 40
red = terrain(x,z)\objectindex * 20
Color red,green,blue
Plot x,z
Next
Next
objectmap = CreateImage( size, size )
SetBuffer ImageBuffer( objectmap )
Color 0,0,0:Rect 0,0,size,size,1
For z =0 To size -1
For x =0 To size -1
green = terrain(x,z)\objectindex * 25
If green > 0
Color green,green,green
Plot x,z
EndIf
Next
Next
landmap = CreateImage( size, size )
SetBuffer ImageBuffer( landmap )
Color 0,0,0:Rect 0,0,size,size,1
For z =0 To size -1
For x =0 To size -1
blue = terrain(x,z)\landindex * 50
Color 0,0,blue
Plot x,z
Next
Next
SetBuffer BackBuffer()
DrawImage heightmap,0,0
DrawImage landmap,0,300
DrawImage objectmap,400,300
Flip
MouseWait
SaveImage ( heightmap, file$)
FreeImage heightmap
FreeImage landmap
FreeImage objectmap
End Function
;===========================
;===========================
;===========================
Function GetHeight( bx#,bz# )
bx=wrap(bx,size)
bz=wrap(bz,size)
tx#=Floor(bx)
tz#=Floor(bz)
ix#=bx - tx:iz#=bz - tz
cx#=WRAP(tx+1.0,size)
cz#=WRAP(tz+1.0,size)
;collision height
v1#=terrain(tx,tz)\height+(terrain(cx,tz)\height-terrain(tx,tz)\height)*ix
v2#=terrain(tx,cz)\height+(terrain(cx,cz)\height-terrain(tx,cz)\height)*ix
Return v1+(v2-v1)*iz
End Function
;===========================
;===========================
;===========================
Function WRAP#( q# , hi# , lo#=0 )
If q < lo Then q = hi + (q-lo)
If q >= hi Then q = lo + (q-hi)
Return q
End Function
;===========================
;===========================
;===========================
Function limit#(q#,low#,hi#)
If q < low q = low
If q > hi q = hi
Return q
end function