瀏覽代碼

Add support for orthographic camera information and use in glTF2 importer. Fixes #3030.

Paul Arden 5 年之前
父節點
當前提交
ae50c4ebdf
共有 2 個文件被更改,包括 18 次插入6 次删除
  1. 1 0
      code/glTF2/glTF2Importer.cpp
  2. 17 6
      include/assimp/camera.h

+ 1 - 0
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;

+ 17 - 6
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