MeshDataTool.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="MeshDataTool" inherits="Reference" version="3.2">
  3. <brief_description>
  4. Helper tool to access and edit [Mesh] data.
  5. </brief_description>
  6. <description>
  7. MeshDataTool provides access to individual vertices in a [Mesh]. It allows users to read and edit vertex data of meshes. It also creates an array of faces and edges.
  8. To use MeshDataTool, load a mesh with [method create_from_surface]. When you are finished editing the data commit the data to a mesh with [method commit_to_surface].
  9. Below is an example of how MeshDataTool may be used.
  10. [codeblock]
  11. var mdt = MeshDataTool.new()
  12. mdt.create_from_surface(mesh, 0)
  13. for i in range(mdt.get_vertex_count()):
  14. var vertex = mdt.get_vertex(i)
  15. ...
  16. mdt.set_vertex(i, vertex)
  17. mesh.surface_remove(0)
  18. mdt.commit_to_surface(mesh)
  19. [/codeblock]
  20. </description>
  21. <tutorials>
  22. </tutorials>
  23. <methods>
  24. <method name="clear">
  25. <return type="void">
  26. </return>
  27. <description>
  28. Clears all data currently in MeshDataTool.
  29. </description>
  30. </method>
  31. <method name="commit_to_surface">
  32. <return type="int" enum="Error">
  33. </return>
  34. <argument index="0" name="mesh" type="ArrayMesh">
  35. </argument>
  36. <description>
  37. Adds a new surface to specified [Mesh] with edited data.
  38. </description>
  39. </method>
  40. <method name="create_from_surface">
  41. <return type="int" enum="Error">
  42. </return>
  43. <argument index="0" name="mesh" type="ArrayMesh">
  44. </argument>
  45. <argument index="1" name="surface" type="int">
  46. </argument>
  47. <description>
  48. Uses specified surface of given [Mesh] to populate data for MeshDataTool.
  49. Requires [Mesh] with primitive type [constant Mesh.PRIMITIVE_TRIANGLES].
  50. </description>
  51. </method>
  52. <method name="get_edge_count" qualifiers="const">
  53. <return type="int">
  54. </return>
  55. <description>
  56. Returns the number of edges in this [Mesh].
  57. </description>
  58. </method>
  59. <method name="get_edge_faces" qualifiers="const">
  60. <return type="PoolIntArray">
  61. </return>
  62. <argument index="0" name="idx" type="int">
  63. </argument>
  64. <description>
  65. Returns array of faces that touch given edge.
  66. </description>
  67. </method>
  68. <method name="get_edge_meta" qualifiers="const">
  69. <return type="Variant">
  70. </return>
  71. <argument index="0" name="idx" type="int">
  72. </argument>
  73. <description>
  74. Returns meta information assigned to given edge.
  75. </description>
  76. </method>
  77. <method name="get_edge_vertex" qualifiers="const">
  78. <return type="int">
  79. </return>
  80. <argument index="0" name="idx" type="int">
  81. </argument>
  82. <argument index="1" name="vertex" type="int">
  83. </argument>
  84. <description>
  85. Returns index of specified vertex connected to given edge.
  86. Vertex argument can only be 0 or 1 because edges are comprised of two vertices.
  87. </description>
  88. </method>
  89. <method name="get_face_count" qualifiers="const">
  90. <return type="int">
  91. </return>
  92. <description>
  93. Returns the number of faces in this [Mesh].
  94. </description>
  95. </method>
  96. <method name="get_face_edge" qualifiers="const">
  97. <return type="int">
  98. </return>
  99. <argument index="0" name="idx" type="int">
  100. </argument>
  101. <argument index="1" name="edge" type="int">
  102. </argument>
  103. <description>
  104. Returns specified edge associated with given face.
  105. Edge argument must 2 or less because a face only has three edges.
  106. </description>
  107. </method>
  108. <method name="get_face_meta" qualifiers="const">
  109. <return type="Variant">
  110. </return>
  111. <argument index="0" name="idx" type="int">
  112. </argument>
  113. <description>
  114. Returns the metadata associated with the given face.
  115. </description>
  116. </method>
  117. <method name="get_face_normal" qualifiers="const">
  118. <return type="Vector3">
  119. </return>
  120. <argument index="0" name="idx" type="int">
  121. </argument>
  122. <description>
  123. Calculates and returns the face normal of the given face.
  124. </description>
  125. </method>
  126. <method name="get_face_vertex" qualifiers="const">
  127. <return type="int">
  128. </return>
  129. <argument index="0" name="idx" type="int">
  130. </argument>
  131. <argument index="1" name="vertex" type="int">
  132. </argument>
  133. <description>
  134. Returns the specified vertex of the given face.
  135. Vertex argument must be 2 or less because faces contain three vertices.
  136. </description>
  137. </method>
  138. <method name="get_format" qualifiers="const">
  139. <return type="int">
  140. </return>
  141. <description>
  142. Returns the [Mesh]'s format. Format is an integer made up of [Mesh] format flags combined together. For example, a mesh containing both vertices and normals would return a format of [code]3[/code] because [constant ArrayMesh.ARRAY_FORMAT_VERTEX] is [code]1[/code] and [constant ArrayMesh.ARRAY_FORMAT_NORMAL] is [code]2[/code].
  143. See [enum ArrayMesh.ArrayFormat] for a list of format flags.
  144. </description>
  145. </method>
  146. <method name="get_material" qualifiers="const">
  147. <return type="Material">
  148. </return>
  149. <description>
  150. Returns the material assigned to the [Mesh].
  151. </description>
  152. </method>
  153. <method name="get_vertex" qualifiers="const">
  154. <return type="Vector3">
  155. </return>
  156. <argument index="0" name="idx" type="int">
  157. </argument>
  158. <description>
  159. Returns the vertex at given index.
  160. </description>
  161. </method>
  162. <method name="get_vertex_bones" qualifiers="const">
  163. <return type="PoolIntArray">
  164. </return>
  165. <argument index="0" name="idx" type="int">
  166. </argument>
  167. <description>
  168. Returns the bones of the given vertex.
  169. </description>
  170. </method>
  171. <method name="get_vertex_color" qualifiers="const">
  172. <return type="Color">
  173. </return>
  174. <argument index="0" name="idx" type="int">
  175. </argument>
  176. <description>
  177. Returns the color of the given vertex.
  178. </description>
  179. </method>
  180. <method name="get_vertex_count" qualifiers="const">
  181. <return type="int">
  182. </return>
  183. <description>
  184. Returns the total number of vertices in [Mesh].
  185. </description>
  186. </method>
  187. <method name="get_vertex_edges" qualifiers="const">
  188. <return type="PoolIntArray">
  189. </return>
  190. <argument index="0" name="idx" type="int">
  191. </argument>
  192. <description>
  193. Returns an array of edges that share the given vertex.
  194. </description>
  195. </method>
  196. <method name="get_vertex_faces" qualifiers="const">
  197. <return type="PoolIntArray">
  198. </return>
  199. <argument index="0" name="idx" type="int">
  200. </argument>
  201. <description>
  202. Returns an array of faces that share the given vertex.
  203. </description>
  204. </method>
  205. <method name="get_vertex_meta" qualifiers="const">
  206. <return type="Variant">
  207. </return>
  208. <argument index="0" name="idx" type="int">
  209. </argument>
  210. <description>
  211. Returns the metadata associated with the given vertex.
  212. </description>
  213. </method>
  214. <method name="get_vertex_normal" qualifiers="const">
  215. <return type="Vector3">
  216. </return>
  217. <argument index="0" name="idx" type="int">
  218. </argument>
  219. <description>
  220. Returns the normal of the given vertex.
  221. </description>
  222. </method>
  223. <method name="get_vertex_tangent" qualifiers="const">
  224. <return type="Plane">
  225. </return>
  226. <argument index="0" name="idx" type="int">
  227. </argument>
  228. <description>
  229. Returns the tangent of the given vertex.
  230. </description>
  231. </method>
  232. <method name="get_vertex_uv" qualifiers="const">
  233. <return type="Vector2">
  234. </return>
  235. <argument index="0" name="idx" type="int">
  236. </argument>
  237. <description>
  238. Returns the UV of the given vertex.
  239. </description>
  240. </method>
  241. <method name="get_vertex_uv2" qualifiers="const">
  242. <return type="Vector2">
  243. </return>
  244. <argument index="0" name="idx" type="int">
  245. </argument>
  246. <description>
  247. Returns the UV2 of the given vertex.
  248. </description>
  249. </method>
  250. <method name="get_vertex_weights" qualifiers="const">
  251. <return type="PoolRealArray">
  252. </return>
  253. <argument index="0" name="idx" type="int">
  254. </argument>
  255. <description>
  256. Returns bone weights of the given vertex.
  257. </description>
  258. </method>
  259. <method name="set_edge_meta">
  260. <return type="void">
  261. </return>
  262. <argument index="0" name="idx" type="int">
  263. </argument>
  264. <argument index="1" name="meta" type="Variant">
  265. </argument>
  266. <description>
  267. Sets the metadata of the given edge.
  268. </description>
  269. </method>
  270. <method name="set_face_meta">
  271. <return type="void">
  272. </return>
  273. <argument index="0" name="idx" type="int">
  274. </argument>
  275. <argument index="1" name="meta" type="Variant">
  276. </argument>
  277. <description>
  278. Sets the metadata of the given face.
  279. </description>
  280. </method>
  281. <method name="set_material">
  282. <return type="void">
  283. </return>
  284. <argument index="0" name="material" type="Material">
  285. </argument>
  286. <description>
  287. Sets the material to be used by newly-constructed [Mesh].
  288. </description>
  289. </method>
  290. <method name="set_vertex">
  291. <return type="void">
  292. </return>
  293. <argument index="0" name="idx" type="int">
  294. </argument>
  295. <argument index="1" name="vertex" type="Vector3">
  296. </argument>
  297. <description>
  298. Sets the position of the given vertex.
  299. </description>
  300. </method>
  301. <method name="set_vertex_bones">
  302. <return type="void">
  303. </return>
  304. <argument index="0" name="idx" type="int">
  305. </argument>
  306. <argument index="1" name="bones" type="PoolIntArray">
  307. </argument>
  308. <description>
  309. Sets the bones of the given vertex.
  310. </description>
  311. </method>
  312. <method name="set_vertex_color">
  313. <return type="void">
  314. </return>
  315. <argument index="0" name="idx" type="int">
  316. </argument>
  317. <argument index="1" name="color" type="Color">
  318. </argument>
  319. <description>
  320. Sets the color of the given vertex.
  321. </description>
  322. </method>
  323. <method name="set_vertex_meta">
  324. <return type="void">
  325. </return>
  326. <argument index="0" name="idx" type="int">
  327. </argument>
  328. <argument index="1" name="meta" type="Variant">
  329. </argument>
  330. <description>
  331. Sets the metadata associated with the given vertex.
  332. </description>
  333. </method>
  334. <method name="set_vertex_normal">
  335. <return type="void">
  336. </return>
  337. <argument index="0" name="idx" type="int">
  338. </argument>
  339. <argument index="1" name="normal" type="Vector3">
  340. </argument>
  341. <description>
  342. Sets the normal of the given vertex.
  343. </description>
  344. </method>
  345. <method name="set_vertex_tangent">
  346. <return type="void">
  347. </return>
  348. <argument index="0" name="idx" type="int">
  349. </argument>
  350. <argument index="1" name="tangent" type="Plane">
  351. </argument>
  352. <description>
  353. Sets the tangent of the given vertex.
  354. </description>
  355. </method>
  356. <method name="set_vertex_uv">
  357. <return type="void">
  358. </return>
  359. <argument index="0" name="idx" type="int">
  360. </argument>
  361. <argument index="1" name="uv" type="Vector2">
  362. </argument>
  363. <description>
  364. Sets the UV of the given vertex.
  365. </description>
  366. </method>
  367. <method name="set_vertex_uv2">
  368. <return type="void">
  369. </return>
  370. <argument index="0" name="idx" type="int">
  371. </argument>
  372. <argument index="1" name="uv2" type="Vector2">
  373. </argument>
  374. <description>
  375. Sets the UV2 of the given vertex.
  376. </description>
  377. </method>
  378. <method name="set_vertex_weights">
  379. <return type="void">
  380. </return>
  381. <argument index="0" name="idx" type="int">
  382. </argument>
  383. <argument index="1" name="weights" type="PoolRealArray">
  384. </argument>
  385. <description>
  386. Sets the bone weights of the given vertex.
  387. </description>
  388. </method>
  389. </methods>
  390. <constants>
  391. </constants>
  392. </class>