AmbientLight.htm 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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>AmbientLight red#,green#,blue#</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. red# - red ambient light value <br />
  13. green# - green ambient light value <br />
  14. blue# - blue ambient light value <br />
  15. <br />
  16. The green, red and blue values should be in the range 0-255. The default ambient light colour is 127,127,127.
  17. </td>
  18. </tr>
  19. </table>
  20. <h1>Description</h1>
  21. <table>
  22. <tr>
  23. <td>
  24. Sets the ambient lighting colour. <br />
  25. <br />
  26. Ambient light is a light source that affects all points on a 3D object equally. So with ambient light only, all 3D objects will appear flat, as there will be no shading. <br />
  27. <br />
  28. Ambient light is useful for providing a certain level of light, before adding other lights to provide a realistic lighting effect. <br />
  29. <br />
  30. An ambient light level of 0,0,0 will result in no ambient light being displayed.
  31. <br>
  32. <br>
  33. See also: <a class=small href=CreateLight.htm>CreateLight</a>.
  34. </td>
  35. </tr>
  36. </table>
  37. <h1><a href=../3d_examples/AmbientLight.bb>Example</a></h1>
  38. <table>
  39. <tr>
  40. <td>
  41. ; AmbientLight Example <br />
  42. ; -------------------- <br />
  43. <br />
  44. Graphics3D 640,480 <br />
  45. SetBuffer BackBuffer() <br />
  46. <br />
  47. camera=CreateCamera() <br />
  48. <br />
  49. sphere=CreateSphere( 32 ) <br />
  50. PositionEntity sphere,-2,0,5 <br />
  51. <br />
  52. cone=CreateCone( 32 ) <br />
  53. PositionEntity cone,2,0,5 <br />
  54. <br />
  55. ; Set initial ambient light colour values <br />
  56. red#=127 <br />
  57. green#=127 <br />
  58. blue#=127 <br />
  59. <br />
  60. While Not KeyDown( 1 ) <br />
  61. <br />
  62. ; Change red, green, blue values depending on key pressed <br />
  63. If KeyDown( 2 )=True And red#>0 Then red#=red#-1 <br />
  64. If KeyDown( 3 )=True And red#<255 Then red#=red#+1 <br />
  65. If KeyDown( 4 )=True And green#>0 Then green#=green#-1 <br />
  66. If KeyDown( 5 )=True And green#<255 Then green#=green#+1 <br />
  67. If KeyDown( 6 )=True And blue#>0 Then blue#=blue#-1 <br />
  68. If KeyDown( 7 )=True And blue#<255 Then blue#=blue#+1 <br />
  69. <br />
  70. ; Set ambient light color using red, green, blue values <br />
  71. AmbientLight red#,green#,blue# <br />
  72. <br />
  73. RenderWorld <br />
  74. <br />
  75. Text 0,0,"Press keys 1-6 to change AmbientLight red#,green#,blue# values <br />
  76. Text 0,20,"Ambient Red: "+red# <br />
  77. Text 0,40,"Ambient Green: "+green# <br />
  78. Text 0,60,"Ambient Blue: "+blue# <br />
  79. <br />
  80. Flip <br />
  81. <br />
  82. Wend <br />
  83. <br />
  84. End
  85. </td>
  86. </tr>
  87. </table>
  88. <br>
  89. <a target=_top href=../index.htm>Index</a><br>
  90. <br>
  91. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=AmbientLight&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  92. </html>