MeshGeometry.lua 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. class "MeshGeometry"
  2. MeshGeometry.TRISTRIP_MESH = 0
  3. MeshGeometry.TRI_MESH = 1
  4. MeshGeometry.TRIFAN_MESH = 2
  5. MeshGeometry.LINE_MESH = 4
  6. MeshGeometry.POINT_MESH = 5
  7. MeshGeometry.LINE_STRIP_MESH = 6
  8. MeshGeometry.LINE_LOOP_MESH = 7
  9. function MeshGeometry:__getvar(name)
  10. if name == "meshType" then
  11. return Polycode.MeshGeometry_get_meshType(self.__ptr)
  12. elseif name == "dataChanged" then
  13. return Polycode.MeshGeometry_get_dataChanged(self.__ptr)
  14. elseif name == "indexedMesh" then
  15. return Polycode.MeshGeometry_get_indexedMesh(self.__ptr)
  16. end
  17. end
  18. function MeshGeometry:__setvar(name,value)
  19. if name == "meshType" then
  20. Polycode.MeshGeometry_set_meshType(self.__ptr, value)
  21. return true
  22. elseif name == "dataChanged" then
  23. Polycode.MeshGeometry_set_dataChanged(self.__ptr, value)
  24. return true
  25. elseif name == "indexedMesh" then
  26. Polycode.MeshGeometry_set_indexedMesh(self.__ptr, value)
  27. return true
  28. end
  29. return false
  30. end
  31. function MeshGeometry:MeshGeometry(...)
  32. local arg = {...}
  33. for k,v in pairs(arg) do
  34. if type(v) == "table" then
  35. if v.__ptr ~= nil then
  36. arg[k] = v.__ptr
  37. end
  38. end
  39. end
  40. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  41. self.__ptr = Polycode.MeshGeometry(unpack(arg))
  42. end
  43. end
  44. function MeshGeometry:clearMesh()
  45. local retVal = Polycode.MeshGeometry_clearMesh(self.__ptr)
  46. end
  47. function MeshGeometry:getVertexCount()
  48. local retVal = Polycode.MeshGeometry_getVertexCount(self.__ptr)
  49. return retVal
  50. end
  51. function MeshGeometry:createPlane(w, h, tilingValue)
  52. local retVal = Polycode.MeshGeometry_createPlane(self.__ptr, w, h, tilingValue)
  53. end
  54. function MeshGeometry:createVPlane(w, h, tilingValue)
  55. local retVal = Polycode.MeshGeometry_createVPlane(self.__ptr, w, h, tilingValue)
  56. end
  57. function MeshGeometry:createCircle(w, h, numSegments, tilingValue)
  58. local retVal = Polycode.MeshGeometry_createCircle(self.__ptr, w, h, numSegments, tilingValue)
  59. end
  60. function MeshGeometry:createLineCircle(w, h, numSegments, tilingValue)
  61. local retVal = Polycode.MeshGeometry_createLineCircle(self.__ptr, w, h, numSegments, tilingValue)
  62. end
  63. function MeshGeometry:createTorus(radius, tubeRadius, segmentsW, segmentsH, tilingValue)
  64. local retVal = Polycode.MeshGeometry_createTorus(self.__ptr, radius, tubeRadius, segmentsW, segmentsH, tilingValue)
  65. end
  66. function MeshGeometry:createBox(w, d, h, tilingValue)
  67. local retVal = Polycode.MeshGeometry_createBox(self.__ptr, w, d, h, tilingValue)
  68. end
  69. function MeshGeometry:createSphere(radius, numRings, numSegments, tilingValue)
  70. local retVal = Polycode.MeshGeometry_createSphere(self.__ptr, radius, numRings, numSegments, tilingValue)
  71. end
  72. function MeshGeometry:createIcosphere(radius, subdivisions)
  73. local retVal = Polycode.MeshGeometry_createIcosphere(self.__ptr, radius, subdivisions)
  74. end
  75. function MeshGeometry:createOctosphere(radius, subdivisions)
  76. local retVal = Polycode.MeshGeometry_createOctosphere(self.__ptr, radius, subdivisions)
  77. end
  78. function MeshGeometry:createCylinder(height, radius, numSegments, capped, tilingValue)
  79. local retVal = Polycode.MeshGeometry_createCylinder(self.__ptr, height, radius, numSegments, capped, tilingValue)
  80. end
  81. function MeshGeometry:createCone(height, radius, numSegments, tilingValue)
  82. local retVal = Polycode.MeshGeometry_createCone(self.__ptr, height, radius, numSegments, tilingValue)
  83. end
  84. function MeshGeometry:recenterMesh()
  85. local retVal = Polycode.MeshGeometry_recenterMesh(self.__ptr)
  86. if retVal == nil then return nil end
  87. local __c = _G["Vector3"]("__skip_ptr__")
  88. __c.__ptr = retVal
  89. return __c
  90. end
  91. function MeshGeometry:setVertexAtOffset(offset, x, y, z)
  92. local retVal = Polycode.MeshGeometry_setVertexAtOffset(self.__ptr, offset, x, y, z)
  93. end
  94. function MeshGeometry:addVertexWithUVAndNormal(x, y, z, u, v, nx, ny, nz)
  95. local retVal = Polycode.MeshGeometry_addVertexWithUVAndNormal(self.__ptr, x, y, z, u, v, nx, ny, nz)
  96. end
  97. function MeshGeometry:addTexCoord(u, v)
  98. local retVal = Polycode.MeshGeometry_addTexCoord(self.__ptr, u, v)
  99. end
  100. function MeshGeometry:addTexCoord2(u, v)
  101. local retVal = Polycode.MeshGeometry_addTexCoord2(self.__ptr, u, v)
  102. end
  103. function MeshGeometry:addTangent(x, y, z)
  104. local retVal = Polycode.MeshGeometry_addTangent(self.__ptr, x, y, z)
  105. end
  106. function MeshGeometry:addVertexWithUV(x, y, z, u, v)
  107. local retVal = Polycode.MeshGeometry_addVertexWithUV(self.__ptr, x, y, z, u, v)
  108. end
  109. function MeshGeometry:addVertex(x, y, z)
  110. local retVal = Polycode.MeshGeometry_addVertex(self.__ptr, x, y, z)
  111. end
  112. function MeshGeometry:addNormal(nx, ny, nz)
  113. local retVal = Polycode.MeshGeometry_addNormal(self.__ptr, nx, ny, nz)
  114. end
  115. function MeshGeometry:addBoneAssignments(b1Weight, b1Index, b2Weight, b2Index, b3Weight, b3Index, b4Weight, b4Index)
  116. local retVal = Polycode.MeshGeometry_addBoneAssignments(self.__ptr, b1Weight, b1Index, b2Weight, b2Index, b3Weight, b3Index, b4Weight, b4Index)
  117. end
  118. function MeshGeometry:addColor(r, g, b, a)
  119. local retVal = Polycode.MeshGeometry_addColor(self.__ptr, r, g, b, a)
  120. end
  121. function MeshGeometry:getVertexPosition(vertexOffset)
  122. local retVal = Polycode.MeshGeometry_getVertexPosition(self.__ptr, vertexOffset)
  123. if retVal == nil then return nil end
  124. local __c = _G["Vector3"]("__skip_ptr__")
  125. __c.__ptr = retVal
  126. return __c
  127. end
  128. function MeshGeometry:getVertexPositionAtIndex(index)
  129. local retVal = Polycode.MeshGeometry_getVertexPositionAtIndex(self.__ptr, index)
  130. if retVal == nil then return nil end
  131. local __c = _G["Vector3"]("__skip_ptr__")
  132. __c.__ptr = retVal
  133. return __c
  134. end
  135. function MeshGeometry:getVertexTexCoord(vertexOffset)
  136. local retVal = Polycode.MeshGeometry_getVertexTexCoord(self.__ptr, vertexOffset)
  137. if retVal == nil then return nil end
  138. local __c = _G["Vector2"]("__skip_ptr__")
  139. __c.__ptr = retVal
  140. return __c
  141. end
  142. function MeshGeometry:getVertexTexCoordAtIndex(index)
  143. local retVal = Polycode.MeshGeometry_getVertexTexCoordAtIndex(self.__ptr, index)
  144. if retVal == nil then return nil end
  145. local __c = _G["Vector2"]("__skip_ptr__")
  146. __c.__ptr = retVal
  147. return __c
  148. end
  149. function MeshGeometry:Copy()
  150. local retVal = Polycode.MeshGeometry_Copy(self.__ptr)
  151. if retVal == nil then return nil end
  152. local __c = _G["MeshGeometry"]("__skip_ptr__")
  153. __c.__ptr = retVal
  154. return __c
  155. end
  156. function MeshGeometry:getRadius()
  157. local retVal = Polycode.MeshGeometry_getRadius(self.__ptr)
  158. return retVal
  159. end
  160. function MeshGeometry:calculateNormals()
  161. local retVal = Polycode.MeshGeometry_calculateNormals(self.__ptr)
  162. end
  163. function MeshGeometry:calculateTangents()
  164. local retVal = Polycode.MeshGeometry_calculateTangents(self.__ptr)
  165. end
  166. function MeshGeometry:getMeshType()
  167. local retVal = Polycode.MeshGeometry_getMeshType(self.__ptr)
  168. return retVal
  169. end
  170. function MeshGeometry:setMeshType(newType)
  171. local retVal = Polycode.MeshGeometry_setMeshType(self.__ptr, newType)
  172. end
  173. function MeshGeometry:getIndexGroupSize()
  174. local retVal = Polycode.MeshGeometry_getIndexGroupSize(self.__ptr)
  175. return retVal
  176. end
  177. function MeshGeometry:calculateBBox()
  178. local retVal = Polycode.MeshGeometry_calculateBBox(self.__ptr)
  179. if retVal == nil then return nil end
  180. local __c = _G["Vector3"]("__skip_ptr__")
  181. __c.__ptr = retVal
  182. return __c
  183. end
  184. function MeshGeometry:addIndexedFace(i1, i2)
  185. local retVal = Polycode.MeshGeometry_addIndexedFace(self.__ptr, i1, i2)
  186. end
  187. function MeshGeometry:addIndex(index)
  188. local retVal = Polycode.MeshGeometry_addIndex(self.__ptr, index)
  189. end
  190. function MeshGeometry:removeVertexRange(beginRemoveVertex, vertexRemovalCount)
  191. local retVal = Polycode.MeshGeometry_removeVertexRange(self.__ptr, beginRemoveVertex, vertexRemovalCount)
  192. end
  193. function MeshGeometry:removeFace(faceIndex)
  194. local retVal = Polycode.MeshGeometry_removeFace(self.__ptr, faceIndex)
  195. end
  196. function MeshGeometry:removeUnusedVertices()
  197. local retVal = Polycode.MeshGeometry_removeUnusedVertices(self.__ptr)
  198. return retVal
  199. end
  200. function MeshGeometry:getIndexCount()
  201. local retVal = Polycode.MeshGeometry_getIndexCount(self.__ptr)
  202. return retVal
  203. end
  204. function MeshGeometry:subdivideToRadius(radius, subdivisions)
  205. local retVal = Polycode.MeshGeometry_subdivideToRadius(self.__ptr, radius, subdivisions)
  206. end
  207. function MeshGeometry:calculateFaceTangent(v1, v2, v3, texCoord1, texCoord2, texCoord3)
  208. local retVal = Polycode.MeshGeometry_calculateFaceTangent(self.__ptr, v1.__ptr, v2.__ptr, v3.__ptr, texCoord1.__ptr, texCoord2.__ptr, texCoord3.__ptr)
  209. if retVal == nil then return nil end
  210. local __c = _G["Vector3"]("__skip_ptr__")
  211. __c.__ptr = retVal
  212. return __c
  213. end
  214. function MeshGeometry:saveAsOBJ(fileName)
  215. local retVal = Polycode.MeshGeometry_saveAsOBJ(self.__ptr, fileName)
  216. end
  217. function MeshGeometry:normalizeBoneWeights()
  218. local retVal = Polycode.MeshGeometry_normalizeBoneWeights(self.__ptr)
  219. end
  220. function MeshGeometry:__delete()
  221. if self then Polycode.delete_MeshGeometry(self.__ptr) end
  222. end