(no commit message)
authorSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>
Sat, 9 Jul 2011 19:33:02 +0000 (19:33 +0000)
committerSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>
Sat, 9 Jul 2011 19:33:02 +0000 (19:33 +0000)
source/blender/collada/AnimationImporter.cpp
source/blender/collada/AnimationImporter.h
source/blender/collada/CameraExporter.cpp

index 5f4d4905646d56c4c40259ae2354ee3bb4f1a2f7..030b9e7582bbdf85fc14395be2bb7ea8836be479 100644 (file)
@@ -919,28 +919,30 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
 
        for (unsigned int i = 0; i < nodeLights.getCount(); i++) {
                const COLLADAFW::Light *light = (COLLADAFW::Light *) FW_object_map[nodeLights[i]->getInstanciatedObjectId()];
+               //
+               //const COLLADAFW::Color *col =  &(light->getColor());
+               //const COLLADAFW::UniqueId& col_listid = col->getAnimationList();
+
+               ////check if color has animations    
+               //if (animlist_map.find(col_listid) != animlist_map.end())  
+               ////    type = type|LIGHT_FOA;
+               //      types->light = types->light|LIGHT_COLOR;
+               types->light = setAnimType(&(light->getColor()),(types->light), LIGHT_COLOR);
+               //
+               //const COLLADAFW::AnimatableFloat *fallOffAngle =  &(light->getFallOffAngle());
+        //   const COLLADAFW::UniqueId& foa_listid = fallOffAngle ->getAnimationList();
+
+               //if (animlist_map.find(foa_listid) != animlist_map.end()) 
+               ////            type = type|LIGHT_FOA;
+               //              types->light = types->light|LIGHT_FOA;
+               types->light = setAnimType(&(light->getFallOffAngle()),(types->light), LIGHT_FOA);
+               //const COLLADAFW::AnimatableFloat *fallOffExpo =  &(light->getFallOffExponent());
+        //   const COLLADAFW::UniqueId& foe_listid = fallOffExpo ->getAnimationList();
+               //if (animlist_map.find(foe_listid) != animlist_map.end()) 
+               //              //type = type|LIGHT_FOE;
+               //              types->light = types->light|LIGHT_FOE;
                
-               const COLLADAFW::Color *col =  &(light->getColor());
-               const COLLADAFW::UniqueId& col_listid = col->getAnimationList();
-
-               //check if color has animations    
-               if (animlist_map.find(col_listid) != animlist_map.end())  
-               //      type = type|LIGHT_FOA;
-                       types->light = types->light|LIGHT_COLOR;
-               
-               const COLLADAFW::AnimatableFloat *fallOffAngle =  &(light->getFallOffAngle());
-           const COLLADAFW::UniqueId& foa_listid = fallOffAngle ->getAnimationList();
-
-               if (animlist_map.find(foa_listid) != animlist_map.end()) 
-               //              type = type|LIGHT_FOA;
-                               types->light = types->light|LIGHT_FOA;
-               
-               const COLLADAFW::AnimatableFloat *fallOffExpo =  &(light->getFallOffExponent());
-           const COLLADAFW::UniqueId& foe_listid = fallOffExpo ->getAnimationList();
-
-               if (animlist_map.find(foe_listid) != animlist_map.end()) 
-                               //type = type|LIGHT_FOE;
-                               types->light = types->light|LIGHT_FOE;
+               types->light = setAnimType(&(light->getFallOffExponent()),(types->light), LIGHT_FOE);
                
                //if ( type != 0) break;
                if ( types->light != 0) break;
@@ -950,24 +952,37 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
        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 )
                {
-                       const COLLADAFW::AnimatableFloat *xfov =  &(camera->getXFov());
-                       const COLLADAFW::UniqueId& xfov_listid = xfov ->getAnimationList();
-                       if (animlist_map.find(xfov_listid) != animlist_map.end()) 
-                               //type = type|CAMERA_XFOV;      
-                               types->camera = types->camera|CAMERA_XFOV;
-               
+                       //const COLLADAFW::AnimatableFloat *xfov =  &(camera->getXFov());
+                       //const COLLADAFW::UniqueId& xfov_listid = xfov ->getAnimationList();
+                       //if (animlist_map.find(xfov_listid) != animlist_map.end()) 
+                       //      //type = type|CAMERA_XFOV;      
+                       //      types->camera = types->camera|CAMERA_XFOV;
+                   types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XFOV);
                }
                else 
                {
-                       const COLLADAFW::AnimatableFloat *xmag =  &(camera->getXMag());
-                       const COLLADAFW::UniqueId& xmag_listid = xmag ->getAnimationList();
-                       if (animlist_map.find(xmag_listid) != animlist_map.end()) 
-                               //      type = type|CAMERA_XMAG;
-                               types->camera = types->camera|CAMERA_XMAG;
-               }       
+                       //const COLLADAFW::AnimatableFloat *xmag =  &(camera->getXMag());
+                       //const COLLADAFW::UniqueId& xmag_listid = xmag ->getAnimationList();
+                       //if (animlist_map.find(xmag_listid) != animlist_map.end()) 
+                       //      //      type = type|CAMERA_XMAG;
+                       //      types->camera = types->camera|CAMERA_XMAG;
+                       types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XMAG);
+               }
+
+               //const COLLADAFW::AnimatableFloat *zfar =  &(camera->getFarClippingPlane());
+               //const COLLADAFW::UniqueId& zfar_listid = zfar ->getAnimationList();
+               //if (animlist_map.find(zfar_listid) != animlist_map.end()) 
+               //              //type = type|CAMERA_XFOV;      
+               //              types->camera = types->camera|CAMERA_ZFAR;
+
+               
+               types->camera = setAnimType(&(camera->getFarClippingPlane()),(types->camera), CAMERA_ZFAR);
+               types->camera = setAnimType(&(camera->getNearClippingPlane()),(types->camera), CAMERA_ZNEAR);
+
                //if ( type != 0) break;
                if ( types->camera != 0) break;
 
@@ -975,6 +990,14 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
        return types;
 }
 
+int AnimationImporter::setAnimType ( const COLLADAFW::Animatable * prop , int types, int addition)
+{
+               const COLLADAFW::UniqueId& listid =  prop->getAnimationList();
+               if (animlist_map.find(listid) != animlist_map.end()) 
+                               return types|addition;
+               else return types;
+}              
+
 //XXX Is not used anymore.
 void AnimationImporter::find_frames_old(std::vector<float> * frames, COLLADAFW::Node * node , COLLADAFW::Transformation::TransformationType tm_type)
 {
index 037ae04a0b4acc69653a880a8363bc6c1ecc38fe..9337e80d63bbb3e5a29b40dba0364659335a8774 100644 (file)
@@ -98,18 +98,15 @@ private:
        {
 //             INANIMATE = 0,
                CAMERA_XFOV = 2,
-               CAMERA_XMAG = 4
+               CAMERA_XMAG = 4,
+               CAMERA_ZFAR = 8,
+               CAMERA_ZNEAR = 16
        };
        
        enum AnimationType
                {
                        INANIMATE = 0,
                        NODE_TRANSFORM = 1,
-       /*              LIGHT_COLOR     = 2,
-                       LIGHT_FOA = 4,
-                       LIGHT_FOE = 8,
-                       CAMERA_XFOV = 16,
-                       CAMERA_XMAG = 32*/
                };
 
        struct AnimMix
@@ -152,7 +149,9 @@ public:
                                                                 std::vector<FCurve*>* curves);
 
        void Assign_float_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, char * anim_type);
-
+    
+       int setAnimType ( const COLLADAFW::Animatable * prop , int type, int addition);
+       
        void modify_fcurve(std::vector<FCurve*>* curves , char* rna_path , int array_index );
        // prerequisites:
        // animlist_map - map animlist id -> animlist
index cc9860723fef46565f3a03cc34d4623e6087597b..a935f45c4031b0da32971ed98d3143bcf5f41320 100644 (file)
@@ -76,7 +76,7 @@ void CamerasExporter::operator()(Object *ob, Scene *sce)
                persp.setXFov(lens_to_angle(cam->lens)*(180.0f/M_PI),"xfov");
                persp.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch),false,"aspect_ratio");
                persp.setZFar(cam->clipend, false , "zfar");
-               persp.setZNear(cam->clipsta);
+               persp.setZNear(cam->clipsta,false , "znear");
                COLLADASW::Camera ccam(mSW, &persp, cam_id, cam_name);
                addCamera(ccam);
        }
@@ -85,7 +85,7 @@ void CamerasExporter::operator()(Object *ob, Scene *sce)
                ortho.setXMag(cam->ortho_scale,"xmag");
                ortho.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch),false,"aspect_ratio");
                ortho.setZFar(cam->clipend , false , "zfar");
-               ortho.setZNear(cam->clipsta);
+               ortho.setZNear(cam->clipsta, false , "znear");
                COLLADASW::Camera ccam(mSW, &ortho, cam_id, cam_name);
                addCamera(ccam);
        }