TGC Codebase Backup



Heightmap to Matrix by UnSomething

14th Nov 2003 8:19
Summary

It takes an image and creates a matrix from it.



Description

It takes an image and creates a matrix from it.You can specify the size and height of the created matrix.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    function matrix(file as string,sizex as integer,sizey as integer,matnum as integer,hvalue as float)
load bitmap file,9999
set current bitmap 9999
width=bitmap width()-1
height=bitmap height()-1
color as dword
dim colora(100,100) as dword
make matrix matnum,sizex,sizey,width,height
for a=0 to width step 1
for b=0 to height step 1
color=rgbr(point(a,b))
set matrix height matnum,a,b,color*hvalue
next b
next a
set current bitmap 0
update matrix matnum
delete bitmap 9999
endfunction