Heres the code corrected:
`------------------------Coded By OutLand---------------------------
`---------------------Height Bmp to Matrix-------------------------
`This Code gets the the color data from a bmp and converts it to
`height data. The lighter the shade the heigher the darker the lower.
`I create my height Bmp's in a program called PhotoStudio2000
`They can also be made in PaintShop
`This function Get the height data from the Hmap.Bmp and saves it
`as a hmap(x,z) array. I picked up the bmp decoder off a forum a
`while back from Kevin Picone. I have cut it down to do the job
`I need it to do.
`--------------------------------------------------------------------
set display mode 1024,768,32
sync on
sync rate 0
backdrop on
color backdrop rgb(0,0,0)
set camera range 1,10000
`this array line isnt needed in dbpro only in dbc
`hmap(1) the array is re-created in the getheightbmp("hmap.bmp") function with the right values
dim hmap(1)
getheightbmp("hmap.bmp")
make matrix 1,5000,5000,70,70
for x=1 to 70
for z=1 to 70
set matrix height 1,x,z,hmap(x,z)*3
next z
next x
update matrix 1
do
rem Crude way to fix mouse pointer (hide this and run again)
position mouse 320,240
rem Use MOUSEMOVE to alter camera angles
cx#=wrapvalue(cx#+mousemovey())
cy#=wrapvalue(cy#+mousemovex())
cz#=wrapvalue(cz#+mousemovez())
rotate camera cx#,cy#,cz#
rem Simple movement
if upkey()=1 then move camera 25
if downkey()=1 then move camera -25
rem Update screen
sync
loop
function getheightbmp(file$)
`this function only gets information from a 24-bit bitmap
`so make sure you save it as one
open to read 1,file$
`--------------------
`decode the header
`The info contained here is not usefull.
read byte 1,notusefull
read byte 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
`--------------------
`Get Bitmap Width
read long 1,BmpWidth
`Get Bitmap Height
read long 1,BmpHeight
`--------------------
read word 1,notusefull
`--------------------
`Get BitDepth
read word 1,BitDepth
`--------------------
`The info contained here is not usefull.
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
`--------------------
`error check only if bitdepth=24
if BitDepth=24
ypos=BmpHeight
` Calculate If bmp required Padding
bmpwidth#=bmpwidth
evenwidth1#=(BmpWidth#*3)/4
evenwidth2=(BmpWidth*3)/4
padlen=0
if evenwidth1#<>evenwidth2
evenwidth1#=evenwidth1#-evenwidth2
padlen=4-(evenwidth1#*4)
endif
`-------------------------------------------
`create the hmap array
dim hmap(bmpwidth,bmpheight)
`-------------------------------------------
`Get color info
For Ylp=1 to BmpHeight
for Xlp=1 to Bmpwidth
`Read color values
read byte 1,blue
read byte 1,Green
read byte 1,red
`enter color info into height array
hmap(xlp,ypos)=(blue+green+red)/3
next Xlp
dec Ypos
`Padding
if padlen<>0
for padlp=1 to padlen
read byte 1,padbyte
next padlp
endif
next Ylp
endif
close file 1
endfunction