mesh_data_tool.cpp 18 KB

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