I get black screen for about 15-30 seconds
then "runtime error 1002 Bitmap does not exist at line 235"
Then my Pentium M froze while posting on this forum, looked at task list didn't look like it was busy, but no other windows would respond. (could have been IE having a problem)
"Runtime error 504 cannot grab image due to illegal area at line 308"
LOD = Landscape of Doom?
[UPDATE]
I changed everyong from 4096 to 1024 and it worked. i dunno why my PC refuses to make a 4096x4096 bitmap
here's the code if anyone else is having problems
Rem Project:ATD add on - roads etc by Van-B
`original memblock creation codes by Kevil (Kevin Verbeek)
sync on : sync rate 0 : autocam off
global freeobj=10000
global terrainspread=1
global size_x=2048
global size_z=2048
global tsize#=100.0
global meshlayer#
global watx#
global waty#
global watz#
global lastheight#
global buildmode=0
Type terraintype
x as integer
y as integer
z as integer
nx as float
ny as float
nz as float
color as integer
sel as byte
Endtype
dim ter(2048,2048) as terraintype
global envcol
envcol=rgb(32,64,128)
set camera range 10,20000
backdrop on
position light 0,12800,12800,12800
set light range 0,50000 : set point light 0,0,0,0
`Load image heightmap
import_height("terrainheightmap.png")
`Load textures
load image "terrainrockface.png",1
load image "terrainpatchygrass.png",2
load image "terrainshore.png",3
load image "terrainmask.png",4
load effect "terrainterrainFXv2.fx",10,0
set ambient light 30
tob=100
create_terrainmask(tob)
load mesh "terrainlod_ter.x",tob
make object tob,tob,0
set object texture 100,0,0
convert object fvf tob,338
set object effect 100,10
texture object tob,0,1
texture object tob,1,2
texture object tob,2,3
texture object tob,3,tob
position camera 2400,2400,2400
setenvironment(envcol)
camx#=247*100
camz#=247*100
tim=timer()
stampz#=1000000
position camera camx#,camy#,camz#
update_terrain(camx#,camz#)
stampx#=camx# : stampz#=camz#
do
lastmb=mb
mx=mousex()
my=mousey()
mb=mouseclick()
yang#=wrapvalue(yang#+(mousemovex()/3.0))
xang#=wrapvalue(xang#+(mousemovey()/3.0))
if upkey()=1 then move camera 50.0*elapsed#
if downkey()=1 then move camera -50.0*elapsed#
camx#=camera position x()
camz#=camera position z()
if mouseclick()=1
inc camys#,10.0*elapsed#
if camys#<20.0 then camys#=20.0
else
dec camys#,10.0*elapsed#
endif
if camys#>50.0 then camys#=50.0
if camys#<-200.0 then camys#=-200.0
inc camy#,camys#*elapsed#
coly#=getheight#(camx#,camz#)+140.0
if camy#<10.0 then camy#=10.0
if camy#<coly#
camy#=coly#
if camys#<-50 then camys#=0.0-camys#/2.0 else camys#=0.0
endif
rotate camera xang#,yang#,0
position camera camx#,camy#,camz#
`Check to see if moved more than 8 tiles
cdifx=(camx#-stampx#)/100
cdifz=(camz#-stampz#)/100
if cdifx>8 or cdifx<-8 or cdifz>8 or cdifz<-8
update_terrain(int(camx#/400)*400.0,int(camz#/400)*400.0)
stampx#=int(camx#/400)*400.0 : stampz#=int(camz#/400)*400.0
endif
text 0,0,str$(statistic(1))+" Polys @ "+str$(screen fps())+"FPS "
elapsed#=(timer()-tim)/100.0
tim=timer()
sync
loop
end
`----------------------------------------------------------------------------------------
function getheight#(x#,z#)
getheight#=0.0
if x#>0 and z#>0 and x#<(2047*100) and z#<(2047*100)
xt=x#/100
zt=z#/100
if (((xt+1)*100.0)-x#)+(z#-(zt*100.0))<=100.0
dx#=ter(xt+1,zt).y-ter(xt,zt).y
dz#=ter(xt+1,zt+1).y-ter(xt+1,zt).y
tri=0
else
dx#=ter(xt+1,zt+1).y-ter(xt,zt+1).y
dz#=ter(xt,zt+1).y-ter(xt,zt).y
tri=1
endif
getheight#=(((x#-(xt*100.0))/100.0)*dx#)+(((z#-(zt*100.0))/100.0)*dz#)+ter(xt,zt).y
endif
endfunction getheight#
`----------------------------------------------------------------------------------------
function setenvironment(col)
color backdrop col
envr=rgbr(col)/1.5
envg=rgbg(col)/1.5
envb=rgbb(col)/1.5
fog color rgb(envr,envg,envb)
endfunction
`----------------------------------------------------------------------------------------
function lim_byte(value)
if value<0 then value=0
if value>255 then value=255
endfunction value
`----------------------------------------------------------------------------------------
function update_terrain(x#,z#)
x#=int(x#/100)*100.0
z#=int(z#/100)*100.0
tob=100
position object tob,x#,0,z#
show object tob
LOCK VERTEXDATA FOR LIMB tob,0
verts=GET VERTEXDATA VERTEX COUNT()-1
for v=0 to verts
xx#=get vertexdata position x(v)
zz#=get vertexdata position z(v)
`yy#=get vertexdata position z(v)
if terrainspread=0
d#=dist#(0.0,0.0,xx#,zz#)
mul#=(d#-2000.0)/800.0
if mul#<1.0 then mul#=1.0
xx#=xx#*mul#
zz#=zz#*mul#
endif
yy#=getheight#(xx#+x#,zz#+z#)
set vertexdata position v,xx#,yy#,zz#
set vertexdata UV v,(xx#+x#)/204800.0,(zz#+z#)/204800.0
next v
unlock vertexdata
terrainspread=1
endfunction
`----------------------------------------------------------------------------------------
function create_terrainmask(tob)
if image exist(tob)=1 then delete image tob
if file exist("terrainterrainmask.bmp")=1
load image "terrainterrainmask.bmp",tob,1
exitfunction
endif
if bitmap exist(9)=0
create bitmap 9,1024,1024
endif
set current bitmap 9
lock pixels
for z=0 to 1023
for x=0 to 1023
colr=0
colg=255
colb=0
x#=x*50.0
z#=z*50.0
y#=(getheight#(x#,z#)+getheight#(x#-12.5,z#)+getheight#(x#+12.5,z#)+getheight#(x#,z#-12.5)+getheight#(x#,z#+12.5))/5.0
if y#<100.0 then colb=abs(y#-100.0)*2.5
yt#=y#
yb#=y#
for ang=0 to 360 step 30
xx#=x#+sin(ang)*50.0 : zz#=z#+cos(ang)*50.0
yy#=getheight#(xx#,zz#)
if yt#<yy# then yt#=yy#
if yb#>yy# then yb#=yy#
next ang
inc yt#,10000.0
inc yb#,10000.0
colr=((yt#-yb#)-50.0)
yt#=y#
yb#=y#
for a=0 to 1
ang=45+(a*180)
xx#=x#+sin(ang)*100.0 : zz#=z#+cos(ang)*100.0
yy#=getheight#(xx#,zz#)
if a=1 then yt#=yy#
if a=0 then yb#=yy#
next a
inc yt#,10000.0
inc yb#,10000.0
cmul#=0.7-((yt#-yb#)/500.0)+((yb#-yt#)/1000.0)
xx#=x#
yy#=y#+5.0
zz#=z#
shade#=0.6
while shade#<1.0 and getheight#(xx#,zz#)<yy#
inc shade#,0.02
dec xx#,12.5
dec zz#,12.5
inc yy#,4.0
endwhile
if cmul#>shade# then cmul#=shade#
if cmul#<0.2 then cmul#=0.2
if cmul#>1.0 then cmul#=1.0
if colr<0 then colr=0
if colr>255 then colr=255
if colg<0 then colg=0
if colg>255 then colg=255
if colb<0 then colb=0
if colb>255 then colb=255
if colr>colb then colg=255-colr
if colb>colr then colg=255-colb
ink rgb(colr*cmul#,colg*cmul#,colb*cmul#),0 : dot x+2,z+2
next x
next z
unlock pixels
get image tob,0,0,1024,1024,1
if file exist("terrainterrainmask.bmp")=1 then delete file "terrainterrainmask.bmp"
save image "terrainterrainmask.bmp",tob
set current bitmap 0
endfunction
`----------------------------------------------------------------------------------------
function dist#(xa#,za#,xb#,zb#)
x#=xa#-xb#
z#=za#-zb#
dist#=sqrt(abs(x#*x#)+abs(z#*z#))
endfunction dist#
`----------------------------------------------------------------------------------------
function create_skysphere(o,t,r#)
make object sphere o,r#,16,16
texture object o,t
set object light o, 0
set object texture o, 3, 0
set object fog o,0
set object cull o,0
set camera range 10,r#*2.1
set object smoothing o,180
endfunction
`----------------------------------------------------------------------------------------
function import_height(fn$)
if bitmap exist(5)=1 then delete bitmap 5
load bitmap fn$,5
set current bitmap 5
sizex=bitmap width(5)
sizez=bitmap height(5)
if sizex>2048 then sizex=2048
if sizez>2048 then sizez=2048
lock pixels
for z=0 to sizez-1
for x=0 to sizex-1
ter(x,z).y=(rgbr(point(x,z))*50.0)-300.0
ter(x,z).color=rnd(256*256*256)
next x
next z
unlock pixels
for z=1 to sizez-1
for x=1 to sizex-1
tty#=ter(x,z).y
tty#=tty#+ter(x-1,z).y
tty#=tty#+ter(x,z-1).y
tty#=tty#+ter(x-1,z-1).y
ter(x,z).y=tty#/4.0
next x
next z
for z=0 to sizez-1
for x=0 to sizex-1
if col>232 then col=232
if col<32 then col=32
col=255
ter(x,z).color=rgb(col,col,col)
if ter(x,z).y<0
bcol=abs(ter(x,z).y*3.0)+col
col=abs(ter(x,z).y)-col
if bcol>255 then bcol=255
if bcol<0 then bcol=0
if col>255 then bcol=255
if col<0 then bcol=0
ter(x,z).color=rgb(col,col,bcol)
endif
ter(x,z).nx=0
ter(x,z).ny=1.0
ter(x,z).nz=0
next x
next z
delete bitmap 5
endfunction
`----------------------------------------------------------------------------------------
DinoHunter (still no nVidia compo voucher!), CPU/GPU Benchmark, DarkFish Encryption DLL, War MMOG (WIP), 3D Model Viewer