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

Include all MeshInstances in scene when exporting MeshLibrary (and not just the direct children of the scene root) #3406

Open
ScottyWired opened this issue Oct 9, 2021 · 4 comments

Comments

@ScottyWired
Copy link

ScottyWired commented Oct 9, 2021

Describe the project you are working on

A grid-based 3D turn-based-tactics game with large amounts of modular terrain.

Describe the problem or limitation you are having in your project

"Scene -> Convert To -> Meshlibrary..." only includes MeshInstance direct children of the scene root when creating the MeshLibrary.
When dragging a 3D model into the scene (in my case, a .glb file), it creates a scene instance consisting of a node (Spatial by default) with a MeshInstance child.

Each of these scene instances has to be "Make Local" and then the MeshInstance child reparented to the root. One by one. The MeshInstance child also needs renaming, as my 3D software (AssetForge) does not support naming meshes.
This is an extremely slow process for a game with hundreds of rapidly made terrain assets.
image

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

Allow MeshLibrary export to include all MeshInstances in scene (including children inside other scenes) and not just MeshInstances which are direct children of the Scene Root.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Godot_Engine_-Tac3d()_TNxxU copy

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

Import script that takes the mesh from the 3D file and gives the mesh the same name as the 3D file, then optionally deletes the 3D file.
Edit: My solution ended up being a Tool script that finds every MeshInstance in the scene, renames them, reparents them under the scene root, and then deletes the scenes they were taken out of.

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

image

@Calinou
Copy link
Member

Calinou commented Oct 9, 2021

I don't think this should be made optional. Is there any reason you want non-direct children to be excluded from the conversion to MeshLibrary?

As for including only visible nodes, I can't see a use case for that either. (It hasn't been described in the proposal text.)

PS: You can create MeshLibrary resources manually by loading MeshResources directly in a newly created MeshLibrary resource, without going through the scene -> MeshLibrary conversion process. However, this requires you to have access to direct Mesh resources which is easier done with OBJ meshes compared to glTF scenes.

@ScottyWired
Copy link
Author

ScottyWired commented Oct 10, 2021

"I don't think this should be made optional. Is there any reason you want non-direct children to be excluded from the conversion to MeshLibrary?"

You misunderstand, I want non-direct children to be included. Currently, only direct children are included, and I want non-direct children to be part of MeshLibraries.

"However, this requires you to have access to direct Mesh resources"

Yes that's the problem.

@Calinou
Copy link
Member

Calinou commented Oct 10, 2021

You misunderstand, I want non-direct children to be included. Currently, only direct children are included, and I want non-direct children to be part of MeshLibraries.

I was saying the new option you're proposing may not need to be made optional. We can make it the only behavior in 4.0 and later if there is no valid use case for the other behavior (including only direct children).

@oparisy
Copy link

oparisy commented Apr 30, 2023

I just tried something similar in Godot 4.0.2 and this ticket is spot on in its description of the desirable workflow and current limitations.

My idea was the following: copy a bunch of glb files into a folder in my project assets, let those auto-import, drag&drop those in a scene, export that scene as a MeshLibrary.

Simple enough, excepted that indeed imported glb are scenes, and drag&dropping leads to a scene not understood by the exporter to MeshLibrary (see proposal 3821 for more details).

I see no way around this at this time except scripting a conversion to the proper scene structure, as described above. Manual reorganization of the scene is unpractical (101 assets, and for example "Make Local" does not work on multiple nodes selection).

Edit: I ended up writing such a script, and it helped me successfully export to a MeshLibrary. I shared it here if it can be of any help (see source code comments for the complete workflow).

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

3 participants