COLLADA: added initial support for ymag and yfov in importer. fixes issue #32237
authorGaia Clary <gaia.clary@machinimatrix.org>
Sat, 4 Aug 2012 21:25:19 +0000 (21:25 +0000)
committerGaia Clary <gaia.clary@machinimatrix.org>
Sat, 4 Aug 2012 21:25:19 +0000 (21:25 +0000)
source/blender/collada/AnimationImporter.cpp
source/blender/collada/AnimationImporter.h

index 9c11358ce7f7ca6237a621e5f185374d5bd6a06d..3b5b96bc544c1f4a9e6500dba111cf65065cbe03 100644 (file)
@@ -934,12 +934,24 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
                                Assign_float_animations(listid, AnimCurves, "lens");
                        }
 
+                       else if ((animType->camera & CAMERA_YFOV) != 0) {
+                               const COLLADAFW::AnimatableFloat *yfov =  &(camera->getYFov());
+                               const COLLADAFW::UniqueId& listid = yfov->getAnimationList();
+                               Assign_float_animations(listid, AnimCurves, "lens");
+                       }
+
                        else if ((animType->camera & CAMERA_XMAG) != 0) {
                                const COLLADAFW::AnimatableFloat *xmag =  &(camera->getXMag());
                                const COLLADAFW::UniqueId& listid = xmag->getAnimationList();
                                Assign_float_animations(listid, AnimCurves, "ortho_scale");
                        }
 
+                       else if ((animType->camera & CAMERA_YMAG) != 0) {
+                               const COLLADAFW::AnimatableFloat *ymag =  &(camera->getYMag());
+                               const COLLADAFW::UniqueId& listid = ymag->getAnimationList();
+                               Assign_float_animations(listid, AnimCurves, "ortho_scale");
+                       }
+
                        if ((animType->camera & CAMERA_ZFAR) != 0) {
                                const COLLADAFW::AnimatableFloat *zfar =  &(camera->getFarClippingPlane());
                                const COLLADAFW::UniqueId& listid = zfar->getAnimationList();
@@ -1166,14 +1178,22 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(const COLLADAF
 
        const COLLADAFW::InstanceCameraPointerArray& nodeCameras = node->getInstanceCameras();
        for (unsigned int i = 0; i < nodeCameras.getCount(); i++) {
-               const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
-
-               if (camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE) {
-                       types->camera = setAnimType(&(camera->getXMag()), (types->camera), CAMERA_XFOV);
+               const COLLADAFW::Camera *camera  = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
+               const bool is_perspective_type   = camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE;
+
+               int addition;
+               const COLLADAFW::Animatable *mag;
+               const COLLADAFW::UniqueId listid = camera->getYMag().getAnimationList();
+               if (animlist_map.find(listid) != animlist_map.end()) {
+                       mag = &(camera->getYMag());
+                       addition = (is_perspective_type) ? CAMERA_YFOV: CAMERA_YMAG;
                }
                else {
-                       types->camera = setAnimType(&(camera->getXMag()), (types->camera), CAMERA_XMAG);
+                       mag = &(camera->getXMag());
+                       addition = (is_perspective_type) ? CAMERA_XFOV: CAMERA_XMAG;
                }
+               types->camera = setAnimType(mag, (types->camera), addition);
+
                types->camera = setAnimType(&(camera->getFarClippingPlane()), (types->camera), CAMERA_ZFAR);
                types->camera = setAnimType(&(camera->getNearClippingPlane()), (types->camera), CAMERA_ZNEAR);
 
@@ -1205,10 +1225,14 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(const COLLADAF
 
 int AnimationImporter::setAnimType(const COLLADAFW::Animatable *prop, int types, int addition)
 {
-       const COLLADAFW::UniqueId& listid =  prop->getAnimationList();
+       int anim_type;
+       const COLLADAFW::UniqueId& listid       = prop->getAnimationList();
        if (animlist_map.find(listid) != animlist_map.end())
-               return types | addition;
-       else return types;
+               anim_type =  types | addition;
+       else
+               anim_type = types;
+
+       return anim_type;
 }              
 
 // Is not used anymore.
index d6a93a36c6e9c7498b7b5d2ccc1126a56ce9142b..32af2b5b78b2472daad6b3ab188fc01573131c22 100644 (file)
@@ -102,8 +102,10 @@ private:
 //             INANIMATE = 0,
                CAMERA_XFOV = 2,
                CAMERA_XMAG = 4,
-               CAMERA_ZFAR = 8,
-               CAMERA_ZNEAR = 16
+               CAMERA_YFOV = 8,
+               CAMERA_YMAG = 16,
+               CAMERA_ZFAR = 32,
+               CAMERA_ZNEAR = 64
        };
 
        enum matAnim