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 functionality to export 3D models from an exported project #341

Closed
kone9 opened this issue Dec 28, 2019 · 12 comments
Closed

Add functionality to export 3D models from an exported project #341

kone9 opened this issue Dec 28, 2019 · 12 comments

Comments

@kone9
Copy link

kone9 commented Dec 28, 2019

Describe the project you are working on:
An application where 3D models are chosen and then can be exported

Describe the problem or limitation you are having in your project:
I can't find a way to export 3D models of a compiled project

Describe how this feature / enhancement will help you overcome this problem or limitation:
It would help me to create an application completely with godot engine

Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
Captura de pantalla_2019-12-28_09-45-12

Describe implementation detail for your proposal (in code), if possible:
you choose a 3D model and then it is exported from the compiled project to be able to print it in 3D

If this enhancement will not be used often, can it be worked around with a few lines of script?:
they told me that if I connect it with a json it may be, but I have no idea how to implement it

Is there a reason why this should be core and not an add-on in the asset library?:
It could be a complement, the important thing is the functionality of being able to export 3D models once the project is compiled.

@Calinou
Copy link
Member

Calinou commented Dec 28, 2019

It could be a complement, the important thing is the functionality of being able to export 3D models once the project is compiled.

If it can be implemented as an add-on, there's no reason to open a proposal here 🙂

There are a few OBJ loaders written in GDScript out there (1, 2). An exporter could likely also be written.

@fire
Copy link
Member

fire commented Dec 28, 2019

I have a pr for exporting scenes to gltf2.

I have been able to convert imported gltf2 scenes to export gltf2 scenes.

However, I haven't done complete matching of all the animation properties.

godotengine/godot#34193

My goal is to prepare this for Godot 4.0, but it has not been merged in and it's waiting for a new public api to be created.

@kone9
Copy link
Author

kone9 commented Dec 29, 2019

I have a pr for exporting scenes to gltf2.

I have been able to convert imported gltf2 scenes to export gltf2 scenes.

However, I haven't done complete matching of all the animation properties.

godotengine/godot#34193

My goal is to prepare this for Godot 4.0, but it has not been merged in and it's waiting for a new public api to be created.

Is it possible to do this from the compiled project? Any node that allows you to do this?

@fire
Copy link
Member

fire commented Dec 29, 2019

That's the new public api!

@lawnjelly
Copy link
Member

Possibly might help, look in the ObjExport folder for a small export script I wrote a few weeks ago. It might do what you are after (or put you on the right track, so you can modify it for your needs), just create an ObjExport object and call

export(mesh_instance, filename)

https://github.com/lawnjelly/GodotTweaks

You might need to alter it a little if you want UVs too, I'll probably try and make it more robust when I have time. I've also made a DAE exporter as part of LPortal but that's probably overkill for what you need and might be more tricky to use.

I've also got a simple addon which does mesh merging which may or may not be of use:
https://github.com/lawnjelly/godot-splerger

@kone9
Copy link
Author

kone9 commented Jan 3, 2020

Possibly might help, look in the ObjExport folder for a small export script I wrote a few weeks ago. It might do what you are after (or put you on the right track, so you can modify it for your needs), just create an ObjExport object and call

export(mesh_instance, filename)

https://github.com/lawnjelly/GodotTweaks

You might need to alter it a little if you want UVs too, I'll probably try and make it more robust when I have time. I've also made a DAE exporter as part of LPortal but that's probably overkill for what you need and might be more tricky to use.

I've also got a simple addon which does mesh merging which may or may not be of use:
https://github.com/lawnjelly/godot-splerger

Ok, I will experiment with this tool .... Is it possible to export from a compiled project?

@lawnjelly
Copy link
Member

Ok, I will experiment with this tool .... Is it possible to export from a compiled project?

Yes, however you may possibly run into problems on non-desktop builds: these afaik don't retain some of the geometry data to save memory, and don't allow reading from the GPU, so reading back the geometry (to export) may not be possible. I haven't tested this.

You can quite easily modify the Godot build to retain this data, but it isn't available in vanilla Godot on mobile (and hence there are quite a few issues reporting crashes trying to use this data). If this is indeed a problem it may also affect fire's gltf2 exporter.

@kone9
Copy link
Author

kone9 commented Jan 3, 2020

Ok, I will experiment with this tool .... Is it possible to export from a compiled project?

Yes, however you may possibly run into problems on non-desktop builds: these afaik don't retain some of the geometry data to save memory, and don't allow reading from the GPU, so reading back the geometry (to export) may not be possible. I haven't tested this.

You can quite easily modify the Godot build to retain this data, but it isn't available in vanilla Godot on mobile (and hence there are quite a few issues reporting crashes trying to use this data). If this is indeed a problem it may also affect fire's gltf2 exporter.

Ok, thanks I'm going to try it and then I'll tell you.

@kone9
Copy link
Author

kone9 commented Jan 4, 2020

Ok, I will experiment with this tool .... Is it possible to export from a compiled project?

Yes, however you may possibly run into problems on non-desktop builds: these afaik don't retain some of the geometry data to save memory, and don't allow reading from the GPU, so reading back the geometry (to export) may not be possible. I haven't tested this.

You can quite easily modify the Godot build to retain this data, but it isn't available in vanilla Godot on mobile (and hence there are quite a few issues reporting crashes trying to use this data). If this is indeed a problem it may also affect fire's gltf2 exporter.

Ok, I will experiment with this tool .... Is it possible to export from a compiled project?

Yes, however you may possibly run into problems on non-desktop builds: these afaik don't retain some of the geometry data to save memory, and don't allow reading from the GPU, so reading back the geometry (to export) may not be possible. I haven't tested this.

You can quite easily modify the Godot build to retain this data, but it isn't available in vanilla Godot on mobile (and hence there are quite a few issues reporting crashes trying to use this data). If this is indeed a problem it may also affect fire's gltf2 exporter.

Link video test youtube
https://youtu.be/ihn10BaDABs
First of all I wanted to tell you that it is an incredible job that you did, thank you very much for sharing it with the community for free.
For some reason when it is compiled in linux desktop version does not create the exported file. What can it be?

@kone9
Copy link
Author

kone9 commented Jan 4, 2020

Ok, I will experiment with this tool .... Is it possible to export from a compiled project?

Yes, however you may possibly run into problems on non-desktop builds: these afaik don't retain some of the geometry data to save memory, and don't allow reading from the GPU, so reading back the geometry (to export) may not be possible. I haven't tested this.

You can quite easily modify the Godot build to retain this data, but it isn't available in vanilla Godot on mobile (and hence there are quite a few issues reporting crashes trying to use this data). If this is indeed a problem it may also affect fire's gltf2 exporter.

It seems that what is failing is the location, that would have to be in the same place where the project was exported, but it does not appear ... First we would have to solve that problem and then create a folder in the same directory that says exported objects. ..
What do you think ... How can I know the location where it is exported?. Any way to tell GDscript that the place where the exported file goes is the same place where the compiled file is? ...

@lawnjelly
Copy link
Member

Although the location can be a problem on some platforms (particularly with permissions) I don't think it should be a problem on linux. That obj export code is not battle tested. In particular it aborts if the vertex count is 0, which is what I was fearing might occur on mobile. This same problem may also be occurring in non-tools builds on desktop...

I will try and put in a printerr in ObjExport.gd to catch this case (you can also add it to your source as follows, just add a printerr or print statement before the return, and it should appear in the console):

func export(var mesh_inst, var filename = "../test.obj"):
	~~~
	if nVerts == 0:
		printerr("Error ObjExport number of verts is zero!")
		return

However in amazing synchronicity, to fix another similar bug, clayjohn has just added a PR to retain the geometry data in all builds.

godotengine/godot#34794

So if you grab the latest nightly build from Calinou (or perhaps the one built within the next day) this may magically work again!! 😄

https://hugo.pro/projects/godot-builds/

Another alternative may be to ship the tools build of Godot with your .pck file (I'm not sure on the size difference).

@fire fire changed the title export3D models of a compiled project export 3D models of a compiled project Jan 9, 2020
@Calinou Calinou changed the title export 3D models of a compiled project Add functionality to export 3D models from an exported project May 6, 2020
@fire
Copy link
Member

fire commented Jan 6, 2022

Fixed by gltf exporting https://godotengine.org/article/introducing-the-godot-gltf-2-0-scene-exporter, godotengine/godot#52541 exporting buffers.

See also #3273.

@fire fire closed this as completed Jan 6, 2022
@fire fire added the archived label Jan 6, 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

4 participants