2
0

Matrix4.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. class "Matrix4"
  2. function Matrix4:Matrix4(...)
  3. for k,v in pairs(arg) do
  4. if type(v) == "table" then
  5. if v.__ptr ~= nil then
  6. arg[k] = v.__ptr
  7. end
  8. end
  9. end
  10. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  11. self.__ptr = Polycore.Matrix4(unpack(arg))
  12. end
  13. end
  14. function Matrix4:init()
  15. local retVal = Polycore.Matrix4_init(self.__ptr)
  16. end
  17. function Matrix4:identity()
  18. local retVal = Polycore.Matrix4_identity(self.__ptr)
  19. end
  20. function Matrix4:rotateVector(v2)
  21. local retVal = Polycore.Matrix4_rotateVector(self.__ptr, v2.__ptr)
  22. if Polycore.__ptr_lookup[retVal] ~= nil then
  23. return Polycore.__ptr_lookup[retVal]
  24. else
  25. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  26. Polycore.__ptr_lookup[retVal].__ptr = retVal
  27. return Polycore.__ptr_lookup[retVal]
  28. end
  29. end
  30. function Matrix4:getPosition()
  31. local retVal = Polycore.Matrix4_getPosition(self.__ptr)
  32. if Polycore.__ptr_lookup[retVal] ~= nil then
  33. return Polycore.__ptr_lookup[retVal]
  34. else
  35. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  36. Polycore.__ptr_lookup[retVal].__ptr = retVal
  37. return Polycore.__ptr_lookup[retVal]
  38. end
  39. end
  40. function Matrix4:setPosition(x, y, z)
  41. local retVal = Polycore.Matrix4_setPosition(self.__ptr, x, y, z)
  42. end
  43. function Matrix4:setScale(scale)
  44. local retVal = Polycore.Matrix4_setScale(self.__ptr, scale.__ptr)
  45. end
  46. function Matrix4:getEulerAngles(ax, ay, az)
  47. local retVal = Polycore.Matrix4_getEulerAngles(self.__ptr, ax.__ptr, ay.__ptr, az.__ptr)
  48. end
  49. function Matrix4:inverse()
  50. local retVal = Polycore.Matrix4_inverse(self.__ptr)
  51. if Polycore.__ptr_lookup[retVal] ~= nil then
  52. return Polycore.__ptr_lookup[retVal]
  53. else
  54. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  55. Polycore.__ptr_lookup[retVal].__ptr = retVal
  56. return Polycore.__ptr_lookup[retVal]
  57. end
  58. end
  59. function Matrix4:inverseAffine()
  60. local retVal = Polycore.Matrix4_inverseAffine(self.__ptr)
  61. if Polycore.__ptr_lookup[retVal] ~= nil then
  62. return Polycore.__ptr_lookup[retVal]
  63. else
  64. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  65. Polycore.__ptr_lookup[retVal].__ptr = retVal
  66. return Polycore.__ptr_lookup[retVal]
  67. end
  68. end