Revision: 38055
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38055
Author:   phabtar
Date:     2011-07-03 11:07:34 +0000 (Sun, 03 Jul 2011)
Log Message:
-----------
Light Animation Identification.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
    branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h
    branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp
    branches/soc-2011-pepper/source/blender/collada/DocumentImporter.h

Modified: branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp       
2011-07-03 10:48:18 UTC (rev 38054)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp       
2011-07-03 11:07:34 UTC (rev 38055)
@@ -675,7 +675,8 @@
 
 void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , 
                                                                                
                   std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
-                                                                               
                   std::map<COLLADAFW::UniqueId, Object*>& object_map )
+                                                                               
                   std::map<COLLADAFW::UniqueId, Object*>& object_map,
+                                                                               
                   std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> 
FW_object_map)
 {
        bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
        
@@ -684,7 +685,7 @@
        
        const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
     
-       if ( ! is_object_animated(node) ) return ;  
+       if ( ! is_object_animated(node, FW_object_map) ) return ;  
 
     char joint_path[200];
 
@@ -776,13 +777,11 @@
                                ob->rotmode = ROT_MODE_EUL;
                        }
                }
- 
        }
-       
 }
 
 //Check if object is animated by checking if animlist_map holds the 
animlist_id of node transforms
-bool AnimationImporter::is_object_animated ( const COLLADAFW::Node * node ) 
+bool AnimationImporter::is_object_animated ( const COLLADAFW::Node * node , 
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map ) 
 {
        bool exists = false;
        const COLLADAFW::TransformationPointerArray& nodeTransforms = 
node->getTransformations();
@@ -800,7 +799,22 @@
                        break;
                }
        }
+       const COLLADAFW::InstanceLightPointerArray& nodeLights = 
node->getInstanceLights();
 
+       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& listid = col->getAnimationList();
+
+               //check if color has animations    
+               if (animlist_map.find(listid) == animlist_map.end()) continue ;
+               else 
+               {
+                       exists = true;
+                       break;
+               }
+       }
+       
        return exists;
 }
 

Modified: branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h 
2011-07-03 10:48:18 UTC (rev 38054)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h 
2011-07-03 11:07:34 UTC (rev 38055)
@@ -37,6 +37,7 @@
 #include "COLLADAFWAnimationList.h"
 #include "COLLADAFWNode.h"
 #include "COLLADAFWUniqueId.h"
+#include "COLLADAFWLight.h"
 
 #include "DNA_anim_types.h"
 #include "DNA_object_types.h"
@@ -97,9 +98,10 @@
   
     void translate_Animations_NEW ( COLLADAFW::Node * Node , 
                                                                                
                   std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
-                                                                               
                   std::map<COLLADAFW::UniqueId, Object*>& object_map );
+                                                                               
                   std::map<COLLADAFW::UniqueId, Object*>& object_map ,
+                                                                               
                   std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> 
FW_object_map);
 
-       bool is_object_animated ( const COLLADAFW::Node * node ) ;
+       bool is_object_animated ( const COLLADAFW::Node * node , 
std::map<COLLADAFW::UniqueId,const COLLADAFW::Object*> FW_object_map ) ;
 
 
        void Assign_transform_animations(std::vector<float>* frames, 

Modified: branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp        
2011-07-03 10:48:18 UTC (rev 38054)
+++ branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp        
2011-07-03 11:07:34 UTC (rev 38055)
@@ -252,7 +252,7 @@
 
        //for (i = 0; i < 4; i++)
                //ob = 
-       anim_importer.translate_Animations_NEW(node, root_map, object_map);
+       anim_importer.translate_Animations_NEW(node, root_map, object_map, 
FW_object_map);
 
        COLLADAFW::NodePointerArray &children = node->getChildNodes();
        for (i = 0; i < children.getCount(); i++) {
@@ -1051,6 +1051,7 @@
        }
 
        this->uid_lamp_map[light->getUniqueId()] = lamp;
+       this->FW_object_map[light->getUniqueId()] = light;
        return true;
 }
 

Modified: branches/soc-2011-pepper/source/blender/collada/DocumentImporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/DocumentImporter.h  
2011-07-03 10:48:18 UTC (rev 38054)
+++ branches/soc-2011-pepper/source/blender/collada/DocumentImporter.h  
2011-07-03 11:07:34 UTC (rev 38055)
@@ -157,7 +157,7 @@
        std::vector<Object*> libnode_ob;
 
        std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map; // find root 
joint by child joint uid, for bone tree evaluation during resampling
-
+       std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map;
 };
 
 #endif

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to