SceneLight.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. require "Polycode/SceneEntity"
  2. class "SceneLight" (SceneEntity)
  3. AREA_LIGHT = 0
  4. SPOT_LIGHT = 1
  5. function SceneLight:SceneLight(...)
  6. if type(arg[1]) == "table" and count(arg) == 1 then
  7. if ""..arg[1]:class() == "SceneEntity" then
  8. self.__ptr = arg[1].__ptr
  9. return
  10. end
  11. end
  12. for k,v in pairs(arg) do
  13. if type(v) == "table" then
  14. if v.__ptr ~= nil then
  15. arg[k] = v.__ptr
  16. end
  17. end
  18. end
  19. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  20. self.__ptr = Polycore.SceneLight(unpack(arg))
  21. Polycore.__ptr_lookup[self.__ptr] = self
  22. end
  23. end
  24. function SceneLight:getIntensity()
  25. local retVal = Polycore.SceneLight_getIntensity(self.__ptr)
  26. return retVal
  27. end
  28. function SceneLight:getConstantAttenuation()
  29. local retVal = Polycore.SceneLight_getConstantAttenuation(self.__ptr)
  30. return retVal
  31. end
  32. function SceneLight:getLinearAttenuation()
  33. local retVal = Polycore.SceneLight_getLinearAttenuation(self.__ptr)
  34. return retVal
  35. end
  36. function SceneLight:getQuadraticAttenuation()
  37. local retVal = Polycore.SceneLight_getQuadraticAttenuation(self.__ptr)
  38. return retVal
  39. end
  40. function SceneLight:getType()
  41. local retVal = Polycore.SceneLight_getType(self.__ptr)
  42. return retVal
  43. end
  44. function SceneLight:renderDepthMap(scene)
  45. local retVal = Polycore.SceneLight_renderDepthMap(self.__ptr, scene.__ptr)
  46. end
  47. function SceneLight:Render()
  48. local retVal = Polycore.SceneLight_Render(self.__ptr)
  49. end
  50. function SceneLight:getLightViewMatrix()
  51. local retVal = Polycore.SceneLight_getLightViewMatrix(self.__ptr)
  52. if Polycore.__ptr_lookup[retVal] ~= nil then
  53. return Polycore.__ptr_lookup[retVal]
  54. else
  55. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  56. Polycore.__ptr_lookup[retVal].__ptr = retVal
  57. return Polycore.__ptr_lookup[retVal]
  58. end
  59. end
  60. function SceneLight:getZBufferTexture()
  61. local retVal = Polycore.SceneLight_getZBufferTexture(self.__ptr)
  62. if Polycore.__ptr_lookup[retVal] ~= nil then
  63. return Polycore.__ptr_lookup[retVal]
  64. else
  65. Polycore.__ptr_lookup[retVal] = Texture("__skip_ptr__")
  66. Polycore.__ptr_lookup[retVal].__ptr = retVal
  67. return Polycore.__ptr_lookup[retVal]
  68. end
  69. end
  70. function SceneLight:setLightColor(r, g, b)
  71. local retVal = Polycore.SceneLight_setLightColor(self.__ptr, r, g, b)
  72. end
  73. function SceneLight:setSpotlightProperties(spotlightCutoff, spotlightExponent)
  74. local retVal = Polycore.SceneLight_setSpotlightProperties(self.__ptr, spotlightCutoff, spotlightExponent)
  75. end
  76. function SceneLight:getSpotlightCutoff()
  77. local retVal = Polycore.SceneLight_getSpotlightCutoff(self.__ptr)
  78. return retVal
  79. end
  80. function SceneLight:getSpotlightExponent()
  81. local retVal = Polycore.SceneLight_getSpotlightExponent(self.__ptr)
  82. return retVal
  83. end
  84. function SceneLight:enableShadows(val, resolution)
  85. local retVal = Polycore.SceneLight_enableShadows(self.__ptr, val, resolution)
  86. end
  87. function SceneLight:setShadowMapFOV(fov)
  88. local retVal = Polycore.SceneLight_setShadowMapFOV(self.__ptr, fov)
  89. end
  90. function SceneLight:areShadowsEnabled()
  91. local retVal = Polycore.SceneLight_areShadowsEnabled(self.__ptr)
  92. return retVal
  93. end
  94. function SceneLight:getLightType()
  95. local retVal = Polycore.SceneLight_getLightType(self.__ptr)
  96. return retVal
  97. end
  98. function SceneLight:__delete()
  99. Polycore.__ptr_lookup[self.__ptr] = nil
  100. Polycore.delete_SceneLight(self.__ptr)
  101. end