Terrain loaded via BlitzTerrain comands using the T.ED produced( and edited ) heightmap.I must say that if you ever want to use T.ED you need to think about some work arround with the terrains which it makes because it's wierd for heightmap to be 505x505 for example while most likely anyone is gonna need square 512x512 one.Every time i use it i need to add few extra pixels manually to the heightmap image.
//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,8
BT SetTerrainDetailTile g_TerrainID,3.0
//LOD
BT SetTerrainLOD g_TerrainID,3 //3 LOD levels
BT SetTerrainLODDistance g_TerrainID,1,1000.0 //LOD Distances start at one and go up to 1 less the LOD level count
BT SetTerrainLODDistance g_TerrainID,2,2000.0
//Build
global g_TerrainObjectID
g_TerrainObjectID=1
//This command processes the heightmap and creates all the internal structures for the terrain
BT BuildTerrain g_TerrainID,g_TerrainObjectID
//This command sets the number of sectors get created every call to 'BT ContinueBuild'.
//As we dont need a loading bar, I set this to 0 which makes it create the whole terrain at once
BT SetBuildStep 0
repeat
//This command generates the sectors. It returns the percentage of how much of the terrain it has generated.
//When it has generated the whole terrain it will return -1
progress=BT ContinueBuild()
until progress=-1
//Setup camera
set camera range 10,10000
hide mouse
//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#
if leftkey() then move camera left 1000.0*Elapsedtime#
if rightkey() then move camera left -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()
//Wireframe
if keystate(59) then set object wireframe g_TerrainObjectID,1
if keystate(60) then set object wireframe g_TerrainObjectID,0
//Render the terrain
BT SetCurrentCamera 0 //Set current camera to 0 (if the camera has moved/rotated since this command was last called, you must call it again!)
BT UpdateTerrainCull g_TerrainID //Update frustum culling
BT UpdateTerrainLOD g_TerrainID //Update LOD
BT RenderTerrain g_TerrainID //Render the terrain
//FPS
text 10,10,str$(screen fps())
//Position mouse
position mouse screen width()/2,screen height()/2
//Update screen
sync
loop
Coding is My Kung Fu!
And My Kung Fu is better than Yours!