FBX import/export: Fix Camera rotation #104500

Open
Inho Lee wants to merge 1 commits from Inho-Lee/blender-addons:main into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
First-time contributor

FBX-Blender axis correction should not be applied
for cameras' Position, UpVector and InterestPosition

Fixes #45176

FBX-Blender axis correction should not be applied for cameras' Position, UpVector and InterestPosition Fixes #45176

Am missing a bit of context/explanation about why this fix would be the proper solution here? Would also be good to know if this was successfully tested at least against the major game engines (Unity, Unreal...)?

Another question is, does this survive camera animation?

Camera fixes have a notorious history of 'fixing one issue with one third party software, creating another issue with another third party tool' ;)

@Mysteryem may know better though here?

Am missing a bit of context/explanation about why this fix would be the proper solution here? Would also be good to know if this was successfully tested at least against the major game engines (Unity, Unreal...)? Another question is, does this survive camera animation? Camera fixes have a notorious history of 'fixing one issue with one third party software, creating another issue with another third party tool' ;) @Mysteryem may know better though here?
Bastien Montagne reviewed 2023-04-12 11:51:04 +02:00
@ -57,6 +57,7 @@ FBX_KTIME = 46186158000 # This is the number of "ktimes" in one second (yep, pr
MAT_CONVERT_LIGHT = Matrix.Rotation(math.pi / 2.0, 4, 'X') # Blender is -Z, FBX is -Y.
MAT_CONVERT_CAMERA = Matrix.Rotation(math.pi / 2.0, 4, 'Y') # Blender is -Z, FBX is +X.

Would rename this to MAT_CONVERT_CAMERA_IMPORT

Would rename this to `MAT_CONVERT_CAMERA_IMPORT`
@ -57,6 +57,7 @@ FBX_KTIME = 46186158000 # This is the number of "ktimes" in one second (yep, pr
MAT_CONVERT_LIGHT = Matrix.Rotation(math.pi / 2.0, 4, 'X') # Blender is -Z, FBX is -Y.
MAT_CONVERT_CAMERA = Matrix.Rotation(math.pi / 2.0, 4, 'Y') # Blender is -Z, FBX is +X.
MAT_CONVERT_CAMERA_INVERSE = Matrix.Rotation(-math.pi / 2.0, 4, 'Y')

Would rename this to MAT_CONVERT_CAMERA_EXPORT

Would rename this to `MAT_CONVERT_CAMERA_EXPORT`
Author
First-time contributor

I'm not sure MAT_CONVERT_CAMERA_EXPORT is a proper name here. MAT_CONVERT_CAMERA is need for export operations too. However this inverse matrix is required in order to property calculate special properties UpVector, InterestPosition.

I'm not sure MAT_CONVERT_CAMERA_EXPORT is a proper name here. MAT_CONVERT_CAMERA is need for export operations too. However this inverse matrix is required in order to property calculate special properties UpVector, InterestPosition.
Author
First-time contributor

Originally I tested FBX cameras in QtQuick3D. At the first time, I exported a blender scene into a FBX format and read it through libassimp.
Recently I found a bug in libassimp which assumed the camera properties as default values and fixed it.(cdfdd75a66) This patch is related with it.

I tested it with FBXSDK while exporting blender scenes having a camera to FBXs.
Do you have any example fbx files for more tests?

I didn't consider any import cases.

Originally I tested FBX cameras in QtQuick3D. At the first time, I exported a blender scene into a FBX format and read it through libassimp. Recently I found a bug in libassimp which assumed the camera properties as default values and fixed it.(https://github.com/assimp/assimp/commit/cdfdd75a66e2323bd834f923798d3043ad3deaf8) This patch is related with it. I tested it with FBXSDK while exporting blender scenes having a camera to FBXs. Do you have any example fbx files for more tests? I didn't consider any import cases.

Issue #45176 is about Import, so it would not be correct to say that this fixes that issue in your description.

Issue #45176 is about Import, so it would not be correct to say that this fixes that issue in your description.
Inho Lee force-pushed main from d995d8c634 to 29b8d4967e 2023-04-14 12:27:40 +02:00 Compare
Inho Lee force-pushed main from 29b8d4967e to f30518faf8 2023-04-14 12:28:54 +02:00 Compare
Inho Lee changed title from FBX export: Fix Camera rotation to FBX import/export: Fix Camera rotation 2023-04-14 12:31:55 +02:00
Author
First-time contributor

I tested import feature and the fbx files in Issue #45176

I tested import feature and the fbx files in Issue #45176
Member

With the import patch, importing an FBX exported by Blender (default settings for both import and export) (both with and without the export patches in this PR) results in the camera being inverted for me.
For example, Blender's default startup scene exported as FBX and re-imported:
image

The export patch changes the "Up", "To", "UpVector" and "InterestPosition" properties, but as far as I can tell, the FBX importer doesn't read any of those properties in the first place.

With the import patch, importing an FBX exported by Blender (default settings for both import and export) (both with and without the export patches in this PR) results in the camera being inverted for me. For example, Blender's default startup scene exported as FBX and re-imported: ![image](/attachments/573b25b2-512d-4c30-97f4-03a1bd6e86b8) The export patch changes the `"Up"`, `"To"`, `"UpVector"` and `"InterestPosition"` properties, but as far as I can tell, the FBX importer doesn't read any of those properties in the first place.
107 KiB
Author
First-time contributor

With the import patch, importing an FBX exported by Blender (default settings for both import and export) (both with and without the export patches in this PR) results in the camera being inverted for me.
For example, Blender's default startup scene exported as FBX and re-imported:
image

The export patch changes the "Up", "To", "UpVector" and "InterestPosition" properties, but as far as I can tell, the FBX importer doesn't read any of those properties in the first place.

Oh Thanks. Now I could understand fully. I'll upload the patch in this weekend.

> With the import patch, importing an FBX exported by Blender (default settings for both import and export) (both with and without the export patches in this PR) results in the camera being inverted for me. > For example, Blender's default startup scene exported as FBX and re-imported: > ![image](/attachments/573b25b2-512d-4c30-97f4-03a1bd6e86b8) > > The export patch changes the `"Up"`, `"To"`, `"UpVector"` and `"InterestPosition"` properties, but as far as I can tell, the FBX importer doesn't read any of those properties in the first place. Oh Thanks. Now I could understand fully. I'll upload the patch in this weekend.
Member

Since this PR was originally only affecting exports, I've tried to find and fix the import issue with #104561

Since this PR was originally only affecting exports, I've tried to find and fix the import issue with https://projects.blender.org/blender/blender-addons/pulls/104561
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u main:Inho-Lee-main
git checkout Inho-Lee-main
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
4 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#104500
No description provided.