| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- require "Polycode/Entity"
- class "Camera" (Entity)
- Camera.ORTHO_SIZE_MANUAL = 0
- Camera.ORTHO_SIZE_LOCK_HEIGHT = 1
- Camera.ORTHO_SIZE_LOCK_WIDTH = 2
- Camera.ORTHO_SIZE_VIEWPORT = 3
- Camera.PERSPECTIVE_FOV = 4
- Camera.PERSPECTIVE_FRUSTUM = 5
- Camera.MANUAL_MATRIX = 6
- function Camera:__getvar(name)
- if name == "frustumCulling" then
- return Polycode.Camera_get_frustumCulling(self.__ptr)
- elseif name == "topLeftOrtho" then
- return Polycode.Camera_get_topLeftOrtho(self.__ptr)
- elseif name == "cameraShift" then
- local retVal = Polycode.Camera_get_cameraShift(self.__ptr)
- if retVal == nil then return nil end
- local __c = _G["Vector2"]("__skip_ptr__")
- __c.__ptr = retVal
- return __c
- end
- if Entity["__getvar"] ~= nil then
- return Entity.__getvar(self, name)
- end
- end
- function Camera:__setvar(name,value)
- if name == "frustumCulling" then
- Polycode.Camera_set_frustumCulling(self.__ptr, value)
- return true
- elseif name == "topLeftOrtho" then
- Polycode.Camera_set_topLeftOrtho(self.__ptr, value)
- return true
- elseif name == "cameraShift" then
- Polycode.Camera_set_cameraShift(self.__ptr, value.__ptr)
- return true
- end
- if Entity["__setvar"] ~= nil then
- return Entity.__setvar(self, name, value)
- else
- return false
- end
- end
- function Camera:Camera(...)
- local arg = {...}
- if type(arg[1]) == "table" and count(arg) == 1 then
- if ""..arg[1].__classname == "Entity" then
- self.__ptr = arg[1].__ptr
- return
- end
- end
- for k,v in pairs(arg) do
- if type(v) == "table" then
- if v.__ptr ~= nil then
- arg[k] = v.__ptr
- end
- end
- end
- if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
- self.__ptr = Polycode.Camera(unpack(arg))
- end
- end
- function Camera:buildFrustumPlanes()
- local retVal = Polycode.Camera_buildFrustumPlanes(self.__ptr)
- end
- function Camera:isSphereInFrustum(pos, fRadius)
- local retVal = Polycode.Camera_isSphereInFrustum(self.__ptr, pos.__ptr, fRadius)
- return retVal
- end
- function Camera:isAABBInFrustum(aabb)
- local retVal = Polycode.Camera_isAABBInFrustum(self.__ptr, aabb.__ptr)
- return retVal
- end
- function Camera:setOrthoMode(mode)
- local retVal = Polycode.Camera_setOrthoMode(self.__ptr, mode)
- end
- function Camera:setOrthoSize(orthoSizeX, orthoSizeY)
- local retVal = Polycode.Camera_setOrthoSize(self.__ptr, orthoSizeX, orthoSizeY)
- end
- function Camera:setFrustumMode(left, right, bottom, top, front, back)
- local retVal = Polycode.Camera_setFrustumMode(self.__ptr, left, right, bottom, top, front, back)
- end
- function Camera:getOrthoMode()
- local retVal = Polycode.Camera_getOrthoMode(self.__ptr)
- return retVal
- end
- function Camera:getOrthoSizeX()
- local retVal = Polycode.Camera_getOrthoSizeX(self.__ptr)
- return retVal
- end
- function Camera:getOrthoSizeY()
- local retVal = Polycode.Camera_getOrthoSizeY(self.__ptr)
- return retVal
- end
- function Camera:setFOV(fov)
- local retVal = Polycode.Camera_setFOV(self.__ptr, fov)
- end
- function Camera:getFOV()
- local retVal = Polycode.Camera_getFOV(self.__ptr)
- return retVal
- end
- function Camera:setClippingPlanes(nearClipPlane, farClipPlane)
- local retVal = Polycode.Camera_setClippingPlanes(self.__ptr, nearClipPlane, farClipPlane)
- end
- function Camera:getNearClippingPlane()
- local retVal = Polycode.Camera_getNearClippingPlane(self.__ptr)
- return retVal
- end
- function Camera:getFarClippingPlane()
- local retVal = Polycode.Camera_getFarClippingPlane(self.__ptr)
- return retVal
- end
- function Camera:createProjectionMatrix()
- local retVal = Polycode.Camera_createProjectionMatrix(self.__ptr)
- if retVal == nil then return nil end
- local __c = _G["Matrix4"]("__skip_ptr__")
- __c.__ptr = retVal
- return __c
- end
- function Camera:hasFilterShader()
- local retVal = Polycode.Camera_hasFilterShader(self.__ptr)
- return retVal
- end
- function Camera:setPostFilter(material)
- local retVal = Polycode.Camera_setPostFilter(self.__ptr, material.__ptr)
- end
- function Camera:removePostFilter()
- local retVal = Polycode.Camera_removePostFilter(self.__ptr)
- end
- function Camera:getScreenShaderMaterial()
- local retVal = Polycode.Camera_getScreenShaderMaterial(self.__ptr)
- if retVal == nil then return nil end
- local __c = _G["shared_ptr<Material>"]("__skip_ptr__")
- __c.__ptr = retVal
- return __c
- end
- function Camera:getProjectionMatrix()
- local retVal = Polycode.Camera_getProjectionMatrix(self.__ptr)
- if retVal == nil then return nil end
- local __c = _G["Matrix4"]("__skip_ptr__")
- __c.__ptr = retVal
- return __c
- end
- function Camera:setCustomProjectionMatrix(matrix)
- local retVal = Polycode.Camera_setCustomProjectionMatrix(self.__ptr, matrix.__ptr)
- end
- function Camera:getViewport()
- local retVal = Polycode.Camera_getViewport(self.__ptr)
- if retVal == nil then return nil end
- local __c = _G["Rectangle"]("__skip_ptr__")
- __c.__ptr = retVal
- return __c
- end
- function Camera:setViewport(viewport)
- local retVal = Polycode.Camera_setViewport(self.__ptr, viewport.__ptr)
- end
- function Camera:setOrthoSizeMode(orthoSizeMode)
- local retVal = Polycode.Camera_setOrthoSizeMode(self.__ptr, orthoSizeMode)
- end
- function Camera:getOrthoSizeMode()
- local retVal = Polycode.Camera_getOrthoSizeMode(self.__ptr)
- return retVal
- end
- function Camera:setProjectionMode(mode)
- local retVal = Polycode.Camera_setProjectionMode(self.__ptr, mode)
- end
- function Camera:getProjectionMode()
- local retVal = Polycode.Camera_getProjectionMode(self.__ptr)
- return retVal
- end
- function Camera:projectRayFrom2DCoordinate(coordinate, viewport)
- local retVal = Polycode.Camera_projectRayFrom2DCoordinate(self.__ptr, coordinate.__ptr, viewport.__ptr)
- if retVal == nil then return nil end
- local __c = _G["Vector3"]("__skip_ptr__")
- __c.__ptr = retVal
- return __c
- end
- function Camera:getShaderPass(index)
- local retVal = Polycode.Camera_getShaderPass(self.__ptr, index)
- if retVal == nil then return nil end
- local __c = _G["ShaderPass"]("__skip_ptr__")
- __c.__ptr = retVal
- return __c
- end
- function Camera:getNumShaderPasses()
- local retVal = Polycode.Camera_getNumShaderPasses(self.__ptr)
- return retVal
- end
- function Camera:__delete()
- if self then Polycode.delete_Camera(self.__ptr) end
- end
|