TGC Codebase Backup



Matrix bump and texture mapper by Zach

12th Apr 2006 12:39
Summary

Used to create complex terrain from 2d bitmap images, in only a few minutes...



Description

This code allows you to use greyscale images of any size to biuld matrixes,
and full color bitmaps of up to 256x256 pxls as texture maps.

instead of coding every point on a matrix and killing time in guess work just draw it in 2d and this code converts it into 3d.

instead of texturing each tile on a matrix, simply use one texture map...



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem ********************************
rem ** Bump and Color Map Project **
rem *** GrimVis ********************
rem ********************4-11-06*****

remstart
**VERY IMPORTANT!!!!!!!!!!!!!!**
   Bump Map images should be equevalent to the size value stated below in pixles
   and in greyscale--(black= sea level | white= very tall mountain).
   texture maps should be no more than 256x256 pxls.

   Note: For better results use Lee Bamber's Normalize routine and lighting.
remend

rem turn manual sync on and autocam off
sync on
autocam off

rem make matrix for bump mapping
Size=25
make matrix 1,1000,1000,size,size

rem set a nuetral camera position
position camera 500,900,-300
point camera 500,0,200

rem load the bump and texture map images
load image "bumpmap.bmp",1
load image "texturemap.bmp",2
prepare matrix texture 1,2,size+1,size+1
paste image 1,0,0

rem preset variables and arrays(bump array stores the height for each point on the matrix)
dim bump(size,size)
x=0
y=0

rem get data from bump image
for y=0 to size
for x=0 to size
paste image 1,0,0
bump(x,y)=point(x,y)
next x
next y
sync

rem texture matrix from texture map
x=0
y=0
b=0
l=0
for y=0 to size-1
if l>0 then b=b+1
for x=0 to size-1
 b=b+1:l=1
if x=5 then l=0
paste image 2,0,0
set matrix tile 1,x,y,b
next x
next y
sync

rem Build matrix from bump map
x=0
y=0
b=0
for y=0 to size
for x=0 to size
f=bump(x,y)/70000
set matrix height 1,x,y,f
update matrix 1
next x
next y
sync

rem update matrix
update matrix 1
sync

rem reposition camera
position camera 500,900,-300
point camera 500,0,200

end