2
0

mesh_data_tool.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. /*************************************************************************/
  2. /* mesh_data_tool.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "mesh_data_tool.h"
  31. void MeshDataTool::clear() {
  32. vertices.clear();
  33. edges.clear();
  34. faces.clear();
  35. material = Ref<Material>();
  36. format = 0;
  37. }
  38. Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surface) {
  39. ERR_FAIL_COND_V(p_mesh.is_null(), ERR_INVALID_PARAMETER);
  40. ERR_FAIL_COND_V(p_mesh->surface_get_primitive_type(p_surface) != Mesh::PRIMITIVE_TRIANGLES, ERR_INVALID_PARAMETER);
  41. Array arrays = p_mesh->surface_get_arrays(p_surface);
  42. ERR_FAIL_COND_V(arrays.is_empty(), ERR_INVALID_PARAMETER);
  43. Vector<Vector3> varray = arrays[Mesh::ARRAY_VERTEX];
  44. int vcount = varray.size();
  45. ERR_FAIL_COND_V(vcount == 0, ERR_INVALID_PARAMETER);
  46. Vector<int> indices;
  47. if (arrays[Mesh::ARRAY_INDEX].get_type() != Variant::NIL) {
  48. indices = arrays[Mesh::ARRAY_INDEX];
  49. } else {
  50. //make code simpler
  51. indices.resize(vcount);
  52. int *iw = indices.ptrw();
  53. for (int i = 0; i < vcount; i++) {
  54. iw[i] = i;
  55. }
  56. }
  57. int icount = indices.size();
  58. const int *r = indices.ptr();
  59. ERR_FAIL_COND_V(icount == 0, ERR_INVALID_PARAMETER);
  60. ERR_FAIL_COND_V(icount % 3, ERR_INVALID_PARAMETER);
  61. for (int i = 0; i < icount; i++) {
  62. ERR_FAIL_INDEX_V(r[i], vcount, ERR_INVALID_PARAMETER);
  63. }
  64. clear();
  65. format = p_mesh->surface_get_format(p_surface);
  66. material = p_mesh->surface_get_material(p_surface);
  67. const Vector3 *vr = varray.ptr();
  68. const Vector3 *nr = nullptr;
  69. if (arrays[Mesh::ARRAY_NORMAL].get_type() != Variant::NIL) {
  70. nr = arrays[Mesh::ARRAY_NORMAL].operator Vector<Vector3>().ptr();
  71. }
  72. const real_t *ta = nullptr;
  73. if (arrays[Mesh::ARRAY_TANGENT].get_type() != Variant::NIL) {
  74. ta = arrays[Mesh::ARRAY_TANGENT].operator Vector<real_t>().ptr();
  75. }
  76. const Vector2 *uv = nullptr;
  77. if (arrays[Mesh::ARRAY_TEX_UV].get_type() != Variant::NIL) {
  78. uv = arrays[Mesh::ARRAY_TEX_UV].operator Vector<Vector2>().ptr();
  79. }
  80. const Vector2 *uv2 = nullptr;
  81. if (arrays[Mesh::ARRAY_TEX_UV2].get_type() != Variant::NIL) {
  82. uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator Vector<Vector2>().ptr();
  83. }
  84. const Color *col = nullptr;
  85. if (arrays[Mesh::ARRAY_COLOR].get_type() != Variant::NIL) {
  86. col = arrays[Mesh::ARRAY_COLOR].operator Vector<Color>().ptr();
  87. }
  88. const int *bo = nullptr;
  89. if (arrays[Mesh::ARRAY_BONES].get_type() != Variant::NIL) {
  90. bo = arrays[Mesh::ARRAY_BONES].operator Vector<int>().ptr();
  91. }
  92. const float *we = nullptr;
  93. if (arrays[Mesh::ARRAY_WEIGHTS].get_type() != Variant::NIL) {
  94. we = arrays[Mesh::ARRAY_WEIGHTS].operator Vector<float>().ptr();
  95. }
  96. vertices.resize(vcount);
  97. for (int i = 0; i < vcount; i++) {
  98. Vertex v;
  99. v.vertex = vr[i];
  100. if (nr) {
  101. v.normal = nr[i];
  102. }
  103. if (ta) {
  104. v.tangent = Plane(ta[i * 4 + 0], ta[i * 4 + 1], ta[i * 4 + 2], ta[i * 4 + 3]);
  105. }
  106. if (uv) {
  107. v.uv = uv[i];
  108. }
  109. if (uv2) {
  110. v.uv2 = uv2[i];
  111. }
  112. if (col) {
  113. v.color = col[i];
  114. }
  115. if (we) {
  116. v.weights.push_back(we[i * 4 + 0]);
  117. v.weights.push_back(we[i * 4 + 1]);
  118. v.weights.push_back(we[i * 4 + 2]);
  119. v.weights.push_back(we[i * 4 + 3]);
  120. }
  121. if (bo) {
  122. v.bones.push_back(bo[i * 4 + 0]);
  123. v.bones.push_back(bo[i * 4 + 1]);
  124. v.bones.push_back(bo[i * 4 + 2]);
  125. v.bones.push_back(bo[i * 4 + 3]);
  126. }
  127. vertices.write[i] = v;
  128. }
  129. Map<Point2i, int> edge_indices;
  130. for (int i = 0; i < icount; i += 3) {
  131. Vertex *v[3] = { &vertices.write[r[i + 0]], &vertices.write[r[i + 1]], &vertices.write[r[i + 2]] };
  132. int fidx = faces.size();
  133. Face face;
  134. for (int j = 0; j < 3; j++) {
  135. face.v[j] = r[i + j];
  136. Point2i edge(r[i + j], r[i + (j + 1) % 3]);
  137. if (edge.x > edge.y) {
  138. SWAP(edge.x, edge.y);
  139. }
  140. if (edge_indices.has(edge)) {
  141. face.edges[j] = edge_indices[edge];
  142. } else {
  143. face.edges[j] = edge_indices.size();
  144. edge_indices[edge] = face.edges[j];
  145. Edge e;
  146. e.vertex[0] = edge.x;
  147. e.vertex[1] = edge.y;
  148. edges.push_back(e);
  149. v[j]->edges.push_back(face.edges[j]);
  150. v[(j + 1) % 3]->edges.push_back(face.edges[j]);
  151. }
  152. edges.write[face.edges[j]].faces.push_back(fidx);
  153. v[j]->faces.push_back(fidx);
  154. }
  155. faces.push_back(face);
  156. }
  157. return OK;
  158. }
  159. Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) {
  160. ERR_FAIL_COND_V(p_mesh.is_null(), ERR_INVALID_PARAMETER);
  161. Array arr;
  162. arr.resize(Mesh::ARRAY_MAX);
  163. int vcount = vertices.size();
  164. Vector<Vector3> v;
  165. Vector<Vector3> n;
  166. Vector<real_t> t;
  167. Vector<Vector2> u;
  168. Vector<Vector2> u2;
  169. Vector<Color> c;
  170. Vector<int> b;
  171. Vector<real_t> w;
  172. Vector<int> in;
  173. {
  174. v.resize(vcount);
  175. Vector3 *vr = v.ptrw();
  176. Vector3 *nr = nullptr;
  177. if (format & Mesh::ARRAY_FORMAT_NORMAL) {
  178. n.resize(vcount);
  179. nr = n.ptrw();
  180. }
  181. real_t *ta = nullptr;
  182. if (format & Mesh::ARRAY_FORMAT_TANGENT) {
  183. t.resize(vcount * 4);
  184. ta = t.ptrw();
  185. }
  186. Vector2 *uv = nullptr;
  187. if (format & Mesh::ARRAY_FORMAT_TEX_UV) {
  188. u.resize(vcount);
  189. uv = u.ptrw();
  190. }
  191. Vector2 *uv2 = nullptr;
  192. if (format & Mesh::ARRAY_FORMAT_TEX_UV2) {
  193. u2.resize(vcount);
  194. uv2 = u2.ptrw();
  195. }
  196. Color *col = nullptr;
  197. if (format & Mesh::ARRAY_FORMAT_COLOR) {
  198. c.resize(vcount);
  199. col = c.ptrw();
  200. }
  201. int *bo = nullptr;
  202. if (format & Mesh::ARRAY_FORMAT_BONES) {
  203. b.resize(vcount * 4);
  204. bo = b.ptrw();
  205. }
  206. real_t *we = nullptr;
  207. if (format & Mesh::ARRAY_FORMAT_WEIGHTS) {
  208. w.resize(vcount * 4);
  209. we = w.ptrw();
  210. }
  211. for (int i = 0; i < vcount; i++) {
  212. const Vertex &vtx = vertices[i];
  213. vr[i] = vtx.vertex;
  214. if (nr) {
  215. nr[i] = vtx.normal;
  216. }
  217. if (ta) {
  218. ta[i * 4 + 0] = vtx.tangent.normal.x;
  219. ta[i * 4 + 1] = vtx.tangent.normal.y;
  220. ta[i * 4 + 2] = vtx.tangent.normal.z;
  221. ta[i * 4 + 3] = vtx.tangent.d;
  222. }
  223. if (uv) {
  224. uv[i] = vtx.uv;
  225. }
  226. if (uv2) {
  227. uv2[i] = vtx.uv2;
  228. }
  229. if (col) {
  230. col[i] = vtx.color;
  231. }
  232. if (we) {
  233. we[i * 4 + 0] = vtx.weights[0];
  234. we[i * 4 + 1] = vtx.weights[1];
  235. we[i * 4 + 2] = vtx.weights[2];
  236. we[i * 4 + 3] = vtx.weights[3];
  237. }
  238. if (bo) {
  239. bo[i * 4 + 0] = vtx.bones[0];
  240. bo[i * 4 + 1] = vtx.bones[1];
  241. bo[i * 4 + 2] = vtx.bones[2];
  242. bo[i * 4 + 3] = vtx.bones[3];
  243. }
  244. }
  245. int fc = faces.size();
  246. in.resize(fc * 3);
  247. int *iw = in.ptrw();
  248. for (int i = 0; i < fc; i++) {
  249. iw[i * 3 + 0] = faces[i].v[0];
  250. iw[i * 3 + 1] = faces[i].v[1];
  251. iw[i * 3 + 2] = faces[i].v[2];
  252. }
  253. }
  254. arr[Mesh::ARRAY_VERTEX] = v;
  255. arr[Mesh::ARRAY_INDEX] = in;
  256. if (n.size()) {
  257. arr[Mesh::ARRAY_NORMAL] = n;
  258. }
  259. if (c.size()) {
  260. arr[Mesh::ARRAY_COLOR] = c;
  261. }
  262. if (u.size()) {
  263. arr[Mesh::ARRAY_TEX_UV] = u;
  264. }
  265. if (u2.size()) {
  266. arr[Mesh::ARRAY_TEX_UV2] = u2;
  267. }
  268. if (t.size()) {
  269. arr[Mesh::ARRAY_TANGENT] = t;
  270. }
  271. if (b.size()) {
  272. arr[Mesh::ARRAY_BONES] = b;
  273. }
  274. if (w.size()) {
  275. arr[Mesh::ARRAY_WEIGHTS] = w;
  276. }
  277. Ref<ArrayMesh> ncmesh = p_mesh;
  278. int sc = ncmesh->get_surface_count();
  279. ncmesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arr);
  280. ncmesh->surface_set_material(sc, material);
  281. return OK;
  282. }
  283. int MeshDataTool::get_format() const {
  284. return format;
  285. }
  286. int MeshDataTool::get_vertex_count() const {
  287. return vertices.size();
  288. }
  289. int MeshDataTool::get_edge_count() const {
  290. return edges.size();
  291. }
  292. int MeshDataTool::get_face_count() const {
  293. return faces.size();
  294. }
  295. Vector3 MeshDataTool::get_vertex(int p_idx) const {
  296. ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector3());
  297. return vertices[p_idx].vertex;
  298. }
  299. void MeshDataTool::set_vertex(int p_idx, const Vector3 &p_vertex) {
  300. ERR_FAIL_INDEX(p_idx, vertices.size());
  301. vertices.write[p_idx].vertex = p_vertex;
  302. }
  303. Vector3 MeshDataTool::get_vertex_normal(int p_idx) const {
  304. ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector3());
  305. return vertices[p_idx].normal;
  306. }
  307. void MeshDataTool::set_vertex_normal(int p_idx, const Vector3 &p_normal) {
  308. ERR_FAIL_INDEX(p_idx, vertices.size());
  309. vertices.write[p_idx].normal = p_normal;
  310. format |= Mesh::ARRAY_FORMAT_NORMAL;
  311. }
  312. Plane MeshDataTool::get_vertex_tangent(int p_idx) const {
  313. ERR_FAIL_INDEX_V(p_idx, vertices.size(), Plane());
  314. return vertices[p_idx].tangent;
  315. }
  316. void MeshDataTool::set_vertex_tangent(int p_idx, const Plane &p_tangent) {
  317. ERR_FAIL_INDEX(p_idx, vertices.size());
  318. vertices.write[p_idx].tangent = p_tangent;
  319. format |= Mesh::ARRAY_FORMAT_TANGENT;
  320. }
  321. Vector2 MeshDataTool::get_vertex_uv(int p_idx) const {
  322. ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector2());
  323. return vertices[p_idx].uv;
  324. }
  325. void MeshDataTool::set_vertex_uv(int p_idx, const Vector2 &p_uv) {
  326. ERR_FAIL_INDEX(p_idx, vertices.size());
  327. vertices.write[p_idx].uv = p_uv;
  328. format |= Mesh::ARRAY_FORMAT_TEX_UV;
  329. }
  330. Vector2 MeshDataTool::get_vertex_uv2(int p_idx) const {
  331. ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector2());
  332. return vertices[p_idx].uv2;
  333. }
  334. void MeshDataTool::set_vertex_uv2(int p_idx, const Vector2 &p_uv2) {
  335. ERR_FAIL_INDEX(p_idx, vertices.size());
  336. vertices.write[p_idx].uv2 = p_uv2;
  337. format |= Mesh::ARRAY_FORMAT_TEX_UV2;
  338. }
  339. Color MeshDataTool::get_vertex_color(int p_idx) const {
  340. ERR_FAIL_INDEX_V(p_idx, vertices.size(), Color());
  341. return vertices[p_idx].color;
  342. }
  343. void MeshDataTool::set_vertex_color(int p_idx, const Color &p_color) {
  344. ERR_FAIL_INDEX(p_idx, vertices.size());
  345. vertices.write[p_idx].color = p_color;
  346. format |= Mesh::ARRAY_FORMAT_COLOR;
  347. }
  348. Vector<int> MeshDataTool::get_vertex_bones(int p_idx) const {
  349. ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>());
  350. return vertices[p_idx].bones;
  351. }
  352. void MeshDataTool::set_vertex_bones(int p_idx, const Vector<int> &p_bones) {
  353. ERR_FAIL_INDEX(p_idx, vertices.size());
  354. ERR_FAIL_COND(p_bones.size() != 4);
  355. vertices.write[p_idx].bones = p_bones;
  356. format |= Mesh::ARRAY_FORMAT_BONES;
  357. }
  358. Vector<float> MeshDataTool::get_vertex_weights(int p_idx) const {
  359. ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<float>());
  360. return vertices[p_idx].weights;
  361. }
  362. void MeshDataTool::set_vertex_weights(int p_idx, const Vector<float> &p_weights) {
  363. ERR_FAIL_INDEX(p_idx, vertices.size());
  364. ERR_FAIL_COND(p_weights.size() != 4);
  365. vertices.write[p_idx].weights = p_weights;
  366. format |= Mesh::ARRAY_FORMAT_WEIGHTS;
  367. }
  368. Variant MeshDataTool::get_vertex_meta(int p_idx) const {
  369. ERR_FAIL_INDEX_V(p_idx, vertices.size(), Variant());
  370. return vertices[p_idx].meta;
  371. }
  372. void MeshDataTool::set_vertex_meta(int p_idx, const Variant &p_meta) {
  373. ERR_FAIL_INDEX(p_idx, vertices.size());
  374. vertices.write[p_idx].meta = p_meta;
  375. }
  376. Vector<int> MeshDataTool::get_vertex_edges(int p_idx) const {
  377. ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>());
  378. return vertices[p_idx].edges;
  379. }
  380. Vector<int> MeshDataTool::get_vertex_faces(int p_idx) const {
  381. ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>());
  382. return vertices[p_idx].faces;
  383. }
  384. int MeshDataTool::get_edge_vertex(int p_edge, int p_vertex) const {
  385. ERR_FAIL_INDEX_V(p_edge, edges.size(), -1);
  386. ERR_FAIL_INDEX_V(p_vertex, 2, -1);
  387. return edges[p_edge].vertex[p_vertex];
  388. }
  389. Vector<int> MeshDataTool::get_edge_faces(int p_edge) const {
  390. ERR_FAIL_INDEX_V(p_edge, edges.size(), Vector<int>());
  391. return edges[p_edge].faces;
  392. }
  393. Variant MeshDataTool::get_edge_meta(int p_idx) const {
  394. ERR_FAIL_INDEX_V(p_idx, edges.size(), Variant());
  395. return edges[p_idx].meta;
  396. }
  397. void MeshDataTool::set_edge_meta(int p_idx, const Variant &p_meta) {
  398. ERR_FAIL_INDEX(p_idx, edges.size());
  399. edges.write[p_idx].meta = p_meta;
  400. }
  401. int MeshDataTool::get_face_vertex(int p_face, int p_vertex) const {
  402. ERR_FAIL_INDEX_V(p_face, faces.size(), -1);
  403. ERR_FAIL_INDEX_V(p_vertex, 3, -1);
  404. return faces[p_face].v[p_vertex];
  405. }
  406. int MeshDataTool::get_face_edge(int p_face, int p_vertex) const {
  407. ERR_FAIL_INDEX_V(p_face, faces.size(), -1);
  408. ERR_FAIL_INDEX_V(p_vertex, 3, -1);
  409. return faces[p_face].edges[p_vertex];
  410. }
  411. Variant MeshDataTool::get_face_meta(int p_face) const {
  412. ERR_FAIL_INDEX_V(p_face, faces.size(), Variant());
  413. return faces[p_face].meta;
  414. }
  415. void MeshDataTool::set_face_meta(int p_face, const Variant &p_meta) {
  416. ERR_FAIL_INDEX(p_face, faces.size());
  417. faces.write[p_face].meta = p_meta;
  418. }
  419. Vector3 MeshDataTool::get_face_normal(int p_face) const {
  420. ERR_FAIL_INDEX_V(p_face, faces.size(), Vector3());
  421. Vector3 v0 = vertices[faces[p_face].v[0]].vertex;
  422. Vector3 v1 = vertices[faces[p_face].v[1]].vertex;
  423. Vector3 v2 = vertices[faces[p_face].v[2]].vertex;
  424. return Plane(v0, v1, v2).normal;
  425. }
  426. Ref<Material> MeshDataTool::get_material() const {
  427. return material;
  428. }
  429. void MeshDataTool::set_material(const Ref<Material> &p_material) {
  430. material = p_material;
  431. }
  432. void MeshDataTool::_bind_methods() {
  433. ClassDB::bind_method(D_METHOD("clear"), &MeshDataTool::clear);
  434. ClassDB::bind_method(D_METHOD("create_from_surface", "mesh", "surface"), &MeshDataTool::create_from_surface);
  435. ClassDB::bind_method(D_METHOD("commit_to_surface", "mesh"), &MeshDataTool::commit_to_surface);
  436. ClassDB::bind_method(D_METHOD("get_format"), &MeshDataTool::get_format);
  437. ClassDB::bind_method(D_METHOD("get_vertex_count"), &MeshDataTool::get_vertex_count);
  438. ClassDB::bind_method(D_METHOD("get_edge_count"), &MeshDataTool::get_edge_count);
  439. ClassDB::bind_method(D_METHOD("get_face_count"), &MeshDataTool::get_face_count);
  440. ClassDB::bind_method(D_METHOD("set_vertex", "idx", "vertex"), &MeshDataTool::set_vertex);
  441. ClassDB::bind_method(D_METHOD("get_vertex", "idx"), &MeshDataTool::get_vertex);
  442. ClassDB::bind_method(D_METHOD("set_vertex_normal", "idx", "normal"), &MeshDataTool::set_vertex_normal);
  443. ClassDB::bind_method(D_METHOD("get_vertex_normal", "idx"), &MeshDataTool::get_vertex_normal);
  444. ClassDB::bind_method(D_METHOD("set_vertex_tangent", "idx", "tangent"), &MeshDataTool::set_vertex_tangent);
  445. ClassDB::bind_method(D_METHOD("get_vertex_tangent", "idx"), &MeshDataTool::get_vertex_tangent);
  446. ClassDB::bind_method(D_METHOD("set_vertex_uv", "idx", "uv"), &MeshDataTool::set_vertex_uv);
  447. ClassDB::bind_method(D_METHOD("get_vertex_uv", "idx"), &MeshDataTool::get_vertex_uv);
  448. ClassDB::bind_method(D_METHOD("set_vertex_uv2", "idx", "uv2"), &MeshDataTool::set_vertex_uv2);
  449. ClassDB::bind_method(D_METHOD("get_vertex_uv2", "idx"), &MeshDataTool::get_vertex_uv2);
  450. ClassDB::bind_method(D_METHOD("set_vertex_color", "idx", "color"), &MeshDataTool::set_vertex_color);
  451. ClassDB::bind_method(D_METHOD("get_vertex_color", "idx"), &MeshDataTool::get_vertex_color);
  452. ClassDB::bind_method(D_METHOD("set_vertex_bones", "idx", "bones"), &MeshDataTool::set_vertex_bones);
  453. ClassDB::bind_method(D_METHOD("get_vertex_bones", "idx"), &MeshDataTool::get_vertex_bones);
  454. ClassDB::bind_method(D_METHOD("set_vertex_weights", "idx", "weights"), &MeshDataTool::set_vertex_weights);
  455. ClassDB::bind_method(D_METHOD("get_vertex_weights", "idx"), &MeshDataTool::get_vertex_weights);
  456. ClassDB::bind_method(D_METHOD("set_vertex_meta", "idx", "meta"), &MeshDataTool::set_vertex_meta);
  457. ClassDB::bind_method(D_METHOD("get_vertex_meta", "idx"), &MeshDataTool::get_vertex_meta);
  458. ClassDB::bind_method(D_METHOD("get_vertex_edges", "idx"), &MeshDataTool::get_vertex_edges);
  459. ClassDB::bind_method(D_METHOD("get_vertex_faces", "idx"), &MeshDataTool::get_vertex_faces);
  460. ClassDB::bind_method(D_METHOD("get_edge_vertex", "idx", "vertex"), &MeshDataTool::get_edge_vertex);
  461. ClassDB::bind_method(D_METHOD("get_edge_faces", "idx"), &MeshDataTool::get_edge_faces);
  462. ClassDB::bind_method(D_METHOD("set_edge_meta", "idx", "meta"), &MeshDataTool::set_edge_meta);
  463. ClassDB::bind_method(D_METHOD("get_edge_meta", "idx"), &MeshDataTool::get_edge_meta);
  464. ClassDB::bind_method(D_METHOD("get_face_vertex", "idx", "vertex"), &MeshDataTool::get_face_vertex);
  465. ClassDB::bind_method(D_METHOD("get_face_edge", "idx", "edge"), &MeshDataTool::get_face_edge);
  466. ClassDB::bind_method(D_METHOD("set_face_meta", "idx", "meta"), &MeshDataTool::set_face_meta);
  467. ClassDB::bind_method(D_METHOD("get_face_meta", "idx"), &MeshDataTool::get_face_meta);
  468. ClassDB::bind_method(D_METHOD("get_face_normal", "idx"), &MeshDataTool::get_face_normal);
  469. ClassDB::bind_method(D_METHOD("set_material", "material"), &MeshDataTool::set_material);
  470. ClassDB::bind_method(D_METHOD("get_material"), &MeshDataTool::get_material);
  471. }
  472. MeshDataTool::MeshDataTool() {
  473. clear();
  474. }