lights.bb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. Global info1$="Lights demo"
  2. Global info2$="Features directional, point and spot lights"
  3. Include "../start.bb"
  4. AmbientLight 0,0,0
  5. sphere=CreateSphere(32)
  6. camera=CreateCamera()
  7. PositionEntity camera,0,0,-3
  8. ;directional light
  9. light1=CreateLight( 1 )
  10. TurnEntity light1,0,-30,0
  11. LightColor light1,255,0,0
  12. HideEntity light1
  13. ;point light
  14. light2=CreateLight( 2 )
  15. PositionEntity light2,5,0,-10
  16. LightColor light2,0,255,0
  17. LightRange light2,15
  18. HideEntity light2
  19. ;spot light
  20. light3=CreateLight( 3 )
  21. PositionEntity light3,0,0,-10
  22. LightColor light3,0,0,255
  23. LightConeAngles light3,0,10
  24. LightRange light3,15
  25. HideEntity light3
  26. on1=True
  27. on2=True
  28. on3=True
  29. If on1 Then ShowEntity light1
  30. If on2 Then ShowEntity light2
  31. If on3 Then ShowEntity light3
  32. While Not KeyHit(1)
  33. If KeyHit(59)
  34. on1=Not on1
  35. If on1 Then ShowEntity light1 Else HideEntity light1
  36. EndIf
  37. If KeyHit(60)
  38. on2=Not on2
  39. If on2 Then ShowEntity light2 Else HideEntity light2
  40. EndIf
  41. If KeyHit(61)
  42. on3=Not on3
  43. If on3 Then ShowEntity light3 Else HideEntity light3
  44. EndIf
  45. If on3
  46. RotateEntity light3,Sin(MilliSecs()*.07)*5,Sin(MilliSecs()*.05)*5,0
  47. ; TurnEntity light3,0,1,0
  48. EndIf
  49. UpdateWorld
  50. RenderWorld
  51. Text 0,FontHeight()*0,"(F1) Light1="+on1
  52. Text 0,FontHeight()*1,"(F2) Light2="+on2
  53. Text 0,FontHeight()*2,"(F3) Light3="+on3
  54. Flip
  55. Wend
  56. End