From 5be2351dc6aa06502a561a5e2e8905d6c60e39ca Mon Sep 17 00:00:00 2001 From: Matt Oliver Date: Mon, 9 Jan 2017 16:11:32 +1100 Subject: [PATCH] FBX: Correct camera position and clip planes. Fbx cameras are stored in the scene graph as well as having separate camera properties. The separate camera properties have a camera position and direction that is already fully transformed based on its position in the scene graph so this results in the assimp camera being transformed twice. Since the scene graph contains all the relevant transformations the camera position and direction can just use default values. Fbx specifies cameras along the positive x axis so the default camera values have a up and direction set accordingly. Fixes: #807 #643 --- code/FBXConverter.cpp | 9 ++++++--- code/FBXDocument.h | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index ee9ce29fc..be7c41f10 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -719,10 +719,13 @@ void Converter::ConvertCamera( const Model& model, const Camera& cam ) out_camera->mName.Set( FixNodeName( model.Name() ) ); out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight(); - out_camera->mPosition = cam.Position(); - out_camera->mUp = cam.UpVector(); - out_camera->mLookAt = cam.InterestPosition() - out_camera->mPosition; + //cameras are defined along positive x direction + out_camera->mPosition = aiVector3D(0.0f); + out_camera->mLookAt = aiVector3D(1.0f, 0.0f, 0.0f); + out_camera->mUp = aiVector3D(0.0f, 1.0f, 0.0f); out_camera->mHorizontalFOV = AI_DEG_TO_RAD( cam.FieldOfView() ); + out_camera->mClipPlaneNear = cam.NearPlane(); + out_camera->mClipPlaneFar = cam.FarPlane(); } diff --git a/code/FBXDocument.h b/code/FBXDocument.h index 0abcdcf07..9c446250b 100644 --- a/code/FBXDocument.h +++ b/code/FBXDocument.h @@ -240,6 +240,9 @@ public: fbx_simple_property(FilmWidth, float, 1.0f) fbx_simple_property(FilmHeight, float, 1.0f) + fbx_simple_property(NearPlane, float, 0.1f) + fbx_simple_property(FarPlane, float, 100.0f) + fbx_simple_property(FilmAspectRatio, float, 1.0f) fbx_simple_property(ApertureMode, int, 0)