light.monkey2 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. Namespace mojo3d
  2. #rem monkeydoc The LightType enumeration.
  3. Note: Only directional lights are currently fully supported.
  4. | LightType | Description
  5. |:--------------|:-----------
  6. | `Directional` | Light at infinity.
  7. | `Point` | Point light.
  8. | `Spot` | Spot light.
  9. #end
  10. Enum LightType
  11. Directional=1
  12. Point=2
  13. Spot=3
  14. End
  15. #rem monkeydoc The Light class.
  16. #end
  17. Class Light Extends Entity
  18. #rem monkeydoc Creates a new light.
  19. #end
  20. Method New( parent:Entity=Null )
  21. Super.New( parent )
  22. Name="Light"
  23. Type=LightType.Directional
  24. CastsShadow=False
  25. Range=10
  26. AddInstance()
  27. Visible=True
  28. End
  29. #rem monkeydoc Copies the light.
  30. #end
  31. Method Copy:Light( parent:Entity=Null ) Override
  32. Local copy:=OnCopy( parent )
  33. CopyTo( copy )
  34. Return copy
  35. End
  36. #rem monkeydoc The light type.
  37. #end
  38. Property Type:LightType()
  39. Return _type
  40. Setter( type:LightType )
  41. _type=type
  42. End
  43. #rem monkeydoc Light shadows enabled flag.
  44. #end
  45. [jsonify=1]
  46. Property CastsShadow:Bool()
  47. Return _castsShadow
  48. Setter( shadows:Bool )
  49. _castsShadow=shadows
  50. End
  51. #rem monkeydoc The light range.
  52. #end
  53. [jsonify=1]
  54. Property Range:Float()
  55. Return _range
  56. Setter( range:Float )
  57. _range=range
  58. End
  59. Protected
  60. Method New( light:Light,parent:Entity )
  61. Super.New( light,parent )
  62. Type=light.Type
  63. Color=light.Color
  64. Range=light.Range
  65. AddInstance( light )
  66. End
  67. Method OnCopy:Light( parent:Entity ) Override
  68. Return New Light( Self,parent )
  69. End
  70. Method OnShow() Override
  71. Scene.Lights.Add( Self )
  72. End
  73. Method OnHide() Override
  74. Scene.Lights.Remove( Self )
  75. End
  76. Private
  77. Field _type:LightType
  78. Field _color:Color
  79. Field _range:Float
  80. Field _castsShadow:bool
  81. Field _dynamic:Bool
  82. End