[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38161] branches/soc-2011-pepper/source/ blender/collada: camera lens (COLLADA xfov ) animation export
Sukhitha Jayathilake
pr.jayathilake at gmail.com
Wed Jul 6 19:41:15 CEST 2011
Revision: 38161
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38161
Author: phabtar
Date: 2011-07-06 17:41:14 +0000 (Wed, 06 Jul 2011)
Log Message:
-----------
camera lens (COLLADA xfov ) animation export
Modified Paths:
--------------
branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp
branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h
branches/soc-2011-pepper/source/blender/collada/CameraExporter.cpp
Modified: branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp 2011-07-06 17:10:38 UTC (rev 38160)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp 2011-07-06 17:41:14 UTC (rev 38161)
@@ -56,18 +56,50 @@
void AnimationExporter::operator() (Object *ob)
{
FCurve *fcu;
+ char * transformName ;
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;
+ {
+ fcu = (FCurve*)ob->adt->action->curves.first;
+ while (fcu) {
+ transformName = extract_transform_name( fcu->rna_path );
+
+ 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);
+ fcu = fcu->next;
+ }
+ }
+ if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action )
+ {
+ fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first);
+ while (fcu) {
+ transformName = extract_transform_name( fcu->rna_path );
+
+ if ((!strcmp(transformName, "color")) ||
+ (!strcmp(transformName, "spot_size"))||
+ (!strcmp(transformName, "spot_blend")))
+ dae_animation(ob ,fcu, transformName,true );
+ fcu = fcu->next;
+ }
+ }
+
+ if( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action )
+ {
+ fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first);
+ while (fcu) {
+ transformName = extract_transform_name( fcu->rna_path );
+
+ if ((!strcmp(transformName, "lens")))
+ dae_animation(ob ,fcu, transformName,true );
+ 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
// fcu = (FCurve*)ob->adt->action->curves.first;
- char * transformName = extract_transform_name( fcu->rna_path );
-
-
+
//if (ob->type == OB_ARMATURE) {
// if (!ob->data) return;
// bArmature *arm = (bArmature*)ob->data;
@@ -82,21 +114,7 @@
// }
//}
//else {
- while (fcu) {
- transformName = extract_transform_name( fcu->rna_path );
-
- if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) ||
- (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)||
- (!strcmp(transformName, "rotation_quaternion")) ||
- (!strcmp(transformName, "color")) ||
- (!strcmp(transformName, "spot_size"))||
- (!strcmp(transformName, "spot_blend")))
- dae_animation(ob ,fcu, transformName );
-
-
- fcu = fcu->next;
- }
- //}
+
}
float * AnimationExporter::get_eul_source_for_quat(Object *ob )
@@ -150,7 +168,7 @@
return id_name(ob);
}
- void AnimationExporter::dae_animation(Object* ob, FCurve *fcu/*, std::string ob_name*/ , char* transformName )
+ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu/*, std::string ob_name*/ , char* transformName , bool is_param )
{
const char *axis_name = NULL;
@@ -166,7 +184,9 @@
if (fcu->array_index < 4)
axis_name = axis_names[fcu->array_index];*/
}
- else if ( !strcmp(transformName, "spot_size")||!strcmp(transformName, "spot_blend") )
+ else if ( !strcmp(transformName, "spot_size")||
+ !strcmp(transformName, "spot_blend")||
+ !strcmp(transformName, "lens"))
{
axis_name = "";
}
@@ -252,13 +272,19 @@
std::string target ;
- if ( ob->type == OB_LAMP )
- target = get_light_id(ob)
+ if ( !is_param )
+ target = translate_id(ob_name)
+ "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true);
else
- target = translate_id(ob_name)
- + "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true);
+ {
+ if ( ob->type == OB_LAMP )
+ target = get_light_id(ob)
+ + "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true);
+ if ( ob->type == OB_CAMERA )
+ target = get_camera_id(ob)
+ + "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true);
+ }
addChannel(COLLADABU::URI(empty, sampler_id), target);
closeAnimation();
@@ -569,9 +595,9 @@
std::string source_id = anim_id + get_semantic_suffix(semantic);
//bool is_rotation = !strcmp(fcu->rna_path, "rotation");
- bool is_rotation = false;
+ bool is_angle = false;
- if (strstr(fcu->rna_path, "rotation")) is_rotation = true;
+ if (strstr(fcu->rna_path, "rotation")||strstr(fcu->rna_path, "lens")) is_angle = true;
COLLADASW::FloatSourceF source(mSW);
source.setId(source_id);
@@ -591,14 +617,14 @@
COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
- add_source_parameters(param, semantic, is_rotation, axis_name);
+ add_source_parameters(param, semantic, is_angle, axis_name);
source.prepareToAppendValues();
for (unsigned int i = 0; i < fcu->totvert; i++) {
float values[3]; // be careful!
int length = 0;
- get_source_values(&fcu->bezt[i], semantic, is_rotation, values, &length);
+ get_source_values(&fcu->bezt[i], semantic, is_angle, values, &length);
for (int j = 0; j < length; j++)
source.appendValues(values[j]);
}
@@ -777,6 +803,8 @@
tm_type = 5;
else if (!strcmp(name, "spot_blend"))
tm_type = 6;
+ else if (!strcmp(name, "lens"))
+ tm_type = 7;
else
tm_type = -1;
}
@@ -802,6 +830,10 @@
case 6:
tm_name = "fall_off_exponent";
break;
+ case 7:
+ tm_name = "xfov";
+ break;
+
default:
tm_name = "";
break;
@@ -890,10 +922,10 @@
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 if( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action )
+ fcu = (FCurve*)(((Camera*)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 ( fcu) return true;
base= base->next;
}
return false;
Modified: branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h 2011-07-06 17:10:38 UTC (rev 38160)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h 2011-07-06 17:41:14 UTC (rev 38161)
@@ -33,6 +33,7 @@
#include "DNA_action_types.h"
#include "DNA_curve_types.h"
#include "DNA_lamp_types.h"
+#include "DNA_camera_types.h"
#include "DNA_armature_types.h"
#include "BKE_DerivedMesh.h"
@@ -90,7 +91,7 @@
protected:
- void dae_animation(Object* ob, FCurve *fcu, char* transformName);
+ void dae_animation(Object* ob, FCurve *fcu, char* transformName , bool is_param);
void write_bone_animation(Object *ob_arm, Bone *bone);
Modified: branches/soc-2011-pepper/source/blender/collada/CameraExporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/CameraExporter.cpp 2011-07-06 17:10:38 UTC (rev 38160)
+++ branches/soc-2011-pepper/source/blender/collada/CameraExporter.cpp 2011-07-06 17:41:14 UTC (rev 38161)
@@ -73,7 +73,7 @@
if (cam->type == CAM_PERSP) {
COLLADASW::PerspectiveOptic persp(mSW);
- persp.setXFov(lens_to_angle(cam->lens)*(180.0f/M_PI));
+ persp.setXFov(lens_to_angle(cam->lens)*(180.0f/M_PI),"XFov");
persp.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch),false,cam_name);
persp.setZFar(cam->clipend);
persp.setZNear(cam->clipsta);
@@ -82,7 +82,7 @@
}
else {
COLLADASW::OrthographicOptic ortho(mSW);
- ortho.setXMag(cam->ortho_scale);
+ ortho.setXMag(cam->ortho_scale,"XMag");
ortho.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch));
ortho.setZFar(cam->clipend);
ortho.setZNear(cam->clipsta);
More information about the Bf-blender-cvs
mailing list