2
0

SceneLight.lua 3.7 KB

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