-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Loading model files at runtime #24768
Comments
I am looking for this feature too!! Many projects depends on being moddables. Importing meshes and textures in a safety way is what I need, it would be GREAT. |
Please see #34193 The api is close to: var importer = SceneImporterGLTF.new()
var root = importer.import_gltf("user://example.glb") |
@fire Where is the API Documentation for SceneImporterGLTF? |
@fire This looks awesome! I am so excited for this. I will need to import GLTF models at runtime for a project. Would you say that functionality is currently at a usable state in your |
Please try and comment on your problems. Remember that res:// is read only and user:// is writable. You probably need to use the duplicate_and_reown function though. [Edited] Line 2176 in a7f49ac
[Edited] This is too difficult to use. I'll change it so it instances at the child of this node. |
Thanks for your quick feedback! Using your suggestion here:
I tried importing my own local gltf file using this Box.glb sample to my extends Node
func _ready():
var importer = SceneImporterGLTF.new()
var root = importer.import_gltf("user://Box.glb") and I got this error E 0:00:01.004 import_gltf: Condition ' err != OK ' is true. returned: __null
<C++ Source> modules/gltf/editor_scene_importer_gltf.h:74 @ import_gltf()
<Stack Trace> Testing_Area.gd:13 @ _ready() Is there anything else you would recommend to help me get this working? |
Update your branch and use: extends Spatial
func _process(_delta):
if Input.is_action_pressed("ui_accept"):
var importer = SceneImporterGLTF.new()
importer.import_gltf(self, "res://door.glb") |
At fire@f00f49c Api changed to: extends Spatial
func _process(_delta):
if Input.is_action_pressed("ui_accept"):
var importer = SceneImporterGLTF.new()
var node = importer.import_gltf("res://door.glb")
add_child(node) |
@fire This is working great so far! Thanks so much. Please reach out if you would like help with any further development. I can also write some docs too! |
How can I contact you? I use discord often. |
will this feature be available in 3.2.2? |
@PravinKumar95 The WIP pull request above isn't in a mergeable state yet, so no. |
I can update my PR to be in 3.2, but I don't think it will be merged in 3.2. For me, 4.0 currently can't even load gltf2 into meshes. I've been using the exporter for my projects. The github master PR pipeline is heavily delayed, so I have been waiting for my Skeleton Inspector PR to be looked. At least until the next time a cool idea shows up. The only big changes in my testing is I removed CSG import because there's no robust api for getting a mesh out. Will need to revisit. Another bug is related to when the root node is a mesh in gltf / godot scene. My fixed tried to fix export, but then import broke. |
This will be good enough for me. I only need runtime import of mesh and materials. Thanks |
Is there also a way to load compiled scripts at runtime? (C# or third-party bindings) |
@Mek101 This is the wrong topic for addressing loading compiled scripts from C# or GDNative. |
@PravinKumar95 I've been developing the changes here. https://github.com/godot-extended-libraries/gltf Please file issues if you have problems. Known issues:
|
Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine. The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker. If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance! |
I have an module that implements runtime model import. Anyone who is interested can make a proposal and I'll link when I make the pull request. |
@fire I see the repo above is archived as it was merged into 4.0, but how difficult would it be to compile it as GDNative for 3.x? Is it something I can do using your archived repo or is the code 4.x specific? |
Please use gltf module from https://godotengine.org/asset-library/asset/964 Source is from https://github.com/V-Sekai/godot-gltf-module/tree/gdnative |
I'm failing to make it work at runtime. Works perfectly in editor, but SceneImporterGLTF (from comments above) is not recognized and EditorSceneImporterGLTF only works in the editor... |
This comment has been minimized.
This comment has been minimized.
There is a GDNative library included, and I'm not even exporting anything, I'm failing to make it work while running a project in debug from the editor. |
@Calinou https://github.com/V-Sekai/godot-gltf-module/tree/gdnative is a GDNative module. Do you have a sample of your project? Remember that you manually call PackedSceneGLTF since none of the editor code is in the runtime. Try 2. Should contain addons/godot_gltf/PackedSceneGLTF.gdns The api is:
|
Thanks, the API is what I was missing. The above API didn't work directly (the class is registered but the method was not found), I actually had to load the GDNative as below (taken from import_vrm.gd):
That worked perfectly for models outside res:// |
Managed to get the above working thanks @fbcosentino, however when exporting to HTML5 it then stops working, any ideas? |
You need to enable GDNative in the HTML5 export preset for GDNative add-ons to work there. The add-on also needs to be compiled for use in HTML5. I think you also need to use a secure context (HTTPS hosting) that sends the required cross-origin isolation headers as well. |
Godot version:
N/A
OS/device including version:
N/A
Issue description:
You currently cannot load files such as OBJ, DAE, and GLTF/GLB at runtime.
Steps to reproduce:
N/A
Minimal reproduction project:
N/A
I understand that packing the import plugins with every exported binary isn't great for the many people who don't need this; that's not what I'm asking for. It would be useful to have a compile flag that allowed the import plugins to be compiled into the binary, for those who are willing to compile. Additionally, although I don't know much about how these plugins work, we'd clearly need more than just a compile flag since even when running a game using the editor's binary you still can't easily import files at runtime.
Some members of the community have questioned why you'd ever need this, which is fair enough, so let me give my use case. I'm developing an FPS where maps are downloaded from servers at runtime. Godot scenes can contain scripts & signals which makes them a security risk. Yes, I can strip out scripts programmatically, but I'm not done yet. Needing to import the maps into Godot makes life more difficult for mapmakers, turning away valuable community members from the game. It's much easier for a mapmaker to just click "Export as glTF" in Blender than it is for them to first model it in Blender and then import it into Godot.
Of course, that's just me and my use case. Others don't need this, which is why it should probably be a separate compile flag rather than the default functionality.
Thank you for your time.
The text was updated successfully, but these errors were encountered: