(no commit message)
authorSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>
Thu, 21 Jul 2011 18:31:01 +0000 (18:31 +0000)
committerSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>
Thu, 21 Jul 2011 18:31:01 +0000 (18:31 +0000)
source/blender/collada/AnimationImporter.cpp

index 129f3192ce2b2208c55c2549f81224429e01cb09..e6c35b3ffb717f5b3b8f93aee987298fa8573f99 100644 (file)
@@ -50,6 +50,7 @@
 #include "collada_utils.h"
 #include "AnimationImporter.h"
 #include "ArmatureImporter.h"
+#include "MaterialExporter.h"
 
 #include <algorithm>
 
@@ -905,8 +906,35 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node ,
 
                }
        }
+               if ( animType->material != 0){
+                        Material *ma = give_current_material(ob, 1);
+                        if (!ma->adt || !ma->adt->action) act = verify_adt_action((ID*)&ma->id, 1);
+                                       else act = ma->adt->action;
+       
+                       ListBase *AnimCurves = &(act->curves);
+                       
+                       const COLLADAFW::InstanceGeometryPointerArray& nodeGeoms = node->getInstanceGeometries();
+                       for (unsigned int i = 0; i < nodeGeoms.getCount(); i++) {
+                               const COLLADAFW::MaterialBindingArray& matBinds = nodeGeoms[i]->getMaterialBindings();
+                               for (unsigned int j = 0; j < matBinds.getCount(); j++) {
+                                       const COLLADAFW::Material *mat = (COLLADAFW::Material *) FW_object_map[matBinds[j].getReferencedMaterial()];
+                                       const COLLADAFW::Effect *ef = (COLLADAFW::Effect *) FW_object_map[mat->getInstantiatedEffect()];
+                                       COLLADAFW::CommonEffectPointerArray commonEffects  =  ef->getCommonEffects();
+                                       for (unsigned int k = 0; k < commonEffects.getCount(); k++) {
+                                               COLLADAFW::EffectCommon *efc = commonEffects[k];
+                                               if((animType->material & MATERIAL_SHININESS) != 0){
+                                                       const COLLADAFW::FloatOrParam *shin = &(efc->getShininess());
+                                                       const COLLADAFW::UniqueId& listid =  shin->getAnimationList();
+                                                       Assign_float_animations( listid, AnimCurves , "specular_hardness" );
+                                               }
+                                       }
+                               }       
+                       }
+               }
+               
 }
 
+
 //Check if object is animated by checking if animlist_map holds the animlist_id of node transforms
 AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLADAFW::Node * node , 
                                                                                        std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map) 
@@ -970,12 +998,13 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
        const COLLADAFW::InstanceGeometryPointerArray& nodeGeoms = node->getInstanceGeometries();
        for (unsigned int i = 0; i < nodeGeoms.getCount(); i++) {
                const COLLADAFW::MaterialBindingArray& matBinds = nodeGeoms[i]->getMaterialBindings();
-               for (unsigned int j = 0; i < matBinds.getCount(); i++) {
-                       const COLLADAFW::Material *mat = (COLLADAFW::Material *) FW_object_map[matBinds[i].getReferencedMaterial()];
+               for (unsigned int j = 0; j < matBinds.getCount(); j++) {
+                       const COLLADAFW::Material *mat = (COLLADAFW::Material *) FW_object_map[matBinds[j].getReferencedMaterial()];
                        const COLLADAFW::Effect *ef = (COLLADAFW::Effect *) FW_object_map[mat->getInstantiatedEffect()];
-                       const COLLADAFW::CommonEffectPointerArray& commonEffects  =  ef->getCommonEffects();
-                       for (unsigned int k = 0; i < commonEffects.getCount(); i++) {
-                               types->material =  setAnimType(&(commonEffects[i]->getShininess()),(types->material), MATERIAL_SHININESS);
+                   COLLADAFW::CommonEffectPointerArray commonEffects  =  ef->getCommonEffects();
+                       for (unsigned int k = 0; k < commonEffects.getCount(); k++) {
+                               COLLADAFW::EffectCommon *efc = commonEffects[k];
+                               types->material =  setAnimType(&(efc->getShininess()),(types->material), MATERIAL_SHININESS);
                        }
                }