Matrix4.lua 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. Polycore.__ptr_lookup[self.__ptr] = self
  13. end
  14. end
  15. function Matrix4:identity()
  16. local retVal = Polycore.Matrix4_identity(self.__ptr)
  17. end
  18. function Matrix4:rotateVector(v2)
  19. local retVal = Polycore.Matrix4_rotateVector(self.__ptr, v2.__ptr)
  20. if retVal == nil then return nil end
  21. if Polycore.__ptr_lookup[retVal] ~= nil then
  22. return Polycore.__ptr_lookup[retVal]
  23. else
  24. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  25. Polycore.__ptr_lookup[retVal].__ptr = retVal
  26. return Polycore.__ptr_lookup[retVal]
  27. end
  28. end
  29. function Matrix4:getPosition()
  30. local retVal = Polycore.Matrix4_getPosition(self.__ptr)
  31. if retVal == nil then return nil end
  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 retVal == nil then return nil end
  52. if Polycore.__ptr_lookup[retVal] ~= nil then
  53. return Polycore.__ptr_lookup[retVal]
  54. else
  55. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  56. Polycore.__ptr_lookup[retVal].__ptr = retVal
  57. return Polycore.__ptr_lookup[retVal]
  58. end
  59. end
  60. function Matrix4:inverseAffine()
  61. local retVal = Polycore.Matrix4_inverseAffine(self.__ptr)
  62. if retVal == nil then return nil end
  63. if Polycore.__ptr_lookup[retVal] ~= nil then
  64. return Polycore.__ptr_lookup[retVal]
  65. else
  66. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  67. Polycore.__ptr_lookup[retVal].__ptr = retVal
  68. return Polycore.__ptr_lookup[retVal]
  69. end
  70. end
  71. function Matrix4:__delete()
  72. Polycore.__ptr_lookup[self.__ptr] = nil
  73. Polycore.delete_Matrix4(self.__ptr)
  74. end