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

Blender Empty Cube not being converted into a collision body #40729

Closed
A-Lamia opened this issue Jul 26, 2020 · 6 comments
Closed

Blender Empty Cube not being converted into a collision body #40729

A-Lamia opened this issue Jul 26, 2020 · 6 comments

Comments

@A-Lamia
Copy link
Contributor

A-Lamia commented Jul 26, 2020

Godot Version: v4.0.

OS Version: Windows 10.

I have used the same test blender file shared in #32678 and added a empty cube with -colonly as the doc said.

Steps:
Export blender file as single GLTF2 (.glb) file Add to local Godot project folder to auto import.

Problem:
Empty Cube being imported as a node3D

Desired Effect:
Empty Cube should be converted to a StaticBody with a collision node child set to BoxShape as the docs have said.

godot windows tools 64_FxlPJjH1b

32678-respect-import-hints-with-empty.zip

Originally posted by @A-Lamia in #32678 (comment)

@Calinou Calinou changed the title Blender Empty Cube not being converted in to collision. Blender Empty Cube not being converted into a collision body Jul 27, 2020
@A-Lamia
Copy link
Contributor Author

A-Lamia commented Jul 28, 2020

After further inspection it seems that exporting empties with gltf2 from blender (version 2.8X, 2.9X) does not export the needed information for Godot to correctly import the collision body.

Issue should probably stay open and a ticket should be made on blenders side until the issue there is fixed.

@ConorLPBoyle
Copy link
Contributor

Export to gltf with custom properties on:

{
    "asset" : {
        "generator" : "Khronos glTF Blender I/O v1.2.75",
        "version" : "2.0"
    },
    "scene" : 0,
    "scenes" : [
        {
            "extras" : {
                "MM" : {
                    "revision" : "f94854aaf7ac8d09d521a6c5437361196822e46e"
                }
            },
            "name" : "Scene",
            "nodes" : [
                0
            ]
        }
    ],
    "nodes" : [
        {
            "extras" : {},
            "name" : "cube_empty-colonly",
            "rotation" : [
                0.2389068305492401,
                0.12964144349098206,
                -0.251981258392334,
                0.9287744760513306
            ],
            "scale" : [
                1.3872629404067993,
                1.3872630596160889,
                1.3872629404067993
            ],
            "translation" : [
                0,
                0,
                -16.017648696899414
            ]
        }
    ]
}

I also checked the Collada exporter and it doesn't export this property either. As far as Blender is concerned, it's just an empty transform that happens to be visualized as a cube.

On the Blender side, the exporter would either need to treat an empty node with an appropriate Display As property as if it had a mesh and export it with geometry, or output some custom properties defining the appropriate Display As and Size properties for that empty node which Godot would then use to generate the appropriate geometry.

One way, you have the unexpected behavior of Blender's exporter generating geometry based on what's intended to be a viewport visualization property. The other way, you end up with Godot's importer treating certain model files differently based on non-spec metadata.

@ghost
Copy link

ghost commented Oct 31, 2020

Collada has an additional property (empty_draw_type) for empty objects which is not available in glTF
#32363 (comment)

glTF exporter uses custom properties that were added manually
Снимок0

As far as I understand the problem is on two sides. Blender does not export required properties, and Godot looks for them in the wrong place.
You can write your own extensions for the glTF Blender exporter (https://docs.blender.org/manual/en/dev/addons/import_export/scene_gltf2.html#third-party-gltf-extensions)
I wrote one. Installed as a regular addon and allows you to add data to glTF file
Снимок
Then just activate the extension on export
Снимок1

I tried options with extensions and/or extras properties. It looks like specification allows this
https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#nodeextensions
https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#nodeextras

{
    "nodes" : [
        {
            "extensions" : {
                "GODOT_glTF_extension" : {
                    "empty_draw_type" : "CUBE"
                }
            },
            "extras" : {
                "Godot_custom_property" : 1,
                "empty_draw_type" : "CUBE"
            },
            "name" : "Empty -colonly"
        },
        {
            "children" : [
                0
            ],
            "mesh" : 0,
            "name" : "Cube"
        }
    ],
}

Unfortunately, Godot glTF importer ignores both options.
Need to find out how exactly should "empty_draw_type" property look like

There is Blender 2.90 add-on prototype, maybe it will be useful to someone.
(https://github.com/valeev-iv/BlenderToGodotGltfExtension)

PS: Sorry for my English. Translated by Google Translate

@fire
Copy link
Member

fire commented Dec 26, 2020

The gltf importer / exporter was changed recently. Please see how gltf2 extensions are implemented. Available for questions.

@william-lohan
Copy link

I'm still running into this issue with Godot 3.4.4 and Blender 3.1.2

@akien-mga
Copy link
Member

Duplicate of #32363

@akien-mga akien-mga marked this as a duplicate of #32363 Jul 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants