Matrix4.lua 2.0 KB

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