SceneLight.lua 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. require "Polycode/SceneEntity"
  2. class "SceneLight" (SceneEntity)
  3. AREA_LIGHT = 0
  4. SPOT_LIGHT = 1
  5. function SceneLight:__index__(name)
  6. if name == "specularLightColor" then
  7. retVal = Polycore.SceneLight_get_specularLightColor(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. elseif name == "lightColor" then
  16. retVal = Polycore.SceneLight_get_lightColor(self.__ptr)
  17. if Polycore.__ptr_lookup[retVal] ~= nil then
  18. return Polycore.__ptr_lookup[retVal]
  19. else
  20. Polycore.__ptr_lookup[retVal] = Color("__skip_ptr__")
  21. Polycore.__ptr_lookup[retVal].__ptr = retVal
  22. return Polycore.__ptr_lookup[retVal]
  23. end
  24. end
  25. end
  26. function SceneLight:__set_callback(name,value)
  27. return false
  28. end
  29. function SceneLight:SceneLight(...)
  30. if type(arg[1]) == "table" and count(arg) == 1 then
  31. if ""..arg[1]:class() == "SceneEntity" then
  32. self.__ptr = arg[1].__ptr
  33. return
  34. end
  35. end
  36. for k,v in pairs(arg) do
  37. if type(v) == "table" then
  38. if v.__ptr ~= nil then
  39. arg[k] = v.__ptr
  40. end
  41. end
  42. end
  43. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  44. self.__ptr = Polycore.SceneLight(unpack(arg))
  45. Polycore.__ptr_lookup[self.__ptr] = self
  46. end
  47. end
  48. function SceneLight:getIntensity()
  49. local retVal = Polycore.SceneLight_getIntensity(self.__ptr)
  50. return retVal
  51. end
  52. function SceneLight:setIntensity(newIntensity)
  53. local retVal = Polycore.SceneLight_setIntensity(self.__ptr, newIntensity)
  54. end
  55. function SceneLight:setAttenuation(constantAttenuation, linearAttenuation, quadraticAttenuation)
  56. local retVal = Polycore.SceneLight_setAttenuation(self.__ptr, constantAttenuation, linearAttenuation, quadraticAttenuation)
  57. end
  58. function SceneLight:getConstantAttenuation()
  59. local retVal = Polycore.SceneLight_getConstantAttenuation(self.__ptr)
  60. return retVal
  61. end
  62. function SceneLight:getLinearAttenuation()
  63. local retVal = Polycore.SceneLight_getLinearAttenuation(self.__ptr)
  64. return retVal
  65. end
  66. function SceneLight:getQuadraticAttenuation()
  67. local retVal = Polycore.SceneLight_getQuadraticAttenuation(self.__ptr)
  68. return retVal
  69. end
  70. function SceneLight:getType()
  71. local retVal = Polycore.SceneLight_getType(self.__ptr)
  72. return retVal
  73. end
  74. function SceneLight:renderDepthMap(scene)
  75. local retVal = Polycore.SceneLight_renderDepthMap(self.__ptr, scene.__ptr)
  76. end
  77. function SceneLight:Render()
  78. local retVal = Polycore.SceneLight_Render(self.__ptr)
  79. end
  80. function SceneLight:getLightViewMatrix()
  81. local retVal = Polycore.SceneLight_getLightViewMatrix(self.__ptr)
  82. if retVal == nil then return nil end
  83. if Polycore.__ptr_lookup[retVal] ~= nil then
  84. return Polycore.__ptr_lookup[retVal]
  85. else
  86. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  87. Polycore.__ptr_lookup[retVal].__ptr = retVal
  88. return Polycore.__ptr_lookup[retVal]
  89. end
  90. end
  91. function SceneLight:getZBufferTexture()
  92. local retVal = Polycore.SceneLight_getZBufferTexture(self.__ptr)
  93. if retVal == nil then return nil end
  94. if Polycore.__ptr_lookup[retVal] ~= nil then
  95. return Polycore.__ptr_lookup[retVal]
  96. else
  97. Polycore.__ptr_lookup[retVal] = Texture("__skip_ptr__")
  98. Polycore.__ptr_lookup[retVal].__ptr = retVal
  99. return Polycore.__ptr_lookup[retVal]
  100. end
  101. end
  102. function SceneLight:setSpecularLightColor(r, g, b, a)
  103. local retVal = Polycore.SceneLight_setSpecularLightColor(self.__ptr, r, g, b, a)
  104. end
  105. function SceneLight:setDiffuseLightColor(r, g, b)
  106. local retVal = Polycore.SceneLight_setDiffuseLightColor(self.__ptr, r, g, b)
  107. end
  108. function SceneLight:setLightColor(r, g, b, a)
  109. local retVal = Polycore.SceneLight_setLightColor(self.__ptr, r, g, b, a)
  110. end
  111. function SceneLight:setSpotlightProperties(spotlightCutoff, spotlightExponent)
  112. local retVal = Polycore.SceneLight_setSpotlightProperties(self.__ptr, spotlightCutoff, spotlightExponent)
  113. end
  114. function SceneLight:getSpotlightCutoff()
  115. local retVal = Polycore.SceneLight_getSpotlightCutoff(self.__ptr)
  116. return retVal
  117. end
  118. function SceneLight:getSpotlightExponent()
  119. local retVal = Polycore.SceneLight_getSpotlightExponent(self.__ptr)
  120. return retVal
  121. end
  122. function SceneLight:enableShadows(val, resolution)
  123. local retVal = Polycore.SceneLight_enableShadows(self.__ptr, val, resolution)
  124. end
  125. function SceneLight:setShadowMapFOV(fov)
  126. local retVal = Polycore.SceneLight_setShadowMapFOV(self.__ptr, fov)
  127. end
  128. function SceneLight:areShadowsEnabled()
  129. local retVal = Polycore.SceneLight_areShadowsEnabled(self.__ptr)
  130. return retVal
  131. end
  132. function SceneLight:getLightType()
  133. local retVal = Polycore.SceneLight_getLightType(self.__ptr)
  134. return retVal
  135. end
  136. function SceneLight:enableDebugDraw(val)
  137. local retVal = Polycore.SceneLight_enableDebugDraw(self.__ptr, val)
  138. end
  139. function SceneLight:setLightImportance(newImportance)
  140. local retVal = Polycore.SceneLight_setLightImportance(self.__ptr, newImportance)
  141. end
  142. function SceneLight:getLightImportance()
  143. local retVal = Polycore.SceneLight_getLightImportance(self.__ptr)
  144. return retVal
  145. end
  146. function SceneLight:__delete()
  147. Polycore.__ptr_lookup[self.__ptr] = nil
  148. Polycore.delete_SceneLight(self.__ptr)
  149. end