Camera.lua 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. require "Polycode/Entity"
  2. class "Camera" (Entity)
  3. Camera.ORTHO_SIZE_MANUAL = 0
  4. Camera.ORTHO_SIZE_LOCK_HEIGHT = 1
  5. Camera.ORTHO_SIZE_LOCK_WIDTH = 2
  6. Camera.ORTHO_SIZE_VIEWPORT = 3
  7. Camera.PERSPECTIVE_FOV = 4
  8. Camera.PERSPECTIVE_FRUSTUM = 5
  9. Camera.MANUAL_MATRIX = 6
  10. function Camera:__getvar(name)
  11. if name == "frustumCulling" then
  12. return Polycore.Camera_get_frustumCulling(self.__ptr)
  13. elseif name == "topLeftOrtho" then
  14. return Polycore.Camera_get_topLeftOrtho(self.__ptr)
  15. elseif name == "cameraShift" then
  16. local retVal = Polycore.Camera_get_cameraShift(self.__ptr)
  17. if retVal == nil then return nil end
  18. local __c = _G["Vector2"]("__skip_ptr__")
  19. __c.__ptr = retVal
  20. return __c
  21. end
  22. if Entity["__getvar"] ~= nil then
  23. return Entity.__getvar(self, name)
  24. end
  25. end
  26. function Camera:__setvar(name,value)
  27. if name == "frustumCulling" then
  28. Polycore.Camera_set_frustumCulling(self.__ptr, value)
  29. return true
  30. elseif name == "topLeftOrtho" then
  31. Polycore.Camera_set_topLeftOrtho(self.__ptr, value)
  32. return true
  33. elseif name == "cameraShift" then
  34. Polycore.Camera_set_cameraShift(self.__ptr, value.__ptr)
  35. return true
  36. end
  37. if Entity["__setvar"] ~= nil then
  38. return Entity.__setvar(self, name, value)
  39. else
  40. return false
  41. end
  42. end
  43. function Camera:Camera(...)
  44. local arg = {...}
  45. if type(arg[1]) == "table" and count(arg) == 1 then
  46. if ""..arg[1].__classname == "Entity" then
  47. self.__ptr = arg[1].__ptr
  48. return
  49. end
  50. end
  51. for k,v in pairs(arg) do
  52. if type(v) == "table" then
  53. if v.__ptr ~= nil then
  54. arg[k] = v.__ptr
  55. end
  56. end
  57. end
  58. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  59. self.__ptr = Polycore.Camera(unpack(arg))
  60. end
  61. end
  62. function Camera:buildFrustumPlanes()
  63. local retVal = Polycore.Camera_buildFrustumPlanes(self.__ptr)
  64. end
  65. function Camera:isSphereInFrustum(pos, fRadius)
  66. local retVal = Polycore.Camera_isSphereInFrustum(self.__ptr, pos.__ptr, fRadius)
  67. return retVal
  68. end
  69. function Camera:isAABBInFrustum(aabb)
  70. local retVal = Polycore.Camera_isAABBInFrustum(self.__ptr, aabb.__ptr)
  71. return retVal
  72. end
  73. function Camera:setOrthoMode(mode)
  74. local retVal = Polycore.Camera_setOrthoMode(self.__ptr, mode)
  75. end
  76. function Camera:setOrthoSize(orthoSizeX, orthoSizeY)
  77. local retVal = Polycore.Camera_setOrthoSize(self.__ptr, orthoSizeX, orthoSizeY)
  78. end
  79. function Camera:setFrustumMode(left, right, bottom, top, front, back)
  80. local retVal = Polycore.Camera_setFrustumMode(self.__ptr, left, right, bottom, top, front, back)
  81. end
  82. function Camera:getOrthoMode()
  83. local retVal = Polycore.Camera_getOrthoMode(self.__ptr)
  84. return retVal
  85. end
  86. function Camera:getOrthoSizeX()
  87. local retVal = Polycore.Camera_getOrthoSizeX(self.__ptr)
  88. return retVal
  89. end
  90. function Camera:getOrthoSizeY()
  91. local retVal = Polycore.Camera_getOrthoSizeY(self.__ptr)
  92. return retVal
  93. end
  94. function Camera:setFOV(fov)
  95. local retVal = Polycore.Camera_setFOV(self.__ptr, fov)
  96. end
  97. function Camera:getFOV()
  98. local retVal = Polycore.Camera_getFOV(self.__ptr)
  99. return retVal
  100. end
  101. function Camera:setClippingPlanes(nearClipPlane, farClipPlane)
  102. local retVal = Polycore.Camera_setClippingPlanes(self.__ptr, nearClipPlane, farClipPlane)
  103. end
  104. function Camera:getNearClippingPlane()
  105. local retVal = Polycore.Camera_getNearClippingPlane(self.__ptr)
  106. return retVal
  107. end
  108. function Camera:getFarClippingPlane()
  109. local retVal = Polycore.Camera_getFarClippingPlane(self.__ptr)
  110. return retVal
  111. end
  112. function Camera:setParentScene(parentScene)
  113. local retVal = Polycore.Camera_setParentScene(self.__ptr, parentScene.__ptr)
  114. end
  115. function Camera:getParentScene()
  116. local retVal = Polycore.Camera_getParentScene(self.__ptr)
  117. if retVal == nil then return nil end
  118. local __c = _G["Scene"]("__skip_ptr__")
  119. __c.__ptr = retVal
  120. return __c
  121. end
  122. function Camera:createProjectionMatrix()
  123. local retVal = Polycore.Camera_createProjectionMatrix(self.__ptr)
  124. if retVal == nil then return nil end
  125. local __c = _G["Matrix4"]("__skip_ptr__")
  126. __c.__ptr = retVal
  127. return __c
  128. end
  129. function Camera:hasFilterShader()
  130. local retVal = Polycore.Camera_hasFilterShader(self.__ptr)
  131. return retVal
  132. end
  133. function Camera:drawFilter(targetBuffer)
  134. local retVal = Polycore.Camera_drawFilter(self.__ptr, targetBuffer.__ptr)
  135. end
  136. function Camera:setPostFilter(material)
  137. local retVal = Polycore.Camera_setPostFilter(self.__ptr, material.__ptr)
  138. end
  139. function Camera:setPostFilterByName(shaderName)
  140. local retVal = Polycore.Camera_setPostFilterByName(self.__ptr, shaderName)
  141. end
  142. function Camera:removePostFilter()
  143. local retVal = Polycore.Camera_removePostFilter(self.__ptr)
  144. end
  145. function Camera:getScreenShaderMaterial()
  146. local retVal = Polycore.Camera_getScreenShaderMaterial(self.__ptr)
  147. if retVal == nil then return nil end
  148. local __c = _G["Material"]("__skip_ptr__")
  149. __c.__ptr = retVal
  150. return __c
  151. end
  152. function Camera:Clone(deepClone, ignoreEditorOnly)
  153. local retVal = Polycore.Camera_Clone(self.__ptr, deepClone, ignoreEditorOnly)
  154. if retVal == nil then return nil end
  155. local __c = _G["Entity"]("__skip_ptr__")
  156. __c.__ptr = retVal
  157. return __c
  158. end
  159. function Camera:applyClone(clone, deepClone, ignoreEditorOnly)
  160. local retVal = Polycore.Camera_applyClone(self.__ptr, clone.__ptr, deepClone, ignoreEditorOnly)
  161. end
  162. function Camera:getProjectionMatrix()
  163. local retVal = Polycore.Camera_getProjectionMatrix(self.__ptr)
  164. if retVal == nil then return nil end
  165. local __c = _G["Matrix4"]("__skip_ptr__")
  166. __c.__ptr = retVal
  167. return __c
  168. end
  169. function Camera:setCustomProjectionMatrix(matrix)
  170. local retVal = Polycore.Camera_setCustomProjectionMatrix(self.__ptr, matrix.__ptr)
  171. end
  172. function Camera:getViewport()
  173. local retVal = Polycore.Camera_getViewport(self.__ptr)
  174. if retVal == nil then return nil end
  175. local __c = _G["Polycode::Rectangle"]("__skip_ptr__")
  176. __c.__ptr = retVal
  177. return __c
  178. end
  179. function Camera:setViewport(viewport)
  180. local retVal = Polycore.Camera_setViewport(self.__ptr, viewport.__ptr)
  181. end
  182. function Camera:setOrthoSizeMode(orthoSizeMode)
  183. local retVal = Polycore.Camera_setOrthoSizeMode(self.__ptr, orthoSizeMode)
  184. end
  185. function Camera:getOrthoSizeMode()
  186. local retVal = Polycore.Camera_getOrthoSizeMode(self.__ptr)
  187. return retVal
  188. end
  189. function Camera:setProjectionMode(mode)
  190. local retVal = Polycore.Camera_setProjectionMode(self.__ptr, mode)
  191. end
  192. function Camera:getProjectionMode()
  193. local retVal = Polycore.Camera_getProjectionMode(self.__ptr)
  194. return retVal
  195. end
  196. function Camera:projectRayFrom2DCoordinate(coordinate, viewport)
  197. local retVal = Polycore.Camera_projectRayFrom2DCoordinate(self.__ptr, coordinate.__ptr, viewport.__ptr)
  198. if retVal == nil then return nil end
  199. local __c = _G["Vector3"]("__skip_ptr__")
  200. __c.__ptr = retVal
  201. return __c
  202. end
  203. function Camera:renderFullScreenQuad(drawBuffer, shaderPass)
  204. local retVal = Polycore.Camera_renderFullScreenQuad(self.__ptr, drawBuffer.__ptr, shaderPass)
  205. end
  206. function Camera:getShaderPass(index)
  207. local retVal = Polycore.Camera_getShaderPass(self.__ptr, index)
  208. if retVal == nil then return nil end
  209. local __c = _G["ShaderPass"]("__skip_ptr__")
  210. __c.__ptr = retVal
  211. return __c
  212. end
  213. function Camera:getNumShaderPasses()
  214. local retVal = Polycore.Camera_getNumShaderPasses(self.__ptr)
  215. return retVal
  216. end
  217. function Camera:__delete()
  218. if self then Polycore.delete_Camera(self.__ptr) end
  219. end