Mesh.lua 2.6 KB

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