importer_mesh_instance_3d.cpp 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**************************************************************************/
  2. /* importer_mesh_instance_3d.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 "importer_mesh_instance_3d.h"
  31. #include "scene/resources/importer_mesh.h"
  32. void ImporterMeshInstance3D::set_mesh(const Ref<ImporterMesh> &p_mesh) {
  33. mesh = p_mesh;
  34. }
  35. Ref<ImporterMesh> ImporterMeshInstance3D::get_mesh() const {
  36. return mesh;
  37. }
  38. void ImporterMeshInstance3D::set_skin(const Ref<Skin> &p_skin) {
  39. skin = p_skin;
  40. }
  41. Ref<Skin> ImporterMeshInstance3D::get_skin() const {
  42. return skin;
  43. }
  44. void ImporterMeshInstance3D::set_surface_material(int p_idx, const Ref<Material> &p_material) {
  45. ERR_FAIL_COND(p_idx < 0);
  46. if (p_idx >= surface_materials.size()) {
  47. surface_materials.resize(p_idx + 1);
  48. }
  49. surface_materials.write[p_idx] = p_material;
  50. }
  51. Ref<Material> ImporterMeshInstance3D::get_surface_material(int p_idx) const {
  52. ERR_FAIL_COND_V(p_idx < 0, Ref<Material>());
  53. if (p_idx >= surface_materials.size()) {
  54. return Ref<Material>();
  55. }
  56. return surface_materials[p_idx];
  57. }
  58. void ImporterMeshInstance3D::set_skeleton_path(const NodePath &p_path) {
  59. skeleton_path = p_path;
  60. }
  61. NodePath ImporterMeshInstance3D::get_skeleton_path() const {
  62. return skeleton_path;
  63. }
  64. void ImporterMeshInstance3D::_bind_methods() {
  65. ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &ImporterMeshInstance3D::set_mesh);
  66. ClassDB::bind_method(D_METHOD("get_mesh"), &ImporterMeshInstance3D::get_mesh);
  67. ClassDB::bind_method(D_METHOD("set_skin", "skin"), &ImporterMeshInstance3D::set_skin);
  68. ClassDB::bind_method(D_METHOD("get_skin"), &ImporterMeshInstance3D::get_skin);
  69. ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path"), &ImporterMeshInstance3D::set_skeleton_path);
  70. ClassDB::bind_method(D_METHOD("get_skeleton_path"), &ImporterMeshInstance3D::get_skeleton_path);
  71. ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "ImporterMesh"), "set_mesh", "get_mesh");
  72. ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "skin", PROPERTY_HINT_RESOURCE_TYPE, "Skin"), "set_skin", "get_skin");
  73. ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton"), "set_skeleton_path", "get_skeleton_path");
  74. }