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 Import / Export Workflow #1463

Closed
fire opened this issue Sep 4, 2020 · 2 comments
Closed

Add Import / Export Workflow #1463

fire opened this issue Sep 4, 2020 · 2 comments
Milestone

Comments

@fire
Copy link
Member

fire commented Sep 4, 2020

Describe the project you are working on:

Godot Engine and a 3D Multiplayer Game.

Describe the problem or limitation you are having in your project:

This is a way to implement #1398.

In GLTF2 we currently code lights and cameras directly into the gltf2 importer.

glTF2 has many extensions. It doesn't make sense for all them to be embedded into the core of Godot Engine. There's also user extensions that shouldn't be part of Godot Engine.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:

Using this extension system, the lights and cameras in gltf2 can be moved to c++ extensions. This also allows other uses.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

The main goal is for these extensions to be gdscript-able.

I wanted to move the glTF2 camera and light extensions to an "Extension class of a glTF2 document".

In the import panel, we can select import/export extensions which are just global named import/export extensions.

Import:

read from disk -> extension pre -> parse into gltf/fbx document -> extension current -> packed scene -> extension post

Export:

packed scene -> extension pre -> convert to gltf/fbx document -> extension current -> write to disk -> extension post

There's a stack of extensions. The order of the extensions are interleaved. The pre of all the extensions is done before all the current extensions, and all the post extensions.

User modifications should be stored in the .import file for use in these scripts.

This should also allow the creation of new properties that are stored inside of the import panel and saved in the .import file.

Misc other uses:

class_name SomeNameHere
extends SceneWorkflowTool
func on_pre_import( resource_path : String ):
    pass

func on_current_import( resource_path : String, document: Resource):
    pass

func on_post_import( resource_path : String, scene : PackedScene ):
  if treeA.contains("/RootNode/"):
     treeA.remove("/RootNode/")
    # example extensions which could be written
    optimise_meshes()
    remove_lighting()
    reset_all_scales_to_one()
    purge_orphans()
    retain_orphan_gui()

func on_pre_export( resource_path : String ):
   convert_all_dds_to_png(resource_path)

func on_current_export( resource_path : String, document: Resource ):
    pass

func on_post_export( resource_path : String, scene : PackedScene ):
   open_diff_gui(treeA, treeB, <matching rule> )
  if treeA.contains("/RootNode/"):
     treeA.remove("/RootNode/")

Workflow extra root node:

There is a root node that is at the top.

Extension point pre and current are ignored.

Extension point post takes the existing scene that is imported and modifies the root to be dissolved keeping children. The nodepath and string references need to be rewritten. Animations too.

Workflow diff tool:

A diff tool can be one of the default extensions and can be subclassed.

We can make an extension post point gui for gdscript fixes that has shows a popup dialog for all the relevant changed locations for review.

Workflow orphan detection:

Extension point pre reads from the raw tscn and directly searches for orphans and deletes it since the orphans don't appear in the scene.

Workflow gdscript is in-correct:

This is a diff tool that shows every node that is invalid. The tool asks the developer for input.

Workflow tool post process move to directory:

Extension point import post is a post process option.

If this enhancement will not be used often, can it be worked around with a few lines of script?:

We want to expose an interface that is gdscriptable.

Is there a reason why this should be core and not an add-on in the asset library?:

Expose the extension points in importers requires work.

@fire fire changed the title Import extensions Import / Export extensions Sep 4, 2020
@Calinou Calinou changed the title Import / Export extensions Add Import / Export extensions Sep 26, 2021
@fire
Copy link
Member Author

fire commented Sep 29, 2021

An updated design.

SceneImporter.set_extensions(TypedArray<SceneImporterExtension> p_extensions) -> void
Store extensions in an ordered vector.
One sample extension is to check the scene requirements. For example, less than N triangles; no textures > 2048. We can implement this extension so that it returns a null node if failing. Error data is stored in the extension.

Add hook functions.

virtual Dictionary get_import_settings() { return import_settings; }
virtual void set_import_settings(Dictionary p_settings) { import_settings = p_settings; }
virtual Error import_preflight(Ref<SceneImporter> p_document, Dictionary p_export_settings) { return OK; }
virtual Error import_post(Ref<SceneImporter> p_document, Node *p_node, Dictionary p_export_settings) { return OK; }
virtual Dictionary get_export_settings() { return export_settings; }
virtual void set_export_settings(Dictionary p_settings) { export_settings = p_settings; }
virtual Error export_preflight(Ref<SceneImporter> p_document, Dictionary p_export_settings) { return OK; }
virtual Error export_post(Ref<SceneImporter> p_document, Node *p_node, Dictionary p_export_settings) { return OK; }

@fire fire changed the title Add Import / Export extensions Add Import / Export Workflow Sep 29, 2021
@fire
Copy link
Member Author

fire commented Jan 5, 2022

Superseded by godotengine/godot#53813.

@fire fire closed this as completed Jan 5, 2022
@Calinou Calinou added this to the 4.0 milestone Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants