; CreateTerrain Example ; --------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() CameraRange camera,1,500 light=CreateLight() RotateEntity light,45,45,0 ; CreateTerrain builds a flat LOD terrain with 64 grid squares per side terrain=CreateTerrain(64) ; Stretch it into a landscape: 8 units per grid square, 40 units tall ScaleEntity terrain,8,40,8 ; Sculpt some rolling hills into the flat grid (heights range 0 to 1) ; Grid points run 0 to size-1; index 64 would wrap around onto index 0 For gx=0 To 63 For gz=0 To 63 ModifyTerrain terrain,gx,gz,(Sin(gx*22)+Cos(gz*17)+2)*0.15 Next Next ; Texture the landscape grass_tex=LoadTexture("media/MossyGround.BMP") EntityTexture terrain,grass_tex ; Start in the middle of the terrain PositionEntity camera,256,30,256 While Not KeyDown(1) ; Drift forward on its own; arrow keys steer and speed up MoveEntity camera,0,0,0.2 If KeyDown(200) Then MoveEntity camera,0,0,1 If KeyDown(208) Then MoveEntity camera,0,0,-1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 ; Glide at a fixed height above the ground x#=EntityX(camera) z#=EntityZ(camera) y#=TerrainY(terrain,x,EntityY(camera),z)+8 PositionEntity camera,x,y,z RenderWorld Text 0,0,"Arrows: fly over the terrain Esc: exit" Text 0,20,"CreateTerrain(64) made this landscape - no height map file needed" Flip Wend End