From fb5b01958a448e1c3dea9b6b2796b8bf9f98a5a7 Mon Sep 17 00:00:00 2001 From: Paul Arden Date: Tue, 25 Feb 2020 11:03:07 +1100 Subject: [PATCH 1/3] Fix to read orthographic camera data. Manual merge for this branch. Fixes #3028 --- code/glTF2/glTF2Asset.inl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/glTF2/glTF2Asset.inl b/code/glTF2/glTF2Asset.inl index 4259022e9..184ad7419 100644 --- a/code/glTF2/glTF2Asset.inl +++ b/code/glTF2/glTF2Asset.inl @@ -1087,10 +1087,10 @@ inline void Camera::Read(Value& obj, Asset& /*r*/) cameraProperties.perspective.znear = MemberOrDefault(*it, "znear", 0.01f); } else { - cameraProperties.ortographic.xmag = MemberOrDefault(obj, "xmag", 1.f); - cameraProperties.ortographic.ymag = MemberOrDefault(obj, "ymag", 1.f); - cameraProperties.ortographic.zfar = MemberOrDefault(obj, "zfar", 100.f); - cameraProperties.ortographic.znear = MemberOrDefault(obj, "znear", 0.01f); + cameraProperties.ortographic.xmag = MemberOrDefault(*it, "xmag", 1.f); + cameraProperties.ortographic.ymag = MemberOrDefault(*it, "ymag", 1.f); + cameraProperties.ortographic.zfar = MemberOrDefault(*it, "zfar", 100.f); + cameraProperties.ortographic.znear = MemberOrDefault(*it, "znear", 0.01f); } } From ae50c4ebdf23c7f6f61300dede5bf32e0d306eb2 Mon Sep 17 00:00:00 2001 From: Paul Arden Date: Tue, 25 Feb 2020 14:45:00 +1100 Subject: [PATCH 2/3] Add support for orthographic camera information and use in glTF2 importer. Fixes #3030. --- code/glTF2/glTF2Importer.cpp | 1 + include/assimp/camera.h | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/code/glTF2/glTF2Importer.cpp b/code/glTF2/glTF2Importer.cpp index dd80aeba9..cd67e69b7 100644 --- a/code/glTF2/glTF2Importer.cpp +++ b/code/glTF2/glTF2Importer.cpp @@ -715,6 +715,7 @@ void glTF2Importer::ImportCameras(glTF2::Asset &r) { aicam->mClipPlaneFar = cam.cameraProperties.ortographic.zfar; aicam->mClipPlaneNear = cam.cameraProperties.ortographic.znear; aicam->mHorizontalFOV = 0.0; + aicam->mOrthographicWidth = cam.cameraProperties.ortographic.xmag; aicam->mAspect = 1.0f; if (0.f != cam.cameraProperties.ortographic.ymag) { aicam->mAspect = cam.cameraProperties.ortographic.xmag / cam.cameraProperties.ortographic.ymag; diff --git a/include/assimp/camera.h b/include/assimp/camera.h index adb749ff5..ef52fce71 100644 --- a/include/assimp/camera.h +++ b/include/assimp/camera.h @@ -171,15 +171,26 @@ struct aiCamera */ float mAspect; + /** Half horizontal orthographic width, in scene units. + * + * The orthographic width specifies the half width of the + * orthographic view box. If non-zero the camera is + * orthographic and the mAspect should define to the + * ratio between the orthographic width and height + * and mHorizontalFOV should be set to 0. + * The default value is 0 (not orthographic). + */ + float mOrthographicWidth; #ifdef __cplusplus aiCamera() AI_NO_EXCEPT - : mUp (0.f,1.f,0.f) - , mLookAt (0.f,0.f,1.f) - , mHorizontalFOV (0.25f * (float)AI_MATH_PI) - , mClipPlaneNear (0.1f) - , mClipPlaneFar (1000.f) - , mAspect (0.f) + : mUp (0.f,1.f,0.f) + , mLookAt (0.f,0.f,1.f) + , mHorizontalFOV (0.25f * (float)AI_MATH_PI) + , mClipPlaneNear (0.1f) + , mClipPlaneFar (1000.f) + , mAspect (0.f) + , mOrthographicWidth (0.f) {} /** @brief Get a *right-handed* camera matrix from me From e56def7585804f39ee4889d11afe2508207308d9 Mon Sep 17 00:00:00 2001 From: Paul Arden Date: Tue, 25 Feb 2020 14:52:59 +1100 Subject: [PATCH 3/3] Fix indentation. --- include/assimp/camera.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/assimp/camera.h b/include/assimp/camera.h index ef52fce71..e266119fe 100644 --- a/include/assimp/camera.h +++ b/include/assimp/camera.h @@ -180,7 +180,7 @@ struct aiCamera * and mHorizontalFOV should be set to 0. * The default value is 0 (not orthographic). */ - float mOrthographicWidth; + float mOrthographicWidth; #ifdef __cplusplus aiCamera() AI_NO_EXCEPT @@ -190,7 +190,7 @@ struct aiCamera , mClipPlaneNear (0.1f) , mClipPlaneFar (1000.f) , mAspect (0.f) - , mOrthographicWidth (0.f) + , mOrthographicWidth (0.f) {} /** @brief Get a *right-handed* camera matrix from me