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

Export vtree #1378

Merged
merged 172 commits into from
Mar 2, 2022
Merged

Export vtree #1378

merged 172 commits into from
Mar 2, 2022

Conversation

julienduroure
Copy link
Collaborator

No description provided.

@julienduroure
Copy link
Collaborator Author

Still a WIP.
This is only a first step: Have a virtual Tree for nodes, and then use this tree to construct glTF tree.

Still have some TODO to manage, because managing skin & joints with this current system is not easy

@julienduroure
Copy link
Collaborator Author

Seems tests are KO only for pull_request because a cache issue (still caching 2.93 where push caches 3.0)
Anyone know how to solve it?

@julienduroure
Copy link
Collaborator Author

2 different new things in this branch:

  • manage a tree before export. It uses an uuid for each "real" object, and these uuid are passed to other function (and can be used for caching)
  • Using custom caching, as proposed by scurest. Already used in some cases here.

In current version:

  • All tested collection instance issues are solved
  • No more proxy check is needed (for example Text and Mesh using same name in different linked data are now ok)

In attachment a test case for multi level collection instance, for materials, and meshes

collections.zip
materials.zip
mesh.zip

Of course lots of work are still needed, but this is a first step.

@emackey
Copy link
Member

emackey commented Feb 11, 2022

@julienduroure I tried exporting a model with multiple same-name NLA tracks, using a vtree build from today. It looks like all my parts came out animated separately. I have "Group by NLA track" checked, but it didn't perform any grouping, they all came out as loose pieces.

This was a complex model that I can't share, but I could try building a reduced test model if needed.

@julienduroure
Copy link
Collaborator Author

@emackey Do you have your .blend test case?
I can't reproduce here for now on simple test case

image

image

@emackey
Copy link
Member

emackey commented Feb 11, 2022

Took a while to figure out how to reproduce, but it turns out the bug activates when "Include Selected Objects" is checked in the exporter options. The combined NLA track exports alongside loose animations per-object.

NLA_Test_vtree.zip

In the above example, there should be only one NLA animation exported, called "CubeDance." But when "Include Selected Objects" is used, the combined animation appears alongside individual cube animations.

@julienduroure
Copy link
Collaborator Author

@emackey Nice catch!
I just pushed a fix, and ask builder to compile a new build. Should be available in a few hours

@emackey
Copy link
Member

emackey commented Feb 11, 2022

Confirmed fix. Thanks!

@s-light
Copy link

s-light commented Feb 16, 2022

just tried and got an error if there is a animation
test_cube_animation.zip
i also checked if it has to do do with any other option:

    use_selection=False,
    export_animations=True,
    export_nla_strips=True,
    export_frame_range=True,

only the export_animations=xxx makes a difference - if False the export is fine. if True the following error pops up:

Info: Saved "test_cube_animation.blend"

... truncated'/home/stefan/mydata/tools/blender/blender-3.0.0-linux-x64/3.0/python/lib/python3.9/site-packages/libextern_draco.so' exists, draco mesh compression is available
14:45:11 | INFO: Starting glTF 2.0 export
14:45:11 | INFO: Extracting primitive: Cube
14:45:11 | INFO: Primitives created: 1
Python: Traceback (most recent call last):
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/__init__.py", line 640, in execute
    return gltf2_blender_export.save(context, export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 46, in save
    json, buffer = __export(export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 63, in __export
    __gather_gltf(exporter, export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 77, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 44, in gather_gltf2
    animations += __gather_animations(blender_scene, export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 99, in __gather_animations
    animations_, merged_tracks = gltf2_blender_gather_animations.gather_animations(obj_uuid, merged_tracks, len(animations), export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py", line 124, in gather_animations
    animation = __gather_animation(obj_uuid, blender_action, export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py", line 165, in __gather_animation
    channels=__gather_channels(obj_uuid, blender_action, export_settings),
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py", line 202, in __gather_channels
    return gltf2_blender_gather_animation_channels.gather_animation_channels(
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 49, in wrapper_cached
    result = func(*args, **kwargs)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py", line 48, in gather_animation_channels
    if blender_action.use_frame_range is True:
AttributeError: 'Action' object has no attribute 'use_frame_range'

location: /home/stefan/mydata/tools/blender/blender-3.0.0-linux-x64/3.0/scripts/modules/bpy/ops.py:132
Error: Python: Traceback (most recent call last):
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/__init__.py", line 640, in execute
    return gltf2_blender_export.save(context, export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 46, in save
    json, buffer = __export(export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 63, in __export
    __gather_gltf(exporter, export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 77, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 44, in gather_gltf2
    animations += __gather_animations(blender_scene, export_settings)
  File "/home/stefan/.Traceback (most recent call last):
  File "/home/stefan/mydata/github/aframe_gltf_animation_player/models/test_cube_animation.blend/export.py", line 13, in <module>
  File "/home/stefan/mydata/tools/blender/blender-3.0.0-linux-x64/3.0/scripts/modules/bpy/ops.py", line 132, in __call__
    ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Error: Python: Traceback (most recent call last):
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/__init__.py", line 640, in execute
    return gltf2_blender_export.save(context, export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 46, in save
    json, buffer = __export(export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 63, in __export
    __gather_gltf(exporter, export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 77, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 44, in gather_gltf2
    animations += __gather_animations(blender_scene, export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 99, in __gather_animations
    animations_, merged_tracks = gltf2_blender_gather_animations.gather_animations(obj_uuid, merged_tracks, len(animations), export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py", line 124, in gather_animations
    animation = __gather_animation(obj_uuid, blender_action, export_settings)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py", line 165, in __gather_animation
    channels=__gather_channels(obj_uuid, blender_action, export_settings),
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py", line 202, in __gather_channels
    return gltf2_blender_gather_animation_channels.gather_animation_channels(
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 49, in wrapper_cached
    result = func(*args, **kwargs)
  File "/home/stefan/.config/blender/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py", line 48, in gather_animation_channels
    if blender_action.use_frame_range is True:
AttributeError: 'Action' object has no attribute 'use_frame_range'

location: /home/stefan/mydata/tools/blender/blender-3.0.0-linux-x64/3.0/scripts/modules/bpy/ops.py:132


Error: Python script failed, check the message in the system console

@julienduroure
Copy link
Collaborator Author

@s-light You need at least 3.1 to run this branch, you can't use 3.0

@julienduroure
Copy link
Collaborator Author

@s-light You have a build here if you want : https://builder.blender.org/download/experimental/gltf_vtree/

@s-light
Copy link

s-light commented Feb 16, 2022

sorry... is not related to vtree.
it also happens in the current master -
and after some digging i found that the used use_frame_range is a blender3.1 feature....

@Capital-Asterisk
Copy link
Contributor

Hi, I just tried out these changes to fix my problems in #1576. I've noticed that skins are duplicated if multiple objects are parented to a single armature:

"skins" : [
    {
        "inverseBindMatrices" : 6,
        "joints" : [
            1,
            0
        ],
        "name" : "Armature"
    },
    {
        "inverseBindMatrices" : 6,
        "joints" : [
            1,
            0
        ],
        "name" : "Armature"
    }
],

I'm not sure if this is intentional, but this did not happen before. It may re-introduce #566, though this issue and its resolution seems complicated. Unlike the mentioned issue, the inverseBindMatrices are exactly the same in this case.

For some context, I'm writing a C++ application that uses gltf, and relies on nodes within the same armature to have the same skin; it would abort otherwise.

@julienduroure
Copy link
Collaborator Author

I've noticed that skins are duplicated if multiple objects are parented to a single armature

Confirmed. I will have a look soon

@julienduroure
Copy link
Collaborator Author

@Capital-Asterisk I just Fixed the duplicate skin data bug

@julienduroure julienduroure merged commit 69746b2 into master Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants