2
0

Matrix4.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 Polycore.__ptr_lookup[retVal] ~= nil then
  21. return Polycore.__ptr_lookup[retVal]
  22. else
  23. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  24. Polycore.__ptr_lookup[retVal].__ptr = retVal
  25. return Polycore.__ptr_lookup[retVal]
  26. end
  27. end
  28. function Matrix4:getPosition()
  29. local retVal = Polycore.Matrix4_getPosition(self.__ptr)
  30. if Polycore.__ptr_lookup[retVal] ~= nil then
  31. return Polycore.__ptr_lookup[retVal]
  32. else
  33. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  34. Polycore.__ptr_lookup[retVal].__ptr = retVal
  35. return Polycore.__ptr_lookup[retVal]
  36. end
  37. end
  38. function Matrix4:setPosition(x, y, z)
  39. local retVal = Polycore.Matrix4_setPosition(self.__ptr, x, y, z)
  40. end
  41. function Matrix4:setScale(scale)
  42. local retVal = Polycore.Matrix4_setScale(self.__ptr, scale.__ptr)
  43. end
  44. function Matrix4:getEulerAngles(ax, ay, az)
  45. local retVal = Polycore.Matrix4_getEulerAngles(self.__ptr, ax.__ptr, ay.__ptr, az.__ptr)
  46. end
  47. function Matrix4:inverse()
  48. local retVal = Polycore.Matrix4_inverse(self.__ptr)
  49. if Polycore.__ptr_lookup[retVal] ~= nil then
  50. return Polycore.__ptr_lookup[retVal]
  51. else
  52. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  53. Polycore.__ptr_lookup[retVal].__ptr = retVal
  54. return Polycore.__ptr_lookup[retVal]
  55. end
  56. end
  57. function Matrix4:inverseAffine()
  58. local retVal = Polycore.Matrix4_inverseAffine(self.__ptr)
  59. if Polycore.__ptr_lookup[retVal] ~= nil then
  60. return Polycore.__ptr_lookup[retVal]
  61. else
  62. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  63. Polycore.__ptr_lookup[retVal].__ptr = retVal
  64. return Polycore.__ptr_lookup[retVal]
  65. end
  66. end