Mesh.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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:loadMesh(fileName)
  23. local retVal = Polycode.Mesh_loadMesh(self.__ptr, fileName)
  24. end
  25. function Mesh:saveToFile(fileName, writeNormals, writeTangents, writeColors, writeBoneWeights, writeUVs, writeSecondaryUVs)
  26. local retVal = Polycode.Mesh_saveToFile(self.__ptr, fileName, writeNormals, writeTangents, writeColors, writeBoneWeights, writeUVs, writeSecondaryUVs)
  27. end
  28. function Mesh:addSubmesh(newSubmesh)
  29. local retVal = Polycode.Mesh_addSubmesh(self.__ptr, newSubmesh.__ptr)
  30. end
  31. function Mesh:removeSubmeshAtIndex(index)
  32. local retVal = Polycode.Mesh_removeSubmeshAtIndex(self.__ptr, index)
  33. end
  34. function Mesh:getNumSubmeshes()
  35. local retVal = Polycode.Mesh_getNumSubmeshes(self.__ptr)
  36. return retVal
  37. end
  38. function Mesh:getSubmeshAtIndex(index)
  39. local retVal = Polycode.Mesh_getSubmeshAtIndex(self.__ptr, index)
  40. if retVal == nil then return nil end
  41. local __c = _G["MeshGeometry"]("__skip_ptr__")
  42. __c.__ptr = retVal
  43. return __c
  44. end
  45. function Mesh:getSubmeshPointer(index)
  46. local retVal = Polycode.Mesh_getSubmeshPointer(self.__ptr, index)
  47. if retVal == nil then return nil end
  48. local __c = _G["shared_ptr<MeshGeometry>"]("__skip_ptr__")
  49. __c.__ptr = retVal
  50. return __c
  51. end
  52. function Mesh:clearMesh()
  53. local retVal = Polycode.Mesh_clearMesh(self.__ptr)
  54. end
  55. function Mesh:calculateBBox()
  56. local retVal = Polycode.Mesh_calculateBBox(self.__ptr)
  57. if retVal == nil then return nil end
  58. local __c = _G["Vector3"]("__skip_ptr__")
  59. __c.__ptr = retVal
  60. return __c
  61. end
  62. function Mesh:getRadius()
  63. local retVal = Polycode.Mesh_getRadius(self.__ptr)
  64. return retVal
  65. end
  66. function Mesh:__delete()
  67. if self then Polycode.delete_Mesh(self.__ptr) end
  68. end