gltf exporter exports incorrect transforms when exporting nodes that have a rotation or scale other than the identity #83131

Closed
opened 2020-11-27 22:48:17 +01:00 by Mark McKay · 10 comments

System Information
Operating system: Windows
Graphics card: ATF

Blender Version
Broken: 2.92.0 Alpha, fbdf1af35550
Worked: never

When I try to export a file in gltf form, any object nodes that link to a collection in another file and which have a rotation or scale applied to them export an incorrect transform in the final file.

Exact steps for others to reproduce the error
Create a new blend file. Create a monkey object and add it to the collection 'Monkey".
Create a second blend file. Create a link to the Monkey collection in the first file.
Select your linked object. Press Ctrl-D and move the object somewhere else in your scene. Rotate it about an axis or scale it. Do this several times with several objects.
Export your scene as a gltf file.
Open the gltf in a viewer. You will see the objects that you applied rotations or scales to in incorrect locations.

How to fix
I've come up with a patch. In the latest build of blender, in the gltf2_blender_gather_nodes.py file you need to replace lines 426-427 with

      offset = -__convert_swizzle_location(
          blender_object.instance_collection.instance_offset, export_settings)
      s = Matrix.Diagonal(sca).to_4x4()
      r = rot.to_matrix().to_4x4() 
      t = Matrix.Translation(trans).to_4x4()
      o = Matrix.Translation(offset).to_4x4()
      m = t @ r @ s @ o
      trans = m.translation
**System Information** Operating system: Windows Graphics card: ATF **Blender Version** Broken: 2.92.0 Alpha, fbdf1af35550 Worked: never When I try to export a file in gltf form, any object nodes that link to a collection in another file and which have a rotation or scale applied to them export an incorrect transform in the final file. **Exact steps for others to reproduce the error** Create a new blend file. Create a monkey object and add it to the collection 'Monkey". Create a second blend file. Create a link to the Monkey collection in the first file. Select your linked object. Press Ctrl-D and move the object somewhere else in your scene. Rotate it about an axis or scale it. Do this several times with several objects. Export your scene as a gltf file. Open the gltf in a viewer. You will see the objects that you applied rotations or scales to in incorrect locations. **How to fix** I've come up with a patch. In the latest build of blender, in the gltf2_blender_gather_nodes.py file you need to replace lines 426-427 with ``` offset = -__convert_swizzle_location( blender_object.instance_collection.instance_offset, export_settings) ``` ``` s = Matrix.Diagonal(sca).to_4x4() r = rot.to_matrix().to_4x4() t = Matrix.Translation(trans).to_4x4() o = Matrix.Translation(offset).to_4x4() m = t @ r @ s @ o ``` ``` trans = m.translation
Author

Added subscriber: @kitfox

Added subscriber: @kitfox
Author

Not sure it's the same thing. The issue you linked to is for bones, not collections.

Not sure it's the same thing. The issue you linked to is for bones, not collections.
Member

Added subscriber: @JulienDuroure

Added subscriber: @JulienDuroure
Member

I created a ticket in upstream repository: https://github.com/KhronosGroup/glTF-Blender-IO/issues/1280

I created a ticket in upstream repository: https://github.com/KhronosGroup/glTF-Blender-IO/issues/1280
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

I can't reproduce.

What gltf viewer are you using?
Please provide example files.

Here are my files and screenshot from https://gltf-viewer.donmccurdy.com/
image.png

monkeys.zip

I can't reproduce. What gltf viewer are you using? Please provide example files. Here are my files and screenshot from https://gltf-viewer.donmccurdy.com/ ![image.png](https://archive.blender.org/developer/F9480224/image.png) [monkeys.zip](https://archive.blender.org/developer/F9480227/monkeys.zip)
Member

Changed status from 'Needs User Info' to: 'Confirmed'

Changed status from 'Needs User Info' to: 'Confirmed'
Member

Ok, with last info from user on glTF repo, I can reproduce

Ok, with last info from user on glTF repo, I can reproduce
Julien Duroure self-assigned this 2020-12-06 20:01:49 +01:00
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Member

Fixed by 3e7209f9f2

Fixed by 3e7209f9f2894d0203cf9697958a6bd946fa3b6b
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#83131
No description provided.