mesh_data_tool.cpp 18 KB

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