Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add three new methods to GLTFDocumentExtension and document all of its methods #68981

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

aaronfranke
Copy link
Member

@aaronfranke aaronfranke commented Nov 21, 2022

Implements and closes godotengine/godot-proposals#3305 (at least, most of what matters, and all for now).

This PR does three things:

  • Re-order the methods in GLTFDocumentExtension to be in the order they are executed in (for easy readability).
  • Add documentation for all methods in GLTFDocumentExtension (and the below new ones).
  • Add three new methods to GLTFDocumentExtension:
    • parse_node_extensions 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 generate_scene_node.
    • generate_scene_node 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; GLTFDocument will handle setting ownership of those children.
    • convert_scene_node 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 export_node.
    • The creation of these methods were driven by practical use cases, including physics and audio nodes. With these methods in place, we could also in theory move the light code to a GLTFDocumentExtension class instead of having it be directly in GLTFDocument, but I discussed with @fire and there is no strong reason to do this.

The signatures of the new methods look like this:

virtual Error parse_node_extensions(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Dictionary &p_extensions);
virtual Node3D *generate_scene_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Node *p_scene_parent);
virtual void convert_scene_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Node *p_scene_node);

This work was sponsored by The Mirror.

Copy link
Member

@fire fire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I wrote godotengine/godot-proposals#3305 there wasn't a full example of importers, but @aaronfranke implemented a few extensions and helped us resolve the question of which methods are essential. (These ones are.)

@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an extension system for the GLTFDocument class
3 participants