2
0

Mesh.lua 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. require "Polycode/Resource"
  2. class "Mesh" (Resource)
  3. function Mesh:Mesh(...)
  4. local arg = {...}
  5. if type(arg[1]) == "table" and count(arg) == 1 then
  6. if ""..arg[1].__classname == "Resource" then
  7. self.__ptr = arg[1].__ptr
  8. return
  9. end
  10. end
  11. for k,v in pairs(arg) do
  12. if type(v) == "table" then
  13. if v.__ptr ~= nil then
  14. arg[k] = v.__ptr
  15. end
  16. end
  17. end
  18. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  19. self.__ptr = Polycode.Mesh(unpack(arg))
  20. end
  21. end
  22. function Mesh:addSubmesh(newSubmesh)
  23. local retVal = Polycode.Mesh_addSubmesh(self.__ptr, newSubmesh.__ptr)
  24. end
  25. function Mesh:removeSubmeshAtIndex(index)
  26. local retVal = Polycode.Mesh_removeSubmeshAtIndex(self.__ptr, index)
  27. end
  28. function Mesh:getNumSubmeshes()
  29. local retVal = Polycode.Mesh_getNumSubmeshes(self.__ptr)
  30. return retVal
  31. end
  32. function Mesh:getSubmeshAtIndex(index)
  33. local retVal = Polycode.Mesh_getSubmeshAtIndex(self.__ptr, index)
  34. if retVal == nil then return nil end
  35. local __c = _G["MeshGeometry"]("__skip_ptr__")
  36. __c.__ptr = retVal
  37. return __c
  38. end
  39. function Mesh:getSubmeshPointer(index)
  40. local retVal = Polycode.Mesh_getSubmeshPointer(self.__ptr, index)
  41. if retVal == nil then return nil end
  42. local __c = _G["shared_ptr<MeshGeometry>"]("__skip_ptr__")
  43. __c.__ptr = retVal
  44. return __c
  45. end
  46. function Mesh:clearMesh()
  47. local retVal = Polycode.Mesh_clearMesh(self.__ptr)
  48. end
  49. function Mesh:calculateBBox()
  50. local retVal = Polycode.Mesh_calculateBBox(self.__ptr)
  51. if retVal == nil then return nil end
  52. local __c = _G["Vector3"]("__skip_ptr__")
  53. __c.__ptr = retVal
  54. return __c
  55. end
  56. function Mesh:getRadius()
  57. local retVal = Polycode.Mesh_getRadius(self.__ptr)
  58. return retVal
  59. end
  60. function Mesh:__delete()
  61. if self then Polycode.delete_Mesh(self.__ptr) end
  62. end