Light color parameter animation export support.
authorSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>
Thu, 30 Jun 2011 18:24:45 +0000 (18:24 +0000)
committerSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>
Thu, 30 Jun 2011 18:24:45 +0000 (18:24 +0000)
source/blender/collada/AnimationExporter.cpp
source/blender/collada/AnimationExporter.h
source/blender/collada/TransformReader.cpp

index ade1475c871a128e01e539a082e17ebb6008f766..50f96926fabc6b60db45b944d966d6a7a58e4cdc 100644 (file)
@@ -29,6 +29,7 @@ template<class Functor>
 void forEachObjectInScene(Scene *sce, Functor &f)
 {
        Base *base= (Base*) sce->base.first;
 void forEachObjectInScene(Scene *sce, Functor &f)
 {
        Base *base= (Base*) sce->base.first;
+       
        while(base) {
                Object *ob = base->object;
                        
        while(base) {
                Object *ob = base->object;
                        
@@ -54,8 +55,16 @@ void AnimationExporter::exportAnimations(Scene *sce)
        // called for each exported object
        void AnimationExporter::operator() (Object *ob) 
        {
        // called for each exported object
        void AnimationExporter::operator() (Object *ob) 
        {
-               if (!ob->adt || !ob->adt->action) return;  //this is already checked in hasAnimations()
-               FCurve *fcu = (FCurve*)ob->adt->action->curves.first;
+               FCurve *fcu;
+        if(ob->adt && ob->adt->action)      
+                               fcu = (FCurve*)ob->adt->action->curves.first;
+           else if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action )
+                               fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first);
+               else return;
+               //if (!ob->adt || !ob->adt->action) 
+               //      fcu = (FCurve*)((Lamp*)ob->data)->adt->action->curves.first;  //this is already checked in hasAnimations()
+               //else
+               //    fcu = (FCurve*)ob->adt->action->curves.first;
                char * transformName = extract_transform_name( fcu->rna_path );
                
                                        
                char * transformName = extract_transform_name( fcu->rna_path );
                
                                        
@@ -78,8 +87,10 @@ void AnimationExporter::exportAnimations(Scene *sce)
                                
                                if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) ||
                                        (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)||
                                
                                if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) ||
                                        (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)||
-                                       (!strcmp(transformName, "rotation_quaternion"))) 
+                                       (!strcmp(transformName, "rotation_quaternion")) ||
+                                       (!strcmp(transformName, "color"))) 
                                        dae_animation(ob ,fcu, transformName );
                                        dae_animation(ob ,fcu, transformName );
+                               
 
                                fcu = fcu->next;
                        }
 
                                fcu = fcu->next;
                        }
@@ -153,7 +164,12 @@ void AnimationExporter::exportAnimations(Scene *sce)
                        if (fcu->array_index < 4)
                        axis_name = axis_names[fcu->array_index];*/
                }
                        if (fcu->array_index < 4)
                        axis_name = axis_names[fcu->array_index];*/
                }
-
+               else if ( !strcmp(transformName, "color") )
+               {
+                       const char *axis_names[] = {"R", "G", "B"};
+                       if (fcu->array_index < 3)
+                       axis_name = axis_names[fcu->array_index];
+               }
                else
                {
                        const char *axis_names[] = {"X", "Y", "Z"};
                else
                {
                        const char *axis_names[] = {"X", "Y", "Z"};
@@ -837,17 +853,19 @@ void AnimationExporter::exportAnimations(Scene *sce)
        bool AnimationExporter::hasAnimations(Scene *sce)
        {
                Base *base= (Base*) sce->base.first;
        bool AnimationExporter::hasAnimations(Scene *sce)
        {
                Base *base= (Base*) sce->base.first;
+               
                while(base) {
                        Object *ob = base->object;
                        
                        FCurve *fcu = 0;
                        if(ob->adt && ob->adt->action)      
                                fcu = (FCurve*)ob->adt->action->curves.first;
                while(base) {
                        Object *ob = base->object;
                        
                        FCurve *fcu = 0;
                        if(ob->adt && ob->adt->action)      
                                fcu = (FCurve*)ob->adt->action->curves.first;
-                               
-                       //The Scene has animations if object type is armature or object has f-curve
+                       else if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action )
+                               fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first);
+                       //The Scene has animations if object type is armature or object has f-curve or object is a Lamp which has f-curves
                        if ((ob->type == OB_ARMATURE && ob->data) || fcu) {
                                return true;
                        if ((ob->type == OB_ARMATURE && ob->data) || fcu) {
                                return true;
-                       }
+                       } 
                        base= base->next;
                }
                return false;
                        base= base->next;
                }
                return false;
index e05fac4eed72517d4bbeaf338fc02cd5ed66d865..85e5e23d0f0d9cd3e1c611f83b44f843ef5ea90b 100644 (file)
@@ -32,6 +32,7 @@ extern "C"
 #include "DNA_anim_types.h"
 #include "DNA_action_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_anim_types.h"
 #include "DNA_action_types.h"
 #include "DNA_curve_types.h"
+#include "DNA_lamp_types.h"
 #include "DNA_armature_types.h"
 
 #include "BKE_DerivedMesh.h"
 #include "DNA_armature_types.h"
 
 #include "BKE_DerivedMesh.h"
index 625a0220830c9ff62f510fcf0334a47f022b8b7d..0fd0c85aa092bd94fdfad290e393524bec4629ae 100644 (file)
@@ -37,6 +37,7 @@ void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::m
 {
        float cur[4][4];
        float copy[4][4];
 {
        float cur[4][4];
        float copy[4][4];
+       float eul[3];
 
        unit_m4(mat);
        
 
        unit_m4(mat);