Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>2011-07-17 22:51:03 +0400
committerSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>2011-07-17 22:51:03 +0400
commit44326c9fe976127b6a63862ea538dfd28cce5404 (patch)
treec51a6f25415738370a9cce51a8e2e1c0b8491dec /source/blender/collada/AnimationExporter.cpp
parentb96d3fd70aa2a967a3096742c7823c129221511e (diff)
Material Animation export. (on going)
Diffstat (limited to 'source/blender/collada/AnimationExporter.cpp')
-rw-r--r--source/blender/collada/AnimationExporter.cpp57
1 files changed, 37 insertions, 20 deletions
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 81dae097315..5b7853f8af7 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -58,6 +58,7 @@ void AnimationExporter::exportAnimations(Scene *sce)
{
FCurve *fcu;
char * transformName ;
+ bool isMatAnim = false;
if(ob->adt && ob->adt->action)
{
fcu = (FCurve*)ob->adt->action->curves.first;
@@ -67,7 +68,7 @@ void AnimationExporter::exportAnimations(Scene *sce)
if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) ||
(!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)||
(!strcmp(transformName, "rotation_quaternion")))
- dae_animation(ob ,fcu, transformName, false);
+ dae_animation(ob ,fcu, transformName, false , isMatAnim);
fcu = fcu->next;
}
}
@@ -80,7 +81,7 @@ void AnimationExporter::exportAnimations(Scene *sce)
if ((!strcmp(transformName, "color")) ||
(!strcmp(transformName, "spot_size"))||
(!strcmp(transformName, "spot_blend")))
- dae_animation(ob ,fcu, transformName,true );
+ dae_animation(ob , fcu, transformName, true, isMatAnim );
fcu = fcu->next;
}
}
@@ -94,10 +95,28 @@ void AnimationExporter::exportAnimations(Scene *sce)
if ((!strcmp(transformName, "lens"))||
(!strcmp(transformName, "ortho_scale"))||
(!strcmp(transformName, "clipend"))||(!strcmp(transformName, "clipsta")))
- dae_animation(ob ,fcu, transformName,true );
+ dae_animation(ob , fcu, transformName, true, isMatAnim );
fcu = fcu->next;
}
}
+
+ for(int a = 0; a < ob->totcol; a++)
+ {
+ Material *ma = give_current_material(ob, a+1);
+ if (!ma) continue;
+ if(ma->adt && ma->adt->action)
+ {
+ isMatAnim = true;
+ fcu = (FCurve*)ma->adt->action->curves.first;
+ while (fcu) {
+ transformName = extract_transform_name( fcu->rna_path );
+
+ if ((!strcmp(transformName, "specular_hardness")))
+ dae_animation(ob ,fcu, transformName, true, isMatAnim );
+ fcu = fcu->next;
+ }
+ }
+ }
//if (!ob->adt || !ob->adt->action)
// fcu = (FCurve*)((Lamp*)ob->data)->adt->action->curves.first; //this is already checked in hasAnimations()
//else
@@ -132,18 +151,15 @@ void AnimationExporter::exportAnimations(Scene *sce)
{
char * transformName = extract_transform_name( fcu->rna_path );
- if( !strcmp(transformName, "rotation_quaternion") )
- {
- for ( int i = 0 ; i < fcu->totvert ; i++)
- {
+ if( !strcmp(transformName, "rotation_quaternion") ) {
+ for ( int i = 0 ; i < fcu->totvert ; i++){
*(quat + ( i * 4 ) + fcu->array_index) = fcu->bezt[i].vec[1][1];
}
}
fcu = fcu->next;
}
- for ( int i = 0 ; i < fcu->totvert ; i++)
- {
+ for ( int i = 0 ; i < fcu->totvert ; i++){
for ( int j = 0;j<4;j++)
temp_quat[j] = quat[(i*4)+j];
@@ -171,7 +187,7 @@ void AnimationExporter::exportAnimations(Scene *sce)
return id_name(ob);
}
- void AnimationExporter::dae_animation(Object* ob, FCurve *fcu/*, std::string ob_name*/ , char* transformName , bool is_param )
+ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformName , bool is_param, bool isMatAnim )
{
const char *axis_name = NULL;
@@ -188,24 +204,23 @@ void AnimationExporter::exportAnimations(Scene *sce)
axis_name = axis_names[fcu->array_index];*/
}
//maybe a list or a vector of float animations
- else if ( !strcmp(transformName, "spot_size")||!strcmp(transformName, "spot_blend")||
- !strcmp(transformName, "lens")||!strcmp(transformName, "ortho_scale")||!strcmp(transformName, "clipend")||
- !strcmp(transformName, "clipsta"))
- {
- axis_name = "";
- }
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
+ else if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) ||
+ (!strcmp(transformName, "rotation_euler")))
{
const char *axis_names[] = {"X", "Y", "Z"};
if (fcu->array_index < 3)
axis_name = axis_names[fcu->array_index];
}
+ else{
+ axis_name = "";
+ }
+
std::string ob_name = std::string("null");
if (ob->type == OB_ARMATURE)
{
@@ -215,9 +230,11 @@ void AnimationExporter::exportAnimations(Scene *sce)
}
else
{
- ob_name = id_name(ob);
- BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(),
- fcu->rna_path, axis_name);
+ if (isMatAnim)
+ ob_name = id_name(ob) + "_material";
+ else
+ BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(),
+ fcu->rna_path, axis_name);
}
// check rna_path is one of: rotation, scale, location