-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Make GLTF Scene Importer populate node metadata with GLTF extras #39024
Conversation
0a7d4fb
to
aaeebc1
Compare
@@ -1161,6 +1162,7 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in | |||
bool animations_out = p_preset == PRESET_SEPARATE_ANIMATIONS || p_preset == PRESET_SEPARATE_MESHES_AND_ANIMATIONS || p_preset == PRESET_SEPARATE_MATERIALS_AND_ANIMATIONS || p_preset == PRESET_SEPARATE_MESHES_MATERIALS_AND_ANIMATIONS; | |||
|
|||
r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "nodes/root_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001"), 1.0)); | |||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "nodes/meta"), false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added metadata doesn't seem particularly compat breaking, so I guess it could be on by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not familiar with many 3D modeling tools but I can imagine some tools abusing custom properties to store a lot of data (maybe editor plugins?) - so I'm just concerned the user might unknowingly end up with a lot of data in his scene that they never use (and currently not even immediately see as the metadata can be displayed only through a plugin or needs to be inspected by code).
Also if someone already used metadata assuming (performance-wise) there's going to be only their keys/values it might significantly slow down their code if they use some 3D tool that fills the object metadata with a lot of stuff.
But as already stated - I don't really know how things usually work in gamedev/3Dmodeling.
Changes seem OK, but it needs a check by @reduz to confirm that it's wanted. A PR should be made for the |
This PR currently only generates metadata for Meshes, Cameras and Spatials. Other nodes can be added later. This feature can be enabled by a Scene Importer import option called "Meta".
aaeebc1
to
a703e44
Compare
@akien-mga Unfortunately |
If you want, I can spend significant time with helping you get Godot Engine 4.0 to run on your computer. |
@fire
|
I really want this, so I'll see if I can find time the next available period to work on it for master. |
This pr is outdated by #40474. |
Superseded by #40474. Thanks for your work! |
Introduction
This PR adds the boolean import option
nodes/meta
to the Scene Importer.When enabled the imported nodes' metadata is populated from annotation data of the specific file format (currently limited to GLTF "extras").
This PR currently only generates metadata for Meshes, Cameras and
Spatials. Other nodes can be added in later PRs.
The change was discussed with @fire on the engine room of the Godot discord.
Motivation
I would like to be able to write custom import scripts that modify the imported scene based on metadata on objects. e.g. generating physics objects for meshes that are somehow tagged in Blender.
The metadata can also be read at runtime, which makes it very easy to specify values in the 3d model (at modeling time i.e. in Blender) that are then used by the game e.g. physical properties of objects.
@fire expressed the desire to include GDscripts in GLTF files.
Example
Notice the custom property
"is_floor"
on the box mesh specified in Blender.We export the model with the GLTF exporter while making sure to have the "Custom properties" option enabled.
We can see that the
.gltf
file encodes the custom property in the"extras"
field.Importing the
.gltf
file into Godot results in a MeshInstance with the metadata set to the values specified in Blender.(the metadata panel is displayed by this plugin)
Breaking behavior
The option is disabled by default so it should not introduce unexpected behavior to anyone.
Disclaimer
I have no prior experience with 3D model formats or game development.