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