mesh_data_tool.cpp 18 KB

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