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