REM *********************************************** REM Title: Heightmap to Matrix REM Author: Phaelax REM Downloaded from: http://dbcc.zimnox.com/ REM *********************************************** REM =================== REM heightmap to matrix REM coded by: Phaelax REM =================== sync on autocam off load image "grass.jpg", 1 load image "heightmap.bmp", 2 rem number of matrix tiles xsegs = 120 zsegs = 120 rem create a matrix make matrix 1, 1000,1000,xsegs, zsegs prepare matrix texture 1,1,1,1 rem create an image memblock from the heightmap make memblock from image 256, 2 rem get the image's dimensions width = memblock dword(256, 0) height = memblock dword(256, 4) rem convert integer variables to floats xsegs# = xsegs+1 zsegs# = zsegs+1 rem pixel offset for configuring match between pixel and tile number ox# = width/xsegs# oz# = height/zsegs# rem max height of matrix max# = 1000 rem get pixel color from image location matching corresponding tile coordinates for z = 0 to zsegs for x = 0 to xsegs location = (int(z*oz#)*width + int(x*ox#))*4 + 12 c = memblock byte(256, location) rem convert color value into height value h# = (c*max#)/255.0 set matrix height 1,x,z,h# next x next z delete memblock 256 update matrix 1 DO gosub camera_stuff set cursor 0,0 print cy# sync LOOP camera_stuff: oldcx#=cx# oldcz#=cz# speed# = 5 if upkey()=1 cx#=newxvalue(cx#,a#,speed#) cz#=newzvalue(cz#,a#,speed#) endif if downkey()=1 cx#=newxvalue(cx#,a#,-speed#) cz#=newzvalue(cz#,a#,-speed#) endif if leftkey()=1 cx#=newxvalue(cx#,wrapvalue(a#-90.0),speed#) cz#=newzvalue(cz#,wrapvalue(a#-90.0),speed#) endif if rightkey()=1 cx#=newxvalue(cx#,wrapvalue(a#+90.0),speed#) cz#=newzvalue(cz#,wrapvalue(a#+90.0),speed#) endif if shiftkey() then inc cy#, 2 if controlkey() then dec cy#, 2 a#=wrapvalue(a#+(mousemovex()/3.0)) cxa#=cxa#+(mousemovey()/3.0) if cxa#<-90.0 then cxa#=-90.0 if cxa#>90.0 then cxa#=90.0 cy# = get ground height(1,cx#,cz#) position camera cx#,cy#+50,cz# rotate camera wrapvalue(cxa#),a#,0 RETURN