Scene.lua 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. require "Polycode/EventDispatcher"
  2. class "Scene" (EventDispatcher)
  3. Scene.SCENE_3D = 0
  4. Scene.SCENE_2D = 1
  5. Scene.SCENE_2D_TOPLEFT = 2
  6. function Scene:__getvar(name)
  7. if name == "clearColor" then
  8. local retVal = Polycore.Scene_get_clearColor(self.__ptr)
  9. if retVal == nil then return nil end
  10. local __c = _G["Color"]("__skip_ptr__")
  11. __c.__ptr = retVal
  12. return __c
  13. elseif name == "useClearColor" then
  14. return Polycore.Scene_get_useClearColor(self.__ptr)
  15. elseif name == "useClearDepth" then
  16. return Polycore.Scene_get_useClearDepth(self.__ptr)
  17. elseif name == "ambientColor" then
  18. local retVal = Polycore.Scene_get_ambientColor(self.__ptr)
  19. if retVal == nil then return nil end
  20. local __c = _G["Color"]("__skip_ptr__")
  21. __c.__ptr = retVal
  22. return __c
  23. elseif name == "fogColor" then
  24. local retVal = Polycore.Scene_get_fogColor(self.__ptr)
  25. if retVal == nil then return nil end
  26. local __c = _G["Color"]("__skip_ptr__")
  27. __c.__ptr = retVal
  28. return __c
  29. elseif name == "enabled" then
  30. return Polycore.Scene_get_enabled(self.__ptr)
  31. elseif name == "ownsChildren" then
  32. return Polycore.Scene_get_ownsChildren(self.__ptr)
  33. elseif name == "rootEntity" then
  34. local retVal = Polycore.Scene_get_rootEntity(self.__ptr)
  35. if retVal == nil then return nil end
  36. local __c = _G["Entity"]("__skip_ptr__")
  37. __c.__ptr = retVal
  38. return __c
  39. elseif name == "sceneMouseRect" then
  40. local retVal = Polycore.Scene_get_sceneMouseRect(self.__ptr)
  41. if retVal == nil then return nil end
  42. local __c = _G["Rectangle"]("__skip_ptr__")
  43. __c.__ptr = retVal
  44. return __c
  45. elseif name == "remapMouse" then
  46. return Polycore.Scene_get_remapMouse(self.__ptr)
  47. elseif name == "constrainPickingToViewport" then
  48. return Polycore.Scene_get_constrainPickingToViewport(self.__ptr)
  49. end
  50. if EventDispatcher["__getvar"] ~= nil then
  51. return EventDispatcher.__getvar(self, name)
  52. end
  53. end
  54. function Scene:__setvar(name,value)
  55. if name == "clearColor" then
  56. Polycore.Scene_set_clearColor(self.__ptr, value.__ptr)
  57. return true
  58. elseif name == "useClearColor" then
  59. Polycore.Scene_set_useClearColor(self.__ptr, value)
  60. return true
  61. elseif name == "useClearDepth" then
  62. Polycore.Scene_set_useClearDepth(self.__ptr, value)
  63. return true
  64. elseif name == "ambientColor" then
  65. Polycore.Scene_set_ambientColor(self.__ptr, value.__ptr)
  66. return true
  67. elseif name == "fogColor" then
  68. Polycore.Scene_set_fogColor(self.__ptr, value.__ptr)
  69. return true
  70. elseif name == "enabled" then
  71. Polycore.Scene_set_enabled(self.__ptr, value)
  72. return true
  73. elseif name == "ownsChildren" then
  74. Polycore.Scene_set_ownsChildren(self.__ptr, value)
  75. return true
  76. elseif name == "rootEntity" then
  77. Polycore.Scene_set_rootEntity(self.__ptr, value.__ptr)
  78. return true
  79. elseif name == "sceneMouseRect" then
  80. Polycore.Scene_set_sceneMouseRect(self.__ptr, value.__ptr)
  81. return true
  82. elseif name == "remapMouse" then
  83. Polycore.Scene_set_remapMouse(self.__ptr, value)
  84. return true
  85. elseif name == "constrainPickingToViewport" then
  86. Polycore.Scene_set_constrainPickingToViewport(self.__ptr, value)
  87. return true
  88. end
  89. if EventDispatcher["__setvar"] ~= nil then
  90. return EventDispatcher.__setvar(self, name, value)
  91. else
  92. return false
  93. end
  94. end
  95. function Scene:Scene(...)
  96. local arg = {...}
  97. if type(arg[1]) == "table" and count(arg) == 1 then
  98. if ""..arg[1].__classname == "EventDispatcher" then
  99. self.__ptr = arg[1].__ptr
  100. return
  101. end
  102. end
  103. for k,v in pairs(arg) do
  104. if type(v) == "table" then
  105. if v.__ptr ~= nil then
  106. arg[k] = v.__ptr
  107. end
  108. end
  109. end
  110. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  111. self.__ptr = Polycore.Scene(unpack(arg))
  112. end
  113. end
  114. function Scene:addEntity(entity)
  115. local retVal = Polycore.Scene_addEntity(self.__ptr, entity.__ptr)
  116. end
  117. function Scene:addChild(entity)
  118. local retVal = Polycore.Scene_addChild(self.__ptr, entity.__ptr)
  119. end
  120. function Scene:removeEntity(entity)
  121. local retVal = Polycore.Scene_removeEntity(self.__ptr, entity.__ptr)
  122. end
  123. function Scene:getDefaultCamera()
  124. local retVal = Polycore.Scene_getDefaultCamera(self.__ptr)
  125. if retVal == nil then return nil end
  126. local __c = _G["Camera"]("__skip_ptr__")
  127. __c.__ptr = retVal
  128. return __c
  129. end
  130. function Scene:getActiveCamera()
  131. local retVal = Polycore.Scene_getActiveCamera(self.__ptr)
  132. if retVal == nil then return nil end
  133. local __c = _G["Camera"]("__skip_ptr__")
  134. __c.__ptr = retVal
  135. return __c
  136. end
  137. function Scene:setActiveCamera(camera)
  138. local retVal = Polycore.Scene_setActiveCamera(self.__ptr, camera.__ptr)
  139. end
  140. function Scene:enableFog(enable)
  141. local retVal = Polycore.Scene_enableFog(self.__ptr, enable)
  142. end
  143. function Scene:setFogProperties(fogMode, color, density, startDepth, _endDepth)
  144. local retVal = Polycore.Scene_setFogProperties(self.__ptr, fogMode, color.__ptr, density, startDepth, _endDepth)
  145. end
  146. function Scene:setSceneType(newType)
  147. local retVal = Polycore.Scene_setSceneType(self.__ptr, newType)
  148. end
  149. function Scene:fixedUpdate()
  150. local retVal = Polycore.Scene_fixedUpdate(self.__ptr)
  151. end
  152. function Scene:Update()
  153. local retVal = Polycore.Scene_Update(self.__ptr)
  154. end
  155. function Scene:setVirtual(val)
  156. local retVal = Polycore.Scene_setVirtual(self.__ptr, val)
  157. end
  158. function Scene:isVirtual()
  159. local retVal = Polycore.Scene_isVirtual(self.__ptr)
  160. return retVal
  161. end
  162. function Scene:isEnabled()
  163. local retVal = Polycore.Scene_isEnabled(self.__ptr)
  164. return retVal
  165. end
  166. function Scene:setEnabled(enabled)
  167. local retVal = Polycore.Scene_setEnabled(self.__ptr, enabled)
  168. end
  169. function Scene:Render(targetCamera, targetFramebuffer, overrideMaterial, s_endLights)
  170. local retVal = Polycore.Scene_Render(self.__ptr, targetCamera.__ptr, targetFramebuffer.__ptr, overrideMaterial.__ptr, s_endLights)
  171. end
  172. function Scene:setOverrideMaterial(material)
  173. local retVal = Polycore.Scene_setOverrideMaterial(self.__ptr, material.__ptr)
  174. end
  175. function Scene:projectRayFromCameraAndViewportCoordinate(camera, coordinate)
  176. local retVal = Polycore.Scene_projectRayFromCameraAndViewportCoordinate(self.__ptr, camera.__ptr, coordinate.__ptr)
  177. if retVal == nil then return nil end
  178. local __c = _G["Ray"]("__skip_ptr__")
  179. __c.__ptr = retVal
  180. return __c
  181. end
  182. function Scene:addLight(light)
  183. local retVal = Polycore.Scene_addLight(self.__ptr, light.__ptr)
  184. end
  185. function Scene:removeLight(light)
  186. local retVal = Polycore.Scene_removeLight(self.__ptr, light.__ptr)
  187. end
  188. function Scene:getNumLights()
  189. local retVal = Polycore.Scene_getNumLights(self.__ptr)
  190. return retVal
  191. end
  192. function Scene:getLight(index)
  193. local retVal = Polycore.Scene_getLight(self.__ptr, index)
  194. if retVal == nil then return nil end
  195. local __c = _G["SceneLight"]("__skip_ptr__")
  196. __c.__ptr = retVal
  197. return __c
  198. end
  199. function Scene:doVisibilityChecking(val)
  200. local retVal = Polycore.Scene_doVisibilityChecking(self.__ptr, val)
  201. end
  202. function Scene:doesVisibilityChecking()
  203. local retVal = Polycore.Scene_doesVisibilityChecking(self.__ptr)
  204. return retVal
  205. end
  206. function Scene:__delete()
  207. if self then Polycore.delete_Scene(self.__ptr) end
  208. end