From 23a3e8cf2d2670b1511f96927953a680a5346f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suhajda=20Tam=C3=A1s?= Date: Tue, 4 Apr 2023 19:39:32 +0200 Subject: [PATCH] ConvertToLHProcess noew inverts viewing direction --- code/PostProcessing/ConvertToLHProcess.cpp | 13 +++++++++++++ code/PostProcessing/ConvertToLHProcess.h | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/code/PostProcessing/ConvertToLHProcess.cpp b/code/PostProcessing/ConvertToLHProcess.cpp index 08e3fe48a..0d5f3dc42 100644 --- a/code/PostProcessing/ConvertToLHProcess.cpp +++ b/code/PostProcessing/ConvertToLHProcess.cpp @@ -113,6 +113,12 @@ void MakeLeftHandedProcess::Execute(aiScene *pScene) { ProcessAnimation(nodeAnim); } } + + // process the cameras accordingly + for( unsigned int a = 0; a < pScene->mNumCameras; ++a) + { + ProcessCamera(pScene->mCameras[a]); + } ASSIMP_LOG_DEBUG("MakeLeftHandedProcess finished"); } @@ -231,6 +237,13 @@ void MakeLeftHandedProcess::ProcessAnimation(aiNodeAnim *pAnim) { } } +// ------------------------------------------------------------------------------------------------ +// Converts a single camera to left handed coordinates. +void MakeLeftHandedProcess::ProcessCamera( aiCamera* pCam) +{ + pCam->mLookAt = 2.0f * pCam->mPosition - pCam->mLookAt; +} + #endif // !! ASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS #ifndef ASSIMP_BUILD_NO_FLIPUVS_PROCESS // # FlipUVsProcess diff --git a/code/PostProcessing/ConvertToLHProcess.h b/code/PostProcessing/ConvertToLHProcess.h index d0532277d..ea001b95b 100644 --- a/code/PostProcessing/ConvertToLHProcess.h +++ b/code/PostProcessing/ConvertToLHProcess.h @@ -58,6 +58,7 @@ struct aiMesh; struct aiNodeAnim; struct aiNode; struct aiMaterial; +struct aiCamera; namespace Assimp { @@ -109,6 +110,14 @@ protected: * @param pAnim The bone animation to transform */ void ProcessAnimation( aiNodeAnim* pAnim); + + // ------------------------------------------------------------------- + /** Converts a single camera to left handed coordinates. + * The camera viewing direction is inverted by reflecting mLookAt + * across mPosition. + * @param pCam The camera to convert + */ + void ProcessCamera( aiCamera* pCam); };