Scene.lua 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 = Polycode.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 Polycode.Scene_get_useClearColor(self.__ptr)
  15. elseif name == "useClearDepth" then
  16. return Polycode.Scene_get_useClearDepth(self.__ptr)
  17. elseif name == "ambientColor" then
  18. local retVal = Polycode.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 = Polycode.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 Polycode.Scene_get_enabled(self.__ptr)
  31. elseif name == "ownsChildren" then
  32. return Polycode.Scene_get_ownsChildren(self.__ptr)
  33. elseif name == "rootEntity" then
  34. local retVal = Polycode.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 = Polycode.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 Polycode.Scene_get_remapMouse(self.__ptr)
  47. elseif name == "constrainPickingToViewport" then
  48. return Polycode.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. Polycode.Scene_set_clearColor(self.__ptr, value.__ptr)
  57. return true
  58. elseif name == "useClearColor" then
  59. Polycode.Scene_set_useClearColor(self.__ptr, value)
  60. return true
  61. elseif name == "useClearDepth" then
  62. Polycode.Scene_set_useClearDepth(self.__ptr, value)
  63. return true
  64. elseif name == "ambientColor" then
  65. Polycode.Scene_set_ambientColor(self.__ptr, value.__ptr)
  66. return true
  67. elseif name == "fogColor" then
  68. Polycode.Scene_set_fogColor(self.__ptr, value.__ptr)
  69. return true
  70. elseif name == "enabled" then
  71. Polycode.Scene_set_enabled(self.__ptr, value)
  72. return true
  73. elseif name == "ownsChildren" then
  74. Polycode.Scene_set_ownsChildren(self.__ptr, value)
  75. return true
  76. elseif name == "rootEntity" then
  77. Polycode.Scene_set_rootEntity(self.__ptr, value.__ptr)
  78. return true
  79. elseif name == "sceneMouseRect" then
  80. Polycode.Scene_set_sceneMouseRect(self.__ptr, value.__ptr)
  81. return true
  82. elseif name == "remapMouse" then
  83. Polycode.Scene_set_remapMouse(self.__ptr, value)
  84. return true
  85. elseif name == "constrainPickingToViewport" then
  86. Polycode.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 = Polycode.Scene(unpack(arg))
  112. end
  113. end
  114. function Scene:enableFog(enable)
  115. local retVal = Polycode.Scene_enableFog(self.__ptr, enable)
  116. end
  117. function Scene:setFogProperties(fogMode, color, density, startDepth, endDepth)
  118. local retVal = Polycode.Scene_setFogProperties(self.__ptr, fogMode, color.__ptr, density, startDepth, endDepth)
  119. end
  120. function Scene:setSceneType(newType)
  121. local retVal = Polycode.Scene_setSceneType(self.__ptr, newType)
  122. end
  123. function Scene:fixedUpdate()
  124. local retVal = Polycode.Scene_fixedUpdate(self.__ptr)
  125. end
  126. function Scene:Update(elapsed)
  127. local retVal = Polycode.Scene_Update(self.__ptr, elapsed)
  128. end
  129. function Scene:isEnabled()
  130. local retVal = Polycode.Scene_isEnabled(self.__ptr)
  131. return retVal
  132. end
  133. function Scene:setEnabled(enabled)
  134. local retVal = Polycode.Scene_setEnabled(self.__ptr, enabled)
  135. end
  136. function Scene:setOverrideMaterial(material)
  137. local retVal = Polycode.Scene_setOverrideMaterial(self.__ptr, material.__ptr)
  138. end
  139. function Scene:doVisibilityChecking(val)
  140. local retVal = Polycode.Scene_doVisibilityChecking(self.__ptr, val)
  141. end
  142. function Scene:doesVisibilityChecking()
  143. local retVal = Polycode.Scene_doesVisibilityChecking(self.__ptr)
  144. return retVal
  145. end
  146. function Scene:__delete()
  147. if self then Polycode.delete_Scene(self.__ptr) end
  148. end