GenericScene.lua 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. require "Polycode/Scene"
  2. class "GenericScene" (Scene)
  3. ENTITY_MESH = 0
  4. ENTITY_LIGHT = 1
  5. ENTITY_CAMERA = 2
  6. ENTITY_ENTITY = 3
  7. ENTITY_COLLMESH = 4
  8. function GenericScene:GenericScene(...)
  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.GenericScene(unpack(arg))
  18. end
  19. end
  20. function GenericScene:Render()
  21. local retVal = Polycore.GenericScene_Render(self.__ptr)
  22. end
  23. function GenericScene:RenderDepthOnly(targetCamera)
  24. local retVal = Polycore.GenericScene_RenderDepthOnly(self.__ptr, targetCamera.__ptr)
  25. end
  26. function GenericScene:addGrid(gridTexture)
  27. local retVal = Polycore.GenericScene_addGrid(self.__ptr, gridTexture)
  28. end
  29. function GenericScene:readString(inFile)
  30. local retVal = Polycore.GenericScene_readString(inFile.__ptr)
  31. return retVal
  32. end
  33. function GenericScene:loadScene(fileName)
  34. local retVal = Polycore.GenericScene_loadScene(self.__ptr, fileName)
  35. end
  36. function GenericScene:generateLightmaps(lightMapRes, lightMapQuality, numRadPasses)
  37. local retVal = Polycore.GenericScene_generateLightmaps(self.__ptr, lightMapRes, lightMapQuality, numRadPasses)
  38. end
  39. function GenericScene:addLight(light)
  40. local retVal = Polycore.GenericScene_addLight(self.__ptr, light.__ptr)
  41. end
  42. function GenericScene:getNearestLight(pos)
  43. local retVal = Polycore.GenericScene_getNearestLight(self.__ptr, pos.__ptr)
  44. if Polycore.__ptr_lookup[retVal] ~= nil then
  45. return Polycore.__ptr_lookup[retVal]
  46. else
  47. Polycore.__ptr_lookup[retVal] = SceneLight("__skip_ptr__")
  48. Polycore.__ptr_lookup[retVal].__ptr = retVal
  49. return Polycore.__ptr_lookup[retVal]
  50. end
  51. end
  52. function GenericScene:writeEntityMatrix(entity, outFile)
  53. local retVal = Polycore.GenericScene_writeEntityMatrix(self.__ptr, entity.__ptr, outFile.__ptr)
  54. end
  55. function GenericScene:writeString(str, outFile)
  56. local retVal = Polycore.GenericScene_writeString(self.__ptr, str, outFile.__ptr)
  57. end
  58. function GenericScene:saveScene(fileName)
  59. local retVal = Polycore.GenericScene_saveScene(self.__ptr, fileName)
  60. end
  61. function GenericScene:getNumStaticGeometry()
  62. local retVal = Polycore.GenericScene_getNumStaticGeometry(self.__ptr)
  63. return retVal
  64. end
  65. function GenericScene:getStaticGeometry(index)
  66. local retVal = Polycore.GenericScene_getStaticGeometry(self.__ptr, index)
  67. if Polycore.__ptr_lookup[retVal] ~= nil then
  68. return Polycore.__ptr_lookup[retVal]
  69. else
  70. Polycore.__ptr_lookup[retVal] = SceneMesh("__skip_ptr__")
  71. Polycore.__ptr_lookup[retVal].__ptr = retVal
  72. return Polycore.__ptr_lookup[retVal]
  73. end
  74. end
  75. function GenericScene:loadCollisionChild(entity, autoCollide, type)
  76. local retVal = Polycore.GenericScene_loadCollisionChild(self.__ptr, entity.__ptr, autoCollide, type)
  77. end
  78. function GenericScene:getNumLights()
  79. local retVal = Polycore.GenericScene_getNumLights(self.__ptr)
  80. return retVal
  81. end
  82. function GenericScene:getLight(index)
  83. local retVal = Polycore.GenericScene_getLight(self.__ptr, index)
  84. if Polycore.__ptr_lookup[retVal] ~= nil then
  85. return Polycore.__ptr_lookup[retVal]
  86. else
  87. Polycore.__ptr_lookup[retVal] = SceneLight("__skip_ptr__")
  88. Polycore.__ptr_lookup[retVal].__ptr = retVal
  89. return Polycore.__ptr_lookup[retVal]
  90. end
  91. end
  92. function GenericScene:getCustomEntityByType(type)
  93. local retVal = Polycore.GenericScene_getCustomEntityByType(self.__ptr, type)
  94. if Polycore.__ptr_lookup[retVal] ~= nil then
  95. return Polycore.__ptr_lookup[retVal]
  96. else
  97. Polycore.__ptr_lookup[retVal] = SceneEntity("__skip_ptr__")
  98. Polycore.__ptr_lookup[retVal].__ptr = retVal
  99. return Polycore.__ptr_lookup[retVal]
  100. end
  101. end