TerrainShading.htm 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>TerrainShading terrain,enable</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. terrain - terrain handle <br />
  13. enable - True to enable terrain shading, False to to disable it. The default mode is False.
  14. </td>
  15. </tr>
  16. </table>
  17. <h1>Description</h1>
  18. <table>
  19. <tr>
  20. <td>
  21. Enables or disables terrain shading. <br />
  22. <br />
  23. Shaded terrains are a little slower than non-shaded terrains, and in some instances can increase the visibility of LOD 'pop-in'. However, the option is there to have shaded terrains if you wish to do so.
  24. </td>
  25. </tr>
  26. </table>
  27. <h1><a href=../3d_examples/TerrainShading.bb>Example</a></h1>
  28. <table>
  29. <tr>
  30. <td>
  31. ; TerrainShading Example <br />
  32. ; ---------------------- <br />
  33. <br />
  34. Graphics3D 640,480 <br />
  35. SetBuffer BackBuffer() <br />
  36. <br />
  37. camera=CreateCamera() <br />
  38. PositionEntity camera,1,1,1 <br />
  39. <br />
  40. light=CreateLight() <br />
  41. RotateEntity light,45,0,0 <br />
  42. <br />
  43. ; Load terrain <br />
  44. terrain=LoadTerrain( "media/height_map.bmp" ) <br />
  45. <br />
  46. ; Set terrain detail, enable vertex morphing <br />
  47. TerrainDetail terrain,4000,True <br />
  48. <br />
  49. ; Scale terrain <br />
  50. ScaleEntity terrain,1,50,1 <br />
  51. <br />
  52. ; Texture terrain <br />
  53. grass_tex=LoadTexture( "media/mossyground.bmp" ) <br />
  54. EntityTexture terrain,grass_tex,0,1 <br />
  55. <br />
  56. While Not KeyDown( 1 ) <br />
  57. <br />
  58. ; Toggle terrain shading value between 0 and 1 when spacebar is pressed <br />
  59. If KeyHit(57)=True Then terra_shade=1-terra_shade <br />
  60. <br />
  61. ; Enable/disable terrain shading <br />
  62. TerrainShading terrain,terra_shade <br />
  63. <br />
  64. If KeyDown( 203 )=True Then x#=x#-0.1 <br />
  65. If KeyDown( 205 )=True Then x#=x#+0.1 <br />
  66. If KeyDown( 208 )=True Then y#=y#-0.1 <br />
  67. If KeyDown( 200 )=True Then y#=y#+0.1 <br />
  68. If KeyDown( 44 )=True Then z#=z#-0.1 <br />
  69. If KeyDown( 30 )=True Then z#=z#+0.1 <br />
  70. <br />
  71. If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0 <br />
  72. If KeyDown( 203 )=True Then TurnEntity camera,0,1,0 <br />
  73. If KeyDown( 208 )=True Then MoveEntity camera,0,0,-0.1 <br />
  74. If KeyDown( 200 )=True Then MoveEntity camera,0,0,0.1 <br />
  75. <br />
  76. x#=EntityX(camera) <br />
  77. y#=EntityY(camera) <br />
  78. z#=EntityZ(camera) <br />
  79. <br />
  80. terra_y#=TerrainY(terrain,x#,y#,z#)+5 <br />
  81. <br />
  82. PositionEntity camera,x#,terra_y#,z# <br />
  83. <br />
  84. RenderWorld <br />
  85. <br />
  86. Text 0,0,"Use cursor keys to move about the terrain" <br />
  87. Text 0,20,"Press spacebar to toggle between TerrainShading True/False" <br />
  88. If terra_shade=True Then Text 0,40,"TerrainShading: True" Else Text 0,40,"TerrainShading: False" <br />
  89. <br />
  90. Flip <br />
  91. <br />
  92. Wend <br />
  93. <br />
  94. End
  95. </td>
  96. </tr>
  97. </table>
  98. <br>
  99. <a target=_top href=../index.htm>Index</a><br>
  100. <br>
  101. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=TerrainShading&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  102. </html>