light.monkey2 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. Texture=Null
  25. Range=10
  26. InnerAngle=15
  27. OuterAngle=30
  28. CastsShadow=False
  29. Visible=True
  30. AddInstance()
  31. End
  32. #rem monkeydoc Copies the light.
  33. #end
  34. Method Copy:Light( parent:Entity=Null ) Override
  35. Local copy:=OnCopy( parent )
  36. CopyTo( copy )
  37. Return copy
  38. End
  39. #rem monkeydoc The light type.
  40. #end
  41. [jsonify=1]
  42. Property Type:LightType()
  43. Return _type
  44. Setter( type:LightType )
  45. _type=type
  46. End
  47. [jsonify=1]
  48. Property Texture:Texture()
  49. Return _texture
  50. Setter( texture:Texture )
  51. _texture=texture
  52. End
  53. #rem monkeydoc Light shadows enabled flag.
  54. #end
  55. [jsonify=1]
  56. Property CastsShadow:Bool()
  57. Return _castsShadow
  58. Setter( shadows:Bool )
  59. _castsShadow=shadows
  60. End
  61. #rem monkeydoc The light range.
  62. #end
  63. [jsonify=1]
  64. Property Range:Float()
  65. Return _range
  66. Setter( range:Float )
  67. _range=range
  68. End
  69. #rem monkeydoc The cone inner angle for spot lights, in degrees.
  70. Defaults to 0 degrees.
  71. #end
  72. [jsonify=1]
  73. Property InnerAngle:Float()
  74. Return _innerAngle
  75. Setter( angle:Float )
  76. _innerAngle=angle
  77. End
  78. #rem monkeydoc The cone outer angle for spot lights, in degrees.
  79. Defaults to 45 degrees.
  80. #end
  81. [jsonify=1]
  82. Property OuterAngle:Float()
  83. Return _outerAngle
  84. Setter( angle:Float )
  85. _outerAngle=angle
  86. End
  87. Protected
  88. Method New( light:Light,parent:Entity )
  89. Super.New( light,parent )
  90. Type=light.Type
  91. Texture=light.Texture
  92. CastsShadow=light.CastsShadow
  93. Range=light.Range
  94. InnerAngle=light.InnerAngle
  95. OuterAngle=light.OuterAngle
  96. AddInstance( light )
  97. End
  98. Method OnCopy:Light( parent:Entity ) Override
  99. Return New Light( Self,parent )
  100. End
  101. Method OnShow() Override
  102. Scene.Lights.Add( Self )
  103. End
  104. Method OnHide() Override
  105. Scene.Lights.Remove( Self )
  106. End
  107. Private
  108. Field _type:LightType
  109. Field _texture:Texture
  110. Field _color:Color
  111. Field _range:Float
  112. Field _innerAngle:Float
  113. Field _outerAngle:Float
  114. Field _castsShadow:bool
  115. End