Camera.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. require "Polycode/SceneEntity"
  2. class "Camera" (SceneEntity)
  3. function Camera:Camera(...)
  4. if type(arg[1]) == "table" and count(arg) == 1 then
  5. if ""..arg[1]:class() == "SceneEntity" then
  6. self.__ptr = arg[1].__ptr
  7. return
  8. end
  9. end
  10. for k,v in pairs(arg) do
  11. if type(v) == "table" then
  12. if v.__ptr ~= nil then
  13. arg[k] = v.__ptr
  14. end
  15. end
  16. end
  17. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  18. self.__ptr = Polycore.Camera(unpack(arg))
  19. Polycore.__ptr_lookup[self.__ptr] = self
  20. end
  21. end
  22. function Camera:buildFrustrumPlanes()
  23. local retVal = Polycore.Camera_buildFrustrumPlanes(self.__ptr)
  24. end
  25. function Camera:isSphereInFrustrum(pos, fRadius)
  26. local retVal = Polycore.Camera_isSphereInFrustrum(self.__ptr, pos.__ptr, fRadius)
  27. return retVal
  28. end
  29. function Camera:canSee(entity)
  30. local retVal = Polycore.Camera_canSee(self.__ptr, entity.__ptr)
  31. return retVal
  32. end
  33. function Camera:setOrthoMode(mode)
  34. local retVal = Polycore.Camera_setOrthoMode(self.__ptr, mode)
  35. end
  36. function Camera:getOrthoMode()
  37. local retVal = Polycore.Camera_getOrthoMode(self.__ptr)
  38. return retVal
  39. end
  40. function Camera:setFOV(fov)
  41. local retVal = Polycore.Camera_setFOV(self.__ptr, fov)
  42. end
  43. function Camera:getFOV()
  44. local retVal = Polycore.Camera_getFOV(self.__ptr)
  45. return retVal
  46. end
  47. function Camera:setParentScene(parentScene)
  48. local retVal = Polycore.Camera_setParentScene(self.__ptr, parentScene.__ptr)
  49. end
  50. function Camera:doCameraTransform()
  51. local retVal = Polycore.Camera_doCameraTransform(self.__ptr)
  52. end
  53. function Camera:setLightDepthTexture(texture)
  54. local retVal = Polycore.Camera_setLightDepthTexture(self.__ptr, texture.__ptr)
  55. end
  56. function Camera:hasFilterShader()
  57. local retVal = Polycore.Camera_hasFilterShader(self.__ptr)
  58. return retVal
  59. end
  60. function Camera:drawFilter()
  61. local retVal = Polycore.Camera_drawFilter(self.__ptr)
  62. end
  63. function Camera:setExposureLevel(level)
  64. local retVal = Polycore.Camera_setExposureLevel(self.__ptr, level)
  65. end
  66. function Camera:getExposureLevel()
  67. local retVal = Polycore.Camera_getExposureLevel(self.__ptr)
  68. return retVal
  69. end
  70. function Camera:createPostFilter(shaderMaterial)
  71. local retVal = Polycore.Camera_createPostFilter(self.__ptr, shaderMaterial.__ptr)
  72. end
  73. function Camera:setPostFilter(shaderName)
  74. local retVal = Polycore.Camera_setPostFilter(self.__ptr, shaderName.__ptr)
  75. end
  76. function Camera:removePostFilter()
  77. local retVal = Polycore.Camera_removePostFilter(self.__ptr)
  78. end
  79. function Camera:getScreenShaderMaterial()
  80. local retVal = Polycore.Camera_getScreenShaderMaterial(self.__ptr)
  81. if retVal == nil then return nil end
  82. if Polycore.__ptr_lookup[retVal] ~= nil then
  83. return Polycore.__ptr_lookup[retVal]
  84. else
  85. Polycore.__ptr_lookup[retVal] = Material("__skip_ptr__")
  86. Polycore.__ptr_lookup[retVal].__ptr = retVal
  87. return Polycore.__ptr_lookup[retVal]
  88. end
  89. end
  90. function Camera:__delete()
  91. Polycore.__ptr_lookup[self.__ptr] = nil
  92. Polycore.delete_Camera(self.__ptr)
  93. end