Hi,
I'm encountering a strange and unpredictale error using the full version. The attached code replicates it (occasionally!) and uses the default blitz media.
When attempting to rescale blitz terrain DBP is locking up with the default "this application has stopped working" error. It's happening for me fairly frequently.
Can anyone please check my code and see if they can replicate this error. I could just be making a stupid error, but can't see where.
Specs: Windows 7 64, i5 650, Radeon HD 6450, 4gb
//BLITZWERKS TERRAIN 2.02 EXAMPLE - LOD TERRAINS
//CREATED BY KARL HOBLEY (KAEDROHO) http://www.blitzwerks.co.uk
//CODE BELOW MAY BE USED IN COMMERCIAL AND NON COMMERCIAL PROJECTS
//CREATED AND TESTED WITH DBPRO 7.5
//This demo shows how to add LOD to a terrain. I will make the system create 3 LOD Levels and update them.
//LOD is basically, an algorithm to simplify parts of the terrain which are far away. Making draw speeds faster with low visual impact.
//BlitzTerrain reduces the amount of draw calls as well as polygons in distant areas for very high FPS gain.
//In this example, I am using a small terrain. The performance gain with LOD is much higher with bigger terrains.
//I only needed to add 4 extra lines to get LOD working.
//CONTROLS
//ARROWKEYS AND MOUSE - MOVE
// F1 - WIREFRAME ON. F2 - WIREFRAME OFF
//Setup
sync on : sync rate 0 : sync
center text screen width()/2,screen height()/2,"Loading..." : sync : cls
//Load media
global g_HeightmapImgID : global g_TextureImgID : global g_DetailmapImgID
g_HeightmapImgID=1 : g_TextureImgID=2 : g_DetailmapImgID=3
load image "Media\heightmap.bmp",g_HeightmapImgID
load image "Media\texture.jpg",g_TextureImgID
load image "Media\detail.tga",g_DetailmapImgID
//Create terrain
//Make the terrain
global g_TerrainID
g_TerrainID=BT MakeTerrain()
//Set images
BT SetTerrainHeightmap g_TerrainID,g_HeightmapImgID
BT SetTerrainTexture g_TerrainID,g_TextureImgID
BT SetTerrainDetail g_TerrainID,g_DetailmapImgID
//Set some other values
BT SetTerrainScale g_TerrainID,12.0
BT SetTerrainYScale g_TerrainID,2.0
BT SetTerrainSplit g_TerrainID,32
BT SetTerrainDetailTile g_TerrainID,3.0
//LOD
BT SetTerrainLOD g_TerrainID,9 //9 LOD levels
BT SetTerrainLODDistance g_TerrainID,1,100.0 //LOD Distances start at one and go up to 1 less the LOD level count
BT SetTerrainLODDistance g_TerrainID,2,300.0
BT SetTerrainLODDistance g_TerrainID,3,500.0
BT SetTerrainLODDistance g_TerrainID,4,1000.0
BT SetTerrainLODDistance g_TerrainID,5,2000.0
BT SetTerrainLODDistance g_TerrainID,6,3000.0
BT SetTerrainLODDistance g_TerrainID,7,4000.0
BT SetTerrainLODDistance g_TerrainID,8,5000.0
//Build
global g_TerrainObjectID
g_TerrainObjectID=1
//This command processes the heightmap and creates all the internal structures for the terrain
`BT Setterrainquadreduction g_TerrainID,1
BT BuildTerrain g_TerrainID,g_TerrainObjectID,1
//Setup camera
set camera range 10,50000
position camera 0,800,1100,1000
hide mouse
//Enable auto render
BT EnableAutoRender 1
//Main loop
StartTime=timer()
do
//Camera movement
Elapsedtime#=(timer()-StartTime)/3000.0+Elapsedtime#*0.7
StartTime=timer()
cx#=camera angle x()+mousemovey()/4.0
if cx#>90.0 then cx#=90.0
if cx#<-90.0 then cx#=-90.0
rotate camera cx#,camera angle y()+mousemovex()/4.0,0.0
if upkey() then move camera 1000.0*Elapsedtime#
if downkey() then move camera -1000.0*Elapsedtime#
gheight#=BT GetGroundHeight(g_TerrainID,camera position x(),camera position z())
if camera position y()-40<gheight# then position camera camera position x(),gheight#+40,camera position z()
aa=BT getterrainsize(g_TerrainID)
//Wireframe
if keystate(59) then set object wireframe g_TerrainObjectID,1
if keystate(60) then set object wireframe g_TerrainObjectID,0
rem raise terrain if in mode
if mouseclick()=1
BT RaiseTerrain g_TerrainID,camera position x(0),camera position z(0),400,200*Elapsedtime#
endif
if mouseclick()=2
BT RaiseTerrain g_TerrainID,camera position x(0),camera position z(0),400,-200*Elapsedtime#
endif
if scancode()=33 then BT Flattenterrain g_TerrainID,camera position x(0),camera position z(0),400
`BT updateterrain g_TerrainObjectID
//FPS
text 10,10,str$(screen fps())
text 10,20,str$(int(camera position x(0)))+","+str$(int(camera position y(0)))+","+str$(int(camera position z(0)))
text 10,30,str$(scancode())
//Position mouse
position mouse screen width()/2,screen height()/2
//Update screen
sync
loop
http://jimjamsgames.yolasite.com