class_gltfdocumentextension.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.1/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.1/modules/gltf/doc_classes/GLTFDocumentExtension.xml.
  6. .. _class_GLTFDocumentExtension:
  7. GLTFDocumentExtension
  8. =====================
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`GLTFDocumentExtensionConvertImporterMesh<class_GLTFDocumentExtensionConvertImporterMesh>`
  11. :ref:`GLTFDocument<class_GLTFDocument>` extension class.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Extends the functionality of the :ref:`GLTFDocument<class_GLTFDocument>` class by allowing you to run arbitrary code at various stages of GLTF import or export.
  16. To use, make a new class extending GLTFDocumentExtension, override any methods you need, make an instance of your class, and register it using :ref:`GLTFDocument.register_gltf_document_extension<class_GLTFDocument_method_register_gltf_document_extension>`.
  17. \ **Note:** Like GLTFDocument itself, all GLTFDocumentExtension classes must be stateless in order to function properly. If you need to store data, use the ``set_additional_data`` and ``get_additional_data`` methods in :ref:`GLTFState<class_GLTFState>` or :ref:`GLTFNode<class_GLTFNode>`.
  18. .. rst-class:: classref-reftable-group
  19. Methods
  20. -------
  21. .. table::
  22. :widths: auto
  23. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`_convert_scene_node<class_GLTFDocumentExtension_method__convert_scene_node>` **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`GLTFNode<class_GLTFNode>` gltf_node, :ref:`Node<class_Node>` scene_node **)** |virtual| |
  25. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`_export_node<class_GLTFDocumentExtension_method__export_node>` **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`GLTFNode<class_GLTFNode>` gltf_node, :ref:`Dictionary<class_Dictionary>` json, :ref:`Node<class_Node>` node **)** |virtual| |
  27. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`_export_post<class_GLTFDocumentExtension_method__export_post>` **(** :ref:`GLTFState<class_GLTFState>` state **)** |virtual| |
  29. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`_export_preflight<class_GLTFDocumentExtension_method__export_preflight>` **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`Node<class_Node>` root **)** |virtual| |
  31. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Node3D<class_Node3D>` | :ref:`_generate_scene_node<class_GLTFDocumentExtension_method__generate_scene_node>` **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`GLTFNode<class_GLTFNode>` gltf_node, :ref:`Node<class_Node>` scene_parent **)** |virtual| |
  33. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`_get_supported_extensions<class_GLTFDocumentExtension_method__get_supported_extensions>` **(** **)** |virtual| |
  35. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`_import_node<class_GLTFDocumentExtension_method__import_node>` **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`GLTFNode<class_GLTFNode>` gltf_node, :ref:`Dictionary<class_Dictionary>` json, :ref:`Node<class_Node>` node **)** |virtual| |
  37. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`_import_post<class_GLTFDocumentExtension_method__import_post>` **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`Node<class_Node>` root **)** |virtual| |
  39. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`_import_post_parse<class_GLTFDocumentExtension_method__import_post_parse>` **(** :ref:`GLTFState<class_GLTFState>` state **)** |virtual| |
  41. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`_import_preflight<class_GLTFDocumentExtension_method__import_preflight>` **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`PackedStringArray<class_PackedStringArray>` extensions **)** |virtual| |
  43. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`_parse_image_data<class_GLTFDocumentExtension_method__parse_image_data>` **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`PackedByteArray<class_PackedByteArray>` image_data, :ref:`String<class_String>` mime_type, :ref:`Image<class_Image>` ret_image **)** |virtual| |
  45. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`_parse_node_extensions<class_GLTFDocumentExtension_method__parse_node_extensions>` **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`GLTFNode<class_GLTFNode>` gltf_node, :ref:`Dictionary<class_Dictionary>` extensions **)** |virtual| |
  47. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`_parse_texture_json<class_GLTFDocumentExtension_method__parse_texture_json>` **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`Dictionary<class_Dictionary>` texture_json, :ref:`GLTFTexture<class_GLTFTexture>` ret_gltf_texture **)** |virtual| |
  49. +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. .. rst-class:: classref-section-separator
  51. ----
  52. .. rst-class:: classref-descriptions-group
  53. Method Descriptions
  54. -------------------
  55. .. _class_GLTFDocumentExtension_method__convert_scene_node:
  56. .. rst-class:: classref-method
  57. void **_convert_scene_node** **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`GLTFNode<class_GLTFNode>` gltf_node, :ref:`Node<class_Node>` scene_node **)** |virtual|
  58. Part of the export process. This method is run after :ref:`_export_preflight<class_GLTFDocumentExtension_method__export_preflight>` and before :ref:`_export_node<class_GLTFDocumentExtension_method__export_node>`.
  59. Runs when converting the data from a Godot scene node. This method can be used to process the Godot scene node data into a format that can be used by :ref:`_export_node<class_GLTFDocumentExtension_method__export_node>`.
  60. .. rst-class:: classref-item-separator
  61. ----
  62. .. _class_GLTFDocumentExtension_method__export_node:
  63. .. rst-class:: classref-method
  64. :ref:`Error<enum_@GlobalScope_Error>` **_export_node** **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`GLTFNode<class_GLTFNode>` gltf_node, :ref:`Dictionary<class_Dictionary>` json, :ref:`Node<class_Node>` node **)** |virtual|
  65. Part of the export process. This method is run after :ref:`_convert_scene_node<class_GLTFDocumentExtension_method__convert_scene_node>` and before :ref:`_export_post<class_GLTFDocumentExtension_method__export_post>`.
  66. This method can be used to modify the final JSON of each node.
  67. .. rst-class:: classref-item-separator
  68. ----
  69. .. _class_GLTFDocumentExtension_method__export_post:
  70. .. rst-class:: classref-method
  71. :ref:`Error<enum_@GlobalScope_Error>` **_export_post** **(** :ref:`GLTFState<class_GLTFState>` state **)** |virtual|
  72. Part of the export process. This method is run last, after all other parts of the export process.
  73. This method can be used to modify the final JSON of the generated GLTF file.
  74. .. rst-class:: classref-item-separator
  75. ----
  76. .. _class_GLTFDocumentExtension_method__export_preflight:
  77. .. rst-class:: classref-method
  78. :ref:`Error<enum_@GlobalScope_Error>` **_export_preflight** **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`Node<class_Node>` root **)** |virtual|
  79. Part of the export process. This method is run first, before all other parts of the export process.
  80. The return value is used to determine if this **GLTFDocumentExtension** instance should be used for exporting a given GLTF file. If :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>`, the export will use this **GLTFDocumentExtension** instance. If not overridden, :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` is returned.
  81. .. rst-class:: classref-item-separator
  82. ----
  83. .. _class_GLTFDocumentExtension_method__generate_scene_node:
  84. .. rst-class:: classref-method
  85. :ref:`Node3D<class_Node3D>` **_generate_scene_node** **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`GLTFNode<class_GLTFNode>` gltf_node, :ref:`Node<class_Node>` scene_parent **)** |virtual|
  86. Part of the import process. This method is run after :ref:`_parse_node_extensions<class_GLTFDocumentExtension_method__parse_node_extensions>` and before :ref:`_import_post_parse<class_GLTFDocumentExtension_method__import_post_parse>`.
  87. Runs when generating a Godot scene node from a GLTFNode. The returned node will be added to the scene tree. Multiple nodes can be generated in this step if they are added as a child of the returned node.
  88. .. rst-class:: classref-item-separator
  89. ----
  90. .. _class_GLTFDocumentExtension_method__get_supported_extensions:
  91. .. rst-class:: classref-method
  92. :ref:`PackedStringArray<class_PackedStringArray>` **_get_supported_extensions** **(** **)** |virtual|
  93. Part of the import process. This method is run after :ref:`_import_preflight<class_GLTFDocumentExtension_method__import_preflight>` and before :ref:`_parse_node_extensions<class_GLTFDocumentExtension_method__parse_node_extensions>`.
  94. Returns an array of the GLTF extensions supported by this GLTFDocumentExtension class. This is used to validate if a GLTF file with required extensions can be loaded.
  95. .. rst-class:: classref-item-separator
  96. ----
  97. .. _class_GLTFDocumentExtension_method__import_node:
  98. .. rst-class:: classref-method
  99. :ref:`Error<enum_@GlobalScope_Error>` **_import_node** **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`GLTFNode<class_GLTFNode>` gltf_node, :ref:`Dictionary<class_Dictionary>` json, :ref:`Node<class_Node>` node **)** |virtual|
  100. Part of the import process. This method is run after :ref:`_import_post_parse<class_GLTFDocumentExtension_method__import_post_parse>` and before :ref:`_import_post<class_GLTFDocumentExtension_method__import_post>`.
  101. This method can be used to make modifications to each of the generated Godot scene nodes.
  102. .. rst-class:: classref-item-separator
  103. ----
  104. .. _class_GLTFDocumentExtension_method__import_post:
  105. .. rst-class:: classref-method
  106. :ref:`Error<enum_@GlobalScope_Error>` **_import_post** **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`Node<class_Node>` root **)** |virtual|
  107. Part of the import process. This method is run last, after all other parts of the import process.
  108. This method can be used to modify the final Godot scene generated by the import process.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_GLTFDocumentExtension_method__import_post_parse:
  112. .. rst-class:: classref-method
  113. :ref:`Error<enum_@GlobalScope_Error>` **_import_post_parse** **(** :ref:`GLTFState<class_GLTFState>` state **)** |virtual|
  114. Part of the import process. This method is run after :ref:`_generate_scene_node<class_GLTFDocumentExtension_method__generate_scene_node>` and before :ref:`_import_node<class_GLTFDocumentExtension_method__import_node>`.
  115. This method can be used to modify any of the data imported so far, including any scene nodes, before running the final per-node import step.
  116. .. rst-class:: classref-item-separator
  117. ----
  118. .. _class_GLTFDocumentExtension_method__import_preflight:
  119. .. rst-class:: classref-method
  120. :ref:`Error<enum_@GlobalScope_Error>` **_import_preflight** **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`PackedStringArray<class_PackedStringArray>` extensions **)** |virtual|
  121. Part of the import process. This method is run first, before all other parts of the import process.
  122. The return value is used to determine if this **GLTFDocumentExtension** instance should be used for importing a given GLTF file. If :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>`, the import will use this **GLTFDocumentExtension** instance. If not overridden, :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` is returned.
  123. .. rst-class:: classref-item-separator
  124. ----
  125. .. _class_GLTFDocumentExtension_method__parse_image_data:
  126. .. rst-class:: classref-method
  127. :ref:`Error<enum_@GlobalScope_Error>` **_parse_image_data** **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`PackedByteArray<class_PackedByteArray>` image_data, :ref:`String<class_String>` mime_type, :ref:`Image<class_Image>` ret_image **)** |virtual|
  128. Part of the import process. This method is run after :ref:`_parse_node_extensions<class_GLTFDocumentExtension_method__parse_node_extensions>` and before :ref:`_parse_texture_json<class_GLTFDocumentExtension_method__parse_texture_json>`.
  129. Runs when parsing image data from a GLTF file. The data could be sourced from a separate file, a URI, or a buffer, and then is passed as a byte array.
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _class_GLTFDocumentExtension_method__parse_node_extensions:
  133. .. rst-class:: classref-method
  134. :ref:`Error<enum_@GlobalScope_Error>` **_parse_node_extensions** **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`GLTFNode<class_GLTFNode>` gltf_node, :ref:`Dictionary<class_Dictionary>` extensions **)** |virtual|
  135. Part of the import process. This method is run after :ref:`_get_supported_extensions<class_GLTFDocumentExtension_method__get_supported_extensions>` and before :ref:`_generate_scene_node<class_GLTFDocumentExtension_method__generate_scene_node>`.
  136. Runs when parsing the node extensions of a GLTFNode. This method can be used to process the extension JSON data into a format that can be used by :ref:`_generate_scene_node<class_GLTFDocumentExtension_method__generate_scene_node>`. The return value should be a member of the :ref:`Error<enum_@GlobalScope_Error>` enum.
  137. .. rst-class:: classref-item-separator
  138. ----
  139. .. _class_GLTFDocumentExtension_method__parse_texture_json:
  140. .. rst-class:: classref-method
  141. :ref:`Error<enum_@GlobalScope_Error>` **_parse_texture_json** **(** :ref:`GLTFState<class_GLTFState>` state, :ref:`Dictionary<class_Dictionary>` texture_json, :ref:`GLTFTexture<class_GLTFTexture>` ret_gltf_texture **)** |virtual|
  142. Part of the import process. This method is run after :ref:`_parse_image_data<class_GLTFDocumentExtension_method__parse_image_data>` and before :ref:`_generate_scene_node<class_GLTFDocumentExtension_method__generate_scene_node>`.
  143. Runs when parsing the texture JSON from the GLTF textures array. This can be used to set the source image index to use as the texture.
  144. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  145. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  146. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  147. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  148. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  149. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  150. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`