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
pull/1131/head
Matt Oliver 2017-01-09 16:11:32 +11:00
parent b34a552fb7
commit 5be2351dc6
2 changed files with 9 additions and 3 deletions

View File

@ -719,10 +719,13 @@ void Converter::ConvertCamera( const Model& model, const Camera& cam )
out_camera->mName.Set( FixNodeName( model.Name() ) ); out_camera->mName.Set( FixNodeName( model.Name() ) );
out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight(); out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight();
out_camera->mPosition = cam.Position(); //cameras are defined along positive x direction
out_camera->mUp = cam.UpVector(); out_camera->mPosition = aiVector3D(0.0f);
out_camera->mLookAt = cam.InterestPosition() - out_camera->mPosition; 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->mHorizontalFOV = AI_DEG_TO_RAD( cam.FieldOfView() );
out_camera->mClipPlaneNear = cam.NearPlane();
out_camera->mClipPlaneFar = cam.FarPlane();
} }

View File

@ -240,6 +240,9 @@ public:
fbx_simple_property(FilmWidth, float, 1.0f) fbx_simple_property(FilmWidth, float, 1.0f)
fbx_simple_property(FilmHeight, 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(FilmAspectRatio, float, 1.0f)
fbx_simple_property(ApertureMode, int, 0) fbx_simple_property(ApertureMode, int, 0)