gltf_node.cpp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. #include "gltf_node.h"
  31. void GLTFNode::_bind_methods() {
  32. ClassDB::bind_method(D_METHOD("get_parent"), &GLTFNode::get_parent);
  33. ClassDB::bind_method(D_METHOD("set_parent", "parent"), &GLTFNode::set_parent);
  34. ClassDB::bind_method(D_METHOD("get_height"), &GLTFNode::get_height);
  35. ClassDB::bind_method(D_METHOD("set_height", "height"), &GLTFNode::set_height);
  36. ClassDB::bind_method(D_METHOD("get_xform"), &GLTFNode::get_xform);
  37. ClassDB::bind_method(D_METHOD("set_xform", "xform"), &GLTFNode::set_xform);
  38. ClassDB::bind_method(D_METHOD("get_mesh"), &GLTFNode::get_mesh);
  39. ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &GLTFNode::set_mesh);
  40. ClassDB::bind_method(D_METHOD("get_camera"), &GLTFNode::get_camera);
  41. ClassDB::bind_method(D_METHOD("set_camera", "camera"), &GLTFNode::set_camera);
  42. ClassDB::bind_method(D_METHOD("get_skin"), &GLTFNode::get_skin);
  43. ClassDB::bind_method(D_METHOD("set_skin", "skin"), &GLTFNode::set_skin);
  44. ClassDB::bind_method(D_METHOD("get_skeleton"), &GLTFNode::get_skeleton);
  45. ClassDB::bind_method(D_METHOD("set_skeleton", "skeleton"), &GLTFNode::set_skeleton);
  46. ClassDB::bind_method(D_METHOD("get_joint"), &GLTFNode::get_joint);
  47. ClassDB::bind_method(D_METHOD("set_joint", "joint"), &GLTFNode::set_joint);
  48. ClassDB::bind_method(D_METHOD("get_translation"), &GLTFNode::get_translation);
  49. ClassDB::bind_method(D_METHOD("set_translation", "translation"), &GLTFNode::set_translation);
  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. ADD_PROPERTY(PropertyInfo(Variant::INT, "parent"), "set_parent", "get_parent"); // GLTFNodeIndex
  61. ADD_PROPERTY(PropertyInfo(Variant::INT, "height"), "set_height", "get_height"); // int
  62. ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "xform"), "set_xform", "get_xform"); // Transform
  63. ADD_PROPERTY(PropertyInfo(Variant::INT, "mesh"), "set_mesh", "get_mesh"); // GLTFMeshIndex
  64. ADD_PROPERTY(PropertyInfo(Variant::INT, "camera"), "set_camera", "get_camera"); // GLTFCameraIndex
  65. ADD_PROPERTY(PropertyInfo(Variant::INT, "skin"), "set_skin", "get_skin"); // GLTFSkinIndex
  66. ADD_PROPERTY(PropertyInfo(Variant::INT, "skeleton"), "set_skeleton", "get_skeleton"); // GLTFSkeletonIndex
  67. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "joint"), "set_joint", "get_joint"); // bool
  68. ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "translation"), "set_translation", "get_translation"); // Vector3
  69. ADD_PROPERTY(PropertyInfo(Variant::QUAT, "rotation"), "set_rotation", "get_rotation"); // Quat
  70. ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale"), "set_scale", "get_scale"); // Vector3
  71. ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "children"), "set_children", "get_children"); // Vector<int>
  72. ADD_PROPERTY(PropertyInfo(Variant::INT, "light"), "set_light", "get_light"); // GLTFLightIndex
  73. }
  74. GLTFNodeIndex GLTFNode::get_parent() {
  75. return parent;
  76. }
  77. void GLTFNode::set_parent(GLTFNodeIndex p_parent) {
  78. parent = p_parent;
  79. }
  80. int GLTFNode::get_height() {
  81. return height;
  82. }
  83. void GLTFNode::set_height(int p_height) {
  84. height = p_height;
  85. }
  86. Transform GLTFNode::get_xform() {
  87. return xform;
  88. }
  89. void GLTFNode::set_xform(Transform p_xform) {
  90. xform = p_xform;
  91. }
  92. GLTFMeshIndex GLTFNode::get_mesh() {
  93. return mesh;
  94. }
  95. void GLTFNode::set_mesh(GLTFMeshIndex p_mesh) {
  96. mesh = p_mesh;
  97. }
  98. GLTFCameraIndex GLTFNode::get_camera() {
  99. return camera;
  100. }
  101. void GLTFNode::set_camera(GLTFCameraIndex p_camera) {
  102. camera = p_camera;
  103. }
  104. GLTFSkinIndex GLTFNode::get_skin() {
  105. return skin;
  106. }
  107. void GLTFNode::set_skin(GLTFSkinIndex p_skin) {
  108. skin = p_skin;
  109. }
  110. GLTFSkeletonIndex GLTFNode::get_skeleton() {
  111. return skeleton;
  112. }
  113. void GLTFNode::set_skeleton(GLTFSkeletonIndex p_skeleton) {
  114. skeleton = p_skeleton;
  115. }
  116. bool GLTFNode::get_joint() {
  117. return joint;
  118. }
  119. void GLTFNode::set_joint(bool p_joint) {
  120. joint = p_joint;
  121. }
  122. Vector3 GLTFNode::get_translation() {
  123. return translation;
  124. }
  125. void GLTFNode::set_translation(Vector3 p_translation) {
  126. translation = p_translation;
  127. }
  128. Quat GLTFNode::get_rotation() {
  129. return rotation;
  130. }
  131. void GLTFNode::set_rotation(Quat p_rotation) {
  132. rotation = p_rotation;
  133. }
  134. Vector3 GLTFNode::get_scale() {
  135. return scale;
  136. }
  137. void GLTFNode::set_scale(Vector3 p_scale) {
  138. scale = p_scale;
  139. }
  140. Vector<int> GLTFNode::get_children() {
  141. return children;
  142. }
  143. void GLTFNode::set_children(Vector<int> p_children) {
  144. children = p_children;
  145. }
  146. GLTFLightIndex GLTFNode::get_light() {
  147. return light;
  148. }
  149. void GLTFNode::set_light(GLTFLightIndex p_light) {
  150. light = p_light;
  151. }
  152. Variant GLTFNode::get_additional_data(const String &p_extension_name) {
  153. return additional_data[p_extension_name];
  154. }
  155. void GLTFNode::set_additional_data(const String &p_extension_name, Variant p_additional_data) {
  156. additional_data[p_extension_name] = p_additional_data;
  157. }