Rotation.lua 985 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. class "Rotation"
  2. function Rotation:__getvar(name)
  3. if name == "pitch" then
  4. return Polycode.Rotation_get_pitch(self.__ptr)
  5. elseif name == "yaw" then
  6. return Polycode.Rotation_get_yaw(self.__ptr)
  7. elseif name == "roll" then
  8. return Polycode.Rotation_get_roll(self.__ptr)
  9. end
  10. end
  11. function Rotation:__setvar(name,value)
  12. if name == "pitch" then
  13. Polycode.Rotation_set_pitch(self.__ptr, value)
  14. return true
  15. elseif name == "yaw" then
  16. Polycode.Rotation_set_yaw(self.__ptr, value)
  17. return true
  18. elseif name == "roll" then
  19. Polycode.Rotation_set_roll(self.__ptr, value)
  20. return true
  21. end
  22. return false
  23. end
  24. function Rotation:Rotation(...)
  25. local arg = {...}
  26. for k,v in pairs(arg) do
  27. if type(v) == "table" then
  28. if v.__ptr ~= nil then
  29. arg[k] = v.__ptr
  30. end
  31. end
  32. end
  33. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  34. self.__ptr = Polycode.Rotation(unpack(arg))
  35. end
  36. end
  37. function Rotation:__delete()
  38. if self then Polycode.delete_Rotation(self.__ptr) end
  39. end