+/*
+ * Lens animations must be stored in COLLADA by using FOV,
+ * while blender internally uses focal length.
+ * The imported animation curves must be converted appropriately.
+ */
+void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const double aspect, Camera *cam, const char *anim_type, int fov_type)
+{
+ char rna_path[100];
+ if (animlist_map.find(listid) == animlist_map.end()) {
+ return;
+ }
+ else {
+ //anim_type has animations
+ const COLLADAFW::AnimationList *animlist = animlist_map[listid];
+ const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings();
+ //all the curves belonging to the current binding
+ std::vector<FCurve *> animcurves;
+ for (unsigned int j = 0; j < bindings.getCount(); j++) {
+ animcurves = curve_map[bindings[j].animation];
+
+ BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
+
+ modify_fcurve(&animcurves, rna_path, 0);
+ std::vector<FCurve *>::iterator iter;
+ //Add the curves of the current animation to the object
+ for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
+ FCurve *fcu = *iter;
+
+ 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);
+
+ fcu->bezt[i].vec[1][1] = fov;
+ }
+
+ BLI_addtail(AnimCurves, fcu);
+ }
+ }
+ }
+}
+