[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37553] branches/soc-2011-pepper/source/ blender/collada: AnimationExporter - Quaternion to euler conversion ( in progress )
Sukhitha Jayathilake
pr.jayathilake at gmail.com
Thu Jun 16 17:04:37 CEST 2011
Revision: 37553
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37553
Author: phabtar
Date: 2011-06-16 15:04:37 +0000 (Thu, 16 Jun 2011)
Log Message:
-----------
AnimationExporter - Quaternion to euler conversion ( in progress )
AnimationImporter
- Action group assignment to bones
- Revert to conversion of angles from deg to rad.
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/AnimationImporter.cpp
branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp
Modified: branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp 2011-06-16 15:01:22 UTC (rev 37552)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp 2011-06-16 15:04:37 UTC (rev 37553)
@@ -86,35 +86,43 @@
//}
}
- /*float * AnimationExporter::get_eul_source_for_quat(Object *ob )
+ float * AnimationExporter::get_eul_source_for_quat(Object *ob )
{
FCurve *fcu = (FCurve*)ob->adt->action->curves.first;
- const int keys = fcu->totvert;
- float quat[keys][4];
- float eul[keys][3];
+ const int keys = fcu->totvert;
+ float *quat = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 4, "quat output source values");
+ float *eul = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values");
+ float temp_quat[4];
+ float temp_eul[3];
while(fcu)
{
- transformName = extract_transform_name( fcu->rna_path );
+ char * transformName = extract_transform_name( fcu->rna_path );
if( !strcmp(transformName, "rotation_quaternion") )
{
- for ( int i = 0 ; i < fcu->totvert ; i+=)
+ for ( int i = 0 ; i < fcu->totvert ; i++)
{
- quat[i][fcu->array_index] = fcu->bezt[i].vec[1][1];
+ *(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++)
{
- quat_to_eul(eul[i],quat[i]);
+ for ( int j = 0;j<4;j++)
+ temp_quat[j] = quat[(i*4)+j];
+
+ quat_to_eul(temp_eul,temp_quat);
+
+ for (int k = 0;k<3;k++)
+ eul[i*3 + k] = temp_eul[k];
+
}
return eul;
- }*/
+ }
std::string AnimationExporter::getObjectBoneName( Object* ob,const FCurve* fcu )
{
//hard-way to derive the bone name from rna_path. Must find more compact method
@@ -134,15 +142,16 @@
const char *axis_name = NULL;
char anim_id[200];
+
bool has_tangents = false;
bool quatRotation = false;
if ( !strcmp(transformName, "rotation_quaternion") )
{
- //quatRotation = true;
- const char *axis_names[] = {"", "X", "Y", "Z"};
+ quatRotation = true;
+ /*const char *axis_names[] = {"", "X", "Y", "Z"};
if (fcu->array_index < 4)
- axis_name = axis_names[fcu->array_index];
+ axis_name = axis_names[fcu->array_index];*/
}
else
@@ -173,7 +182,19 @@
std::string input_id = create_source_from_fcurve(COLLADASW::InputSemantic::INPUT, fcu, anim_id, axis_name);
// create output source
- std::string output_id = create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name);
+ std::string output_id ;
+
+ /*if(quatRotation)
+ {
+ float * eul = get_eul_source_for_quat(ob);
+ float * eul_axis =
+ for ( int i = 0 ; i< fcu->totvert ; i++)
+ eul_axis[i] = eul[i*3 + fcu->array_index];
+ output_id= create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis , fcu->totvert, quatRotation, anim_id, axis_name);
+ }
+ else*/
+
+ output_id= create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name);
// create interpolations source
std::string interpolation_id = create_interpolation_source(fcu, anim_id, axis_name, &has_tangents);
Modified: branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h 2011-06-16 15:01:22 UTC (rev 37552)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h 2011-06-16 15:04:37 UTC (rev 37553)
@@ -112,10 +112,8 @@
void get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool rotation, float *values, int *length);
- /*float * get_eul_source_for_quat(Object *ob );*/
+ float * get_eul_source_for_quat(Object *ob );
- /*std::string create_source_from_array(COLLADASW::InputSemantic::Semantics semantic, float *v, int tot, const std::string& anim_id, int array_index);*/
-
std::string create_source_from_fcurve(COLLADASW::InputSemantic::Semantics semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name);
std::string create_source_from_array(COLLADASW::InputSemantic::Semantics semantic, float *v, int tot, bool is_rot, const std::string& anim_id, const char *axis_name);
Modified: branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp 2011-06-16 15:01:22 UTC (rev 37552)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp 2011-06-16 15:04:37 UTC (rev 37553)
@@ -170,8 +170,8 @@
for (unsigned int i = 0; i < cu->totvert; i++) {
// TODO convert handles too
cu->bezt[i].vec[1][1] *= M_PI / 180.0f;
- /*cu->bezt[i].vec[0][1] *= M_PI / 180.0f;
- cu->bezt[i].vec[2][1] *= M_PI / 180.0f;*/
+ cu->bezt[i].vec[0][1] *= M_PI / 180.0f;
+ cu->bezt[i].vec[2][1] *= M_PI / 180.0f;
cu->bezt[i].vec[1][0];
}
}
@@ -677,8 +677,8 @@
FCurve* fcu = *iter;
//if transform is rotation the fcurves values must be turned in to radian.
- /*if (is_rotation)
- fcurve_deg_to_rad(fcu); */
+ if (is_rotation)
+ fcurve_deg_to_rad(fcu);
}
COLLADAFW::Rotate* rot = (COLLADAFW::Rotate*)transform;
COLLADABU::Math::Vector3& axis = rot->getRotationAxis();
@@ -735,6 +735,7 @@
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
bAction * act;
+ bActionGroup *grp = NULL;
if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID*)&ob->id, 1);
else act = ob->adt->action;
@@ -765,8 +766,7 @@
copy_m4_m4(rest, bone->arm_mat);
invert_m4_m4(irest, rest);
}
-
-
+
const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations();
//for each transformation in node
@@ -803,7 +803,10 @@
//Add the curves of the current animation to the object
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve * fcu = *iter;
- BLI_addtail(AnimCurves, fcu);
+ if (ob->type == OB_ARMATURE)
+ add_bone_fcurve( ob, node , fcu );
+ else
+ BLI_addtail(AnimCurves, fcu);
}
}
std::sort(frames.begin(), frames.end());
@@ -812,7 +815,7 @@
if (is_joint)
{
bPoseChannel *chan = get_pose_channel(ob->pose, bone_name);
- chan->rotmode = ROT_MODE_QUAT;
+ chan->rotmode = ROT_MODE_EUL;
}
else
{
Modified: branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp 2011-06-16 15:01:22 UTC (rev 37552)
+++ branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp 2011-06-16 15:04:37 UTC (rev 37553)
@@ -256,7 +256,7 @@
COLLADAFW::NodePointerArray &children = node->getChildNodes();
for (i = 0; i < children.getCount(); i++) {
- translate_anim_recursive(children[i], node, ob);
+ translate_anim_recursive(children[i], node, NULL);
}
}
More information about the Bf-blender-cvs
mailing list