TerrainSize.bb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ; TerrainSize Example
  2. ; -------------------
  3. Graphics3D 640,480
  4. SetBuffer BackBuffer()
  5. camera=CreateCamera()
  6. PositionEntity camera,1,1,1
  7. light=CreateLight()
  8. RotateEntity light,90,0,0
  9. ; Load terrain
  10. terrain=LoadTerrain( "media/height_map.bmp" )
  11. ; Set terrain detail, enable vertex morphing
  12. TerrainDetail terrain,4000,True
  13. ; Scale terrain
  14. ScaleEntity terrain,1,50,1
  15. ; Texture terrain
  16. grass_tex=LoadTexture( "media/mossyground.bmp" )
  17. EntityTexture terrain,grass_tex,0,1
  18. While Not KeyDown( 1 )
  19. If KeyDown( 203 )=True Then x#=x#-0.1
  20. If KeyDown( 205 )=True Then x#=x#+0.1
  21. If KeyDown( 208 )=True Then y#=y#-0.1
  22. If KeyDown( 200 )=True Then y#=y#+0.1
  23. If KeyDown( 44 )=True Then z#=z#-0.1
  24. If KeyDown( 30 )=True Then z#=z#+0.1
  25. If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0
  26. If KeyDown( 203 )=True Then TurnEntity camera,0,1,0
  27. If KeyDown( 208 )=True Then MoveEntity camera,0,0,-0.1
  28. If KeyDown( 200 )=True Then MoveEntity camera,0,0,0.1
  29. x#=EntityX(camera)
  30. y#=EntityY(camera)
  31. z#=EntityZ(camera)
  32. terra_y#=TerrainY(terrain,x#,y#,z#)+5
  33. PositionEntity camera,x#,terra_y#,z#
  34. RenderWorld
  35. Text 0,0,"Use cursor keys to move about the terrain"
  36. ; Output terrain size to screen
  37. Text 0,20,"Terrain Size: "+TerrainSize(terrain)
  38. Flip
  39. Wend
  40. End