| 1 | /**************************************************************************/ |
| 2 | /* gltf_node.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 "gltf_node.h" |
| 32 | |
| 33 | void GLTFNode::_bind_methods() { |
| 34 | ClassDB::bind_method(D_METHOD("get_parent" ), &GLTFNode::get_parent); |
| 35 | ClassDB::bind_method(D_METHOD("set_parent" , "parent" ), &GLTFNode::set_parent); |
| 36 | ClassDB::bind_method(D_METHOD("get_height" ), &GLTFNode::get_height); |
| 37 | ClassDB::bind_method(D_METHOD("set_height" , "height" ), &GLTFNode::set_height); |
| 38 | ClassDB::bind_method(D_METHOD("get_xform" ), &GLTFNode::get_xform); |
| 39 | ClassDB::bind_method(D_METHOD("set_xform" , "xform" ), &GLTFNode::set_xform); |
| 40 | ClassDB::bind_method(D_METHOD("get_mesh" ), &GLTFNode::get_mesh); |
| 41 | ClassDB::bind_method(D_METHOD("set_mesh" , "mesh" ), &GLTFNode::set_mesh); |
| 42 | ClassDB::bind_method(D_METHOD("get_camera" ), &GLTFNode::get_camera); |
| 43 | ClassDB::bind_method(D_METHOD("set_camera" , "camera" ), &GLTFNode::set_camera); |
| 44 | ClassDB::bind_method(D_METHOD("get_skin" ), &GLTFNode::get_skin); |
| 45 | ClassDB::bind_method(D_METHOD("set_skin" , "skin" ), &GLTFNode::set_skin); |
| 46 | ClassDB::bind_method(D_METHOD("get_skeleton" ), &GLTFNode::get_skeleton); |
| 47 | ClassDB::bind_method(D_METHOD("set_skeleton" , "skeleton" ), &GLTFNode::set_skeleton); |
| 48 | ClassDB::bind_method(D_METHOD("get_position" ), &GLTFNode::get_position); |
| 49 | ClassDB::bind_method(D_METHOD("set_position" , "position" ), &GLTFNode::set_position); |
| 50 | ClassDB::bind_method(D_METHOD("get_rotation" ), &GLTFNode::get_rotation); |
| 51 | ClassDB::bind_method(D_METHOD("set_rotation" , "rotation" ), &GLTFNode::set_rotation); |
| 52 | ClassDB::bind_method(D_METHOD("get_scale" ), &GLTFNode::get_scale); |
| 53 | ClassDB::bind_method(D_METHOD("set_scale" , "scale" ), &GLTFNode::set_scale); |
| 54 | ClassDB::bind_method(D_METHOD("get_children" ), &GLTFNode::get_children); |
| 55 | ClassDB::bind_method(D_METHOD("set_children" , "children" ), &GLTFNode::set_children); |
| 56 | ClassDB::bind_method(D_METHOD("get_light" ), &GLTFNode::get_light); |
| 57 | ClassDB::bind_method(D_METHOD("set_light" , "light" ), &GLTFNode::set_light); |
| 58 | ClassDB::bind_method(D_METHOD("get_additional_data" , "extension_name" ), &GLTFNode::get_additional_data); |
| 59 | ClassDB::bind_method(D_METHOD("set_additional_data" , "extension_name" , "additional_data" ), &GLTFNode::set_additional_data); |
| 60 | |
| 61 | ADD_PROPERTY(PropertyInfo(Variant::INT, "parent" ), "set_parent" , "get_parent" ); // GLTFNodeIndex |
| 62 | ADD_PROPERTY(PropertyInfo(Variant::INT, "height" ), "set_height" , "get_height" ); // int |
| 63 | ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "xform" ), "set_xform" , "get_xform" ); // Transform3D |
| 64 | ADD_PROPERTY(PropertyInfo(Variant::INT, "mesh" ), "set_mesh" , "get_mesh" ); // GLTFMeshIndex |
| 65 | ADD_PROPERTY(PropertyInfo(Variant::INT, "camera" ), "set_camera" , "get_camera" ); // GLTFCameraIndex |
| 66 | ADD_PROPERTY(PropertyInfo(Variant::INT, "skin" ), "set_skin" , "get_skin" ); // GLTFSkinIndex |
| 67 | ADD_PROPERTY(PropertyInfo(Variant::INT, "skeleton" ), "set_skeleton" , "get_skeleton" ); // GLTFSkeletonIndex |
| 68 | ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position" ), "set_position" , "get_position" ); // Vector3 |
| 69 | ADD_PROPERTY(PropertyInfo(Variant::QUATERNION, "rotation" ), "set_rotation" , "get_rotation" ); // Quaternion |
| 70 | ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale" ), "set_scale" , "get_scale" ); // Vector3 |
| 71 | ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "children" ), "set_children" , "get_children" ); // Vector<int> |
| 72 | ADD_PROPERTY(PropertyInfo(Variant::INT, "light" ), "set_light" , "get_light" ); // GLTFLightIndex |
| 73 | } |
| 74 | |
| 75 | GLTFNodeIndex GLTFNode::get_parent() { |
| 76 | return parent; |
| 77 | } |
| 78 | |
| 79 | void GLTFNode::set_parent(GLTFNodeIndex p_parent) { |
| 80 | parent = p_parent; |
| 81 | } |
| 82 | |
| 83 | int GLTFNode::get_height() { |
| 84 | return height; |
| 85 | } |
| 86 | |
| 87 | void GLTFNode::set_height(int p_height) { |
| 88 | height = p_height; |
| 89 | } |
| 90 | |
| 91 | Transform3D GLTFNode::get_xform() { |
| 92 | return xform; |
| 93 | } |
| 94 | |
| 95 | void GLTFNode::set_xform(Transform3D p_xform) { |
| 96 | xform = p_xform; |
| 97 | } |
| 98 | |
| 99 | GLTFMeshIndex GLTFNode::get_mesh() { |
| 100 | return mesh; |
| 101 | } |
| 102 | |
| 103 | void GLTFNode::set_mesh(GLTFMeshIndex p_mesh) { |
| 104 | mesh = p_mesh; |
| 105 | } |
| 106 | |
| 107 | GLTFCameraIndex GLTFNode::get_camera() { |
| 108 | return camera; |
| 109 | } |
| 110 | |
| 111 | void GLTFNode::set_camera(GLTFCameraIndex p_camera) { |
| 112 | camera = p_camera; |
| 113 | } |
| 114 | |
| 115 | GLTFSkinIndex GLTFNode::get_skin() { |
| 116 | return skin; |
| 117 | } |
| 118 | |
| 119 | void GLTFNode::set_skin(GLTFSkinIndex p_skin) { |
| 120 | skin = p_skin; |
| 121 | } |
| 122 | |
| 123 | GLTFSkeletonIndex GLTFNode::get_skeleton() { |
| 124 | return skeleton; |
| 125 | } |
| 126 | |
| 127 | void GLTFNode::set_skeleton(GLTFSkeletonIndex p_skeleton) { |
| 128 | skeleton = p_skeleton; |
| 129 | } |
| 130 | |
| 131 | Vector3 GLTFNode::get_position() { |
| 132 | return position; |
| 133 | } |
| 134 | |
| 135 | void GLTFNode::set_position(Vector3 p_position) { |
| 136 | position = p_position; |
| 137 | } |
| 138 | |
| 139 | Quaternion GLTFNode::get_rotation() { |
| 140 | return rotation; |
| 141 | } |
| 142 | |
| 143 | void GLTFNode::set_rotation(Quaternion p_rotation) { |
| 144 | rotation = p_rotation; |
| 145 | } |
| 146 | |
| 147 | Vector3 GLTFNode::get_scale() { |
| 148 | return scale; |
| 149 | } |
| 150 | |
| 151 | void GLTFNode::set_scale(Vector3 p_scale) { |
| 152 | scale = p_scale; |
| 153 | } |
| 154 | |
| 155 | Vector<int> GLTFNode::get_children() { |
| 156 | return children; |
| 157 | } |
| 158 | |
| 159 | void GLTFNode::set_children(Vector<int> p_children) { |
| 160 | children = p_children; |
| 161 | } |
| 162 | |
| 163 | GLTFLightIndex GLTFNode::get_light() { |
| 164 | return light; |
| 165 | } |
| 166 | |
| 167 | void GLTFNode::set_light(GLTFLightIndex p_light) { |
| 168 | light = p_light; |
| 169 | } |
| 170 | |
| 171 | Variant GLTFNode::get_additional_data(const StringName &p_extension_name) { |
| 172 | return additional_data[p_extension_name]; |
| 173 | } |
| 174 | |
| 175 | void GLTFNode::set_additional_data(const StringName &p_extension_name, Variant p_additional_data) { |
| 176 | additional_data[p_extension_name] = p_additional_data; |
| 177 | } |
| 178 | |