fix:32348 Collada yfov to xfov conversion fo camera settings
authorGaia Clary <gaia.clary@machinimatrix.org>
Mon, 3 Sep 2012 17:54:04 +0000 (17:54 +0000)
committerGaia Clary <gaia.clary@machinimatrix.org>
Mon, 3 Sep 2012 17:54:04 +0000 (17:54 +0000)
source/blender/collada/AnimationImporter.cpp
source/blender/collada/DocumentImporter.cpp

index d241926c20ce59fc07d6a121fa0c2d82cfad40f2..b2748a55b6af20d661727494a96e68e1059bf48c 100644 (file)
@@ -683,12 +683,11 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId& listid
                                for (unsigned int i = 0; i < fcu->totvert; i++) {
 
                                        double input_fov = fcu->bezt[i].vec[1][1];
-                                       double xfov = (fov_type == CAMERA_YFOV) ? aspect * input_fov : input_fov;
 
-                                       // fov is in degrees, cam->lens is in millimiters
-                                       double fov = fov_to_focallength(DEG2RADF(input_fov), cam->sensor_x);
+                                       // NOTE: Needs more testing (As we curretnly have no official test data for this)
+                                       double xfov = (fov_type == CAMERA_YFOV) ? (2.0f * atanf(aspect * tanf(DEG2RADF(input_fov) * 0.5f))) : DEG2RADF(input_fov);
 
-                                       fcu->bezt[i].vec[1][1] = fov;
+                                       fcu->bezt[i].vec[1][1] = fov_to_focallength(xfov, cam->sensor_x);
                                }
 
                                BLI_addtail(AnimCurves, fcu);
index 60b03a211ba30816504fbf66f7731f16f4a14b11..e171cfecc231e1a48fb5deed498de158a46b1b19 100644 (file)
@@ -867,9 +867,11 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
                                {
                                        double yfov = camera->getYFov().getValue();
                                        double aspect = camera->getAspectRatio().getValue();
-                                       double xfov = aspect * yfov;
-                                       // xfov is in degrees, cam->lens is in millimiters
-                                       cam->lens = fov_to_focallength(DEG2RADF(xfov), cam->sensor_x);
+
+                                       // NOTE: Needs more testing (As we curretnly have no official test data for this)
+
+                                       double xfov = 2.0f * atanf(aspect * tanf(DEG2RADF(yfov) * 0.5f));
+                                       cam->lens = fov_to_focallength(xfov, cam->sensor_x);
                                }
                                break;
                        }