gltf_document_extension.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*************************************************************************/
  2. /* gltf_document_extension.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 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 "gltf_document_extension.h"
  31. void GLTFDocumentExtension::_bind_methods() {
  32. GDVIRTUAL_BIND(_import_preflight, "state");
  33. GDVIRTUAL_BIND(_import_post_parse, "state");
  34. GDVIRTUAL_BIND(_import_node, "state", "gltf_node", "json", "node");
  35. GDVIRTUAL_BIND(_import_post, "state", "root");
  36. GDVIRTUAL_BIND(_export_preflight, "root");
  37. GDVIRTUAL_BIND(_export_node, "state", "gltf_node", "json", "node");
  38. GDVIRTUAL_BIND(_export_post, "state");
  39. }
  40. Error GLTFDocumentExtension::import_post(Ref<GLTFState> p_state, Node *p_root) {
  41. ERR_FAIL_NULL_V(p_root, ERR_INVALID_PARAMETER);
  42. ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER);
  43. int err = OK;
  44. if (GDVIRTUAL_CALL(_import_post, p_state, p_root, err)) {
  45. return Error(err);
  46. }
  47. return OK;
  48. }
  49. Error GLTFDocumentExtension::import_preflight(Ref<GLTFState> p_state) {
  50. ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER);
  51. int err = OK;
  52. if (GDVIRTUAL_CALL(_import_preflight, p_state, err)) {
  53. return Error(err);
  54. }
  55. return OK;
  56. }
  57. Error GLTFDocumentExtension::import_post_parse(Ref<GLTFState> p_state) {
  58. ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER);
  59. int err = OK;
  60. if (GDVIRTUAL_CALL(_import_post_parse, p_state, err)) {
  61. return Error(err);
  62. }
  63. return OK;
  64. }
  65. Error GLTFDocumentExtension::export_post(Ref<GLTFState> p_state) {
  66. ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER);
  67. int err = OK;
  68. if (GDVIRTUAL_CALL(_export_post, p_state, err)) {
  69. return Error(err);
  70. }
  71. return OK;
  72. }
  73. Error GLTFDocumentExtension::export_preflight(Node *p_root) {
  74. ERR_FAIL_NULL_V(p_root, ERR_INVALID_PARAMETER);
  75. int err = OK;
  76. if (GDVIRTUAL_CALL(_export_preflight, p_root, err)) {
  77. return Error(err);
  78. }
  79. return OK;
  80. }
  81. Error GLTFDocumentExtension::import_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Dictionary &r_dict, Node *p_node) {
  82. ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER);
  83. ERR_FAIL_NULL_V(p_gltf_node, ERR_INVALID_PARAMETER);
  84. ERR_FAIL_NULL_V(p_node, ERR_INVALID_PARAMETER);
  85. int err = OK;
  86. if (GDVIRTUAL_CALL(_import_node, p_state, p_gltf_node, r_dict, p_node, err)) {
  87. return Error(err);
  88. }
  89. return OK;
  90. }
  91. Error GLTFDocumentExtension::export_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Dictionary &r_dict, Node *p_node) {
  92. ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER);
  93. ERR_FAIL_NULL_V(p_gltf_node, ERR_INVALID_PARAMETER);
  94. ERR_FAIL_NULL_V(p_node, ERR_INVALID_PARAMETER);
  95. int err = OK;
  96. if (GDVIRTUAL_CALL(_export_node, p_state, p_gltf_node, r_dict, p_node, err)) {
  97. return Error(err);
  98. }
  99. return OK;
  100. }