{ From: SEAN PALMER Subj: 3d Landscape src --------------------------------------------------------------------------- Check it out! Clean-room reverse-engineering of something pretty damn similar to Comanche's patented Voxel-space technology... In Turbo!! {by Sean Palmer} {use I,J,K,L to look around, ESC ends} uses crt; const xSize=256; {90 degrees} ySize=128; {60 degrees} angleMask=xSize*4-1; {xSize must be power of 2 or and's won't work} mapSize=128; var sinTab:array[0..angleMask]of integer; {sin(xyAngle)*$7FFF} tanTab:array[0..ySize-1]of integer; {tan(zAngle)*$7FFF} map:array[0..mapSize-1,0..mapSize-1]of byte; type fixed=record case boolean of false:(l:longint); true:(f:word;i:integer); end; procedure drawScene(x,y,z,rot:integer); var lastTan,lastAngle,h:integer; mapTan:longint; var scrn:word; var color,height:byte; var xs,ys,ds:longint; var xp,yp,dp:fixed; begin fillchar(mem[$A000:0],320*200,0); for h:=0 to xSize-1 do begin lastAngle:=0; scrn:=h+320*(ySize-1); lastTan:=tanTab[lastAngle]; xp.i:=x; xp.f:=0; yp.i:=y; yp.f:=0; dp.l:=0; xs:=longint(sinTab[(h+rot-(xSize shr 1))and angleMask])*2; ys:=longint(sinTab[(h+rot-(xSize shr 1)+xSize)and angleMask])*2; {cos} ds:=$FFFE; inc(xp.l,xs*16); inc(yp.l,ys*16); inc(dp.l,ds*16); while lastAnglemapSize-1 then break; if word(yp.i)>mapSize-1 then break; height:=map[xp.i,yp.i]; mapTan:=(longint(height-z)*$7FFF)div dp.i; color:=32+(z-height); while(lastTan<=mapTan)and(lastAngle-30000 then for i:=0 to ySize-1 do dec(tanTab[i],500); 'J':r:=(r-32)and angleMask; 'L':r:=(r+32)and angleMask; end; until c=^[; textMode(lastMode); end.