소스 검색

ConvertToLHProcess noew inverts viewing direction

Suhajda Tamás 2 년 전
부모
커밋
23a3e8cf2d
2개의 변경된 파일22개의 추가작업 그리고 0개의 파일을 삭제
  1. 13 0
      code/PostProcessing/ConvertToLHProcess.cpp
  2. 9 0
      code/PostProcessing/ConvertToLHProcess.h

+ 13 - 0
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

+ 9 - 0
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);
 };