Scene.lua 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. require "Polycode/EventDispatcher"
  2. class "Scene" (EventDispatcher)
  3. ENTITY_MESH = 0
  4. ENTITY_LIGHT = 1
  5. ENTITY_CAMERA = 2
  6. ENTITY_ENTITY = 3
  7. ENTITY_COLLMESH = 4
  8. function Scene:Scene(...)
  9. for k,v in pairs(arg) do
  10. if type(v) == "table" then
  11. if v.__ptr ~= nil then
  12. arg[k] = v.__ptr
  13. end
  14. end
  15. end
  16. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  17. self.__ptr = Polycore.Scene(unpack(arg))
  18. end
  19. end
  20. function Scene:addEntity(entity)
  21. local retVal = Polycore.Scene_addEntity(self.__ptr, entity.__ptr)
  22. end
  23. function Scene:removeEntity(entity)
  24. local retVal = Polycore.Scene_removeEntity(self.__ptr, entity.__ptr)
  25. end
  26. function Scene:getDefaultCamera()
  27. local retVal = Polycore.Scene_getDefaultCamera(self.__ptr)
  28. if Polycore.__ptr_lookup[retVal] ~= nil then
  29. return Polycore.__ptr_lookup[retVal]
  30. else
  31. Polycore.__ptr_lookup[retVal] = Camera("__skip_ptr__")
  32. Polycore.__ptr_lookup[retVal].__ptr = retVal
  33. return Polycore.__ptr_lookup[retVal]
  34. end
  35. end
  36. function Scene:enableLighting(enable)
  37. local retVal = Polycore.Scene_enableLighting(self.__ptr, enable)
  38. end
  39. function Scene:enableFog(enable)
  40. local retVal = Polycore.Scene_enableFog(self.__ptr, enable)
  41. end
  42. function Scene:setFogProperties(fogMode, color, density, startDepth, _endDepth)
  43. local retVal = Polycore.Scene_setFogProperties(self.__ptr, fogMode, color.__ptr, density, startDepth, _endDepth)
  44. end
  45. function Scene:Update()
  46. local retVal = Polycore.Scene_Update(self.__ptr)
  47. end
  48. function Scene:setVirtual(val)
  49. local retVal = Polycore.Scene_setVirtual(self.__ptr, val)
  50. end
  51. function Scene:isVirtual()
  52. local retVal = Polycore.Scene_isVirtual(self.__ptr)
  53. return retVal
  54. end
  55. function Scene:isEnabled()
  56. local retVal = Polycore.Scene_isEnabled(self.__ptr)
  57. return retVal
  58. end
  59. function Scene:setEnabled(enabled)
  60. local retVal = Polycore.Scene_setEnabled(self.__ptr, enabled)
  61. end
  62. function Scene:getNumEntities()
  63. local retVal = Polycore.Scene_getNumEntities(self.__ptr)
  64. return retVal
  65. end
  66. function Scene:getEntity(index)
  67. local retVal = Polycore.Scene_getEntity(self.__ptr, index)
  68. if Polycore.__ptr_lookup[retVal] ~= nil then
  69. return Polycore.__ptr_lookup[retVal]
  70. else
  71. Polycore.__ptr_lookup[retVal] = SceneEntity("__skip_ptr__")
  72. Polycore.__ptr_lookup[retVal].__ptr = retVal
  73. return Polycore.__ptr_lookup[retVal]
  74. end
  75. end
  76. function Scene:getEntityAtCursor(x, y)
  77. local retVal = Polycore.Scene_getEntityAtCursor(self.__ptr, x, y)
  78. if Polycore.__ptr_lookup[retVal] ~= nil then
  79. return Polycore.__ptr_lookup[retVal]
  80. else
  81. Polycore.__ptr_lookup[retVal] = SceneEntity("__skip_ptr__")
  82. Polycore.__ptr_lookup[retVal].__ptr = retVal
  83. return Polycore.__ptr_lookup[retVal]
  84. end
  85. end
  86. function Scene:Render()
  87. local retVal = Polycore.Scene_Render(self.__ptr)
  88. end
  89. function Scene:RenderDepthOnly(targetCamera)
  90. local retVal = Polycore.Scene_RenderDepthOnly(self.__ptr, targetCamera.__ptr)
  91. end
  92. function Scene:readString(inFile)
  93. local retVal = Polycore.Scene_readString(inFile.__ptr)
  94. return retVal
  95. end
  96. function Scene:loadScene(fileName)
  97. local retVal = Polycore.Scene_loadScene(self.__ptr, fileName)
  98. end
  99. function Scene:generateLightmaps(lightMapRes, lightMapQuality, numRadPasses)
  100. local retVal = Polycore.Scene_generateLightmaps(self.__ptr, lightMapRes, lightMapQuality, numRadPasses)
  101. end
  102. function Scene:addLight(light)
  103. local retVal = Polycore.Scene_addLight(self.__ptr, light.__ptr)
  104. end
  105. function Scene:getNearestLight(pos)
  106. local retVal = Polycore.Scene_getNearestLight(self.__ptr, pos.__ptr)
  107. if Polycore.__ptr_lookup[retVal] ~= nil then
  108. return Polycore.__ptr_lookup[retVal]
  109. else
  110. Polycore.__ptr_lookup[retVal] = SceneLight("__skip_ptr__")
  111. Polycore.__ptr_lookup[retVal].__ptr = retVal
  112. return Polycore.__ptr_lookup[retVal]
  113. end
  114. end
  115. function Scene:writeEntityMatrix(entity, outFile)
  116. local retVal = Polycore.Scene_writeEntityMatrix(self.__ptr, entity.__ptr, outFile.__ptr)
  117. end
  118. function Scene:writeString(str, outFile)
  119. local retVal = Polycore.Scene_writeString(self.__ptr, str, outFile.__ptr)
  120. end
  121. function Scene:saveScene(fileName)
  122. local retVal = Polycore.Scene_saveScene(self.__ptr, fileName)
  123. end
  124. function Scene:getNumStaticGeometry()
  125. local retVal = Polycore.Scene_getNumStaticGeometry(self.__ptr)
  126. return retVal
  127. end
  128. function Scene:getStaticGeometry(index)
  129. local retVal = Polycore.Scene_getStaticGeometry(self.__ptr, index)
  130. if Polycore.__ptr_lookup[retVal] ~= nil then
  131. return Polycore.__ptr_lookup[retVal]
  132. else
  133. Polycore.__ptr_lookup[retVal] = SceneMesh("__skip_ptr__")
  134. Polycore.__ptr_lookup[retVal].__ptr = retVal
  135. return Polycore.__ptr_lookup[retVal]
  136. end
  137. end
  138. function Scene:loadCollisionChild(entity, autoCollide, type)
  139. local retVal = Polycore.Scene_loadCollisionChild(self.__ptr, entity.__ptr, autoCollide, type)
  140. end
  141. function Scene:getNumLights()
  142. local retVal = Polycore.Scene_getNumLights(self.__ptr)
  143. return retVal
  144. end
  145. function Scene:getLight(index)
  146. local retVal = Polycore.Scene_getLight(self.__ptr, index)
  147. if Polycore.__ptr_lookup[retVal] ~= nil then
  148. return Polycore.__ptr_lookup[retVal]
  149. else
  150. Polycore.__ptr_lookup[retVal] = SceneLight("__skip_ptr__")
  151. Polycore.__ptr_lookup[retVal].__ptr = retVal
  152. return Polycore.__ptr_lookup[retVal]
  153. end
  154. end
  155. function Scene:getCustomEntityByType(type)
  156. local retVal = Polycore.Scene_getCustomEntityByType(self.__ptr, type)
  157. if Polycore.__ptr_lookup[retVal] ~= nil then
  158. return Polycore.__ptr_lookup[retVal]
  159. else
  160. Polycore.__ptr_lookup[retVal] = SceneEntity("__skip_ptr__")
  161. Polycore.__ptr_lookup[retVal].__ptr = retVal
  162. return Polycore.__ptr_lookup[retVal]
  163. end
  164. end