From 9915e875bf259f354d40bd97d0c4d0100e679477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suhajda=20Tam=C3=A1s?= Date: Mon, 3 Apr 2023 23:35:04 +0200 Subject: [PATCH 1/2] glTF2: Fix incorrect camera position --- code/AssetLib/glTF2/glTF2Importer.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index d30556806..fda89c2a7 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -1172,11 +1172,6 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector & if (node.camera) { pScene->mCameras[node.camera.GetIndex()]->mName = ainode->mName; - if (node.translation.isPresent) { - aiVector3D trans; - CopyValue(node.translation.value, trans); - pScene->mCameras[node.camera.GetIndex()]->mPosition = trans; - } } if (node.light) { From 9d76493ad846256ac3d6126c109380e332eb0066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suhajda=20Tam=C3=A1s?= Date: Tue, 4 Apr 2023 00:06:09 +0200 Subject: [PATCH 2/2] Fix mLookAt with pretransformed vertices mLookAt is a position vector inside the nodes reference frame, not a direction vector, so translation should be applied to it. --- code/PostProcessing/PretransformVertices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/PostProcessing/PretransformVertices.cpp b/code/PostProcessing/PretransformVertices.cpp index b6bb6155e..16548f09c 100644 --- a/code/PostProcessing/PretransformVertices.cpp +++ b/code/PostProcessing/PretransformVertices.cpp @@ -577,7 +577,7 @@ void PretransformVertices::Execute(aiScene *pScene) { // multiply all properties of the camera with the absolute // transformation of the corresponding node cam->mPosition = nd->mTransformation * cam->mPosition; - cam->mLookAt = aiMatrix3x3(nd->mTransformation) * cam->mLookAt; + cam->mLookAt = nd->mTransformation * cam->mLookAt; cam->mUp = aiMatrix3x3(nd->mTransformation) * cam->mUp; }