[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39348] branches/soc-2011-pepper/source/ blender/collada: Transform matrix Animation import fix.
Sukhitha Jayathilake
pr.jayathilake at gmail.com
Fri Aug 12 22:38:30 CEST 2011
Revision: 39348
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39348
Author: phabtar
Date: 2011-08-12 20:38:29 +0000 (Fri, 12 Aug 2011)
Log Message:
-----------
Transform matrix Animation import fix.
Modified Paths:
--------------
branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp
Modified: branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp 2011-08-12 18:29:21 UTC (rev 39347)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp 2011-08-12 20:38:29 UTC (rev 39348)
@@ -65,7 +65,6 @@
FCurve *AnimationImporter::create_fcurve(int array_index, const char *rna_path)
{
FCurve *fcu = (FCurve*)MEM_callocN(sizeof(FCurve), "FCurve");
-
fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path));
fcu->array_index = array_index;
@@ -801,20 +800,11 @@
else
strcpy(rna_path, tm_str);
newcu[i] = create_fcurve(axis, rna_path);
-
-#ifdef ARMATURE_TEST
- if (is_joint)
- job_curves[i] = create_fcurve(axis, tm_str);
-#endif
+ newcu[i]->totvert = frames.size();
}
// Object *job = NULL;
-#ifdef ARMATURE_TEST
- FCurve *job_curves[10];
- job = get_joint_object(root, node, par_job);
-#endif
-
if (frames.size() == 0)
return;
@@ -833,17 +823,11 @@
float matfra[4][4];
unit_m4(matfra);
+
+ // calc object-space mat
+ evaluate_transform_at_frame(matfra, node, fra);
- float m[4][4];
- unit_m4(m);
- dae_matrix_to_mat4(tm, m);
-
- float temp[4][4];
- copy_m4_m4(temp, mat);
-
- mul_m4_m4m4(mat, m, temp);
-
// for joints, we need a special matrix
if (is_joint) {
// special matrix: iR * M * iR_dae * R
@@ -865,8 +849,12 @@
}
float rot[4], loc[3], scale[3];
-
+
mat4_to_quat(rot, mat);
+ for ( int i = 0 ; i < 4 ; i ++ )
+ {
+ rot[i] = rot[i] * (180 / M_PI);
+ }
copy_v3_v3(loc, mat[3]);
mat4_to_size(scale, mat);
@@ -979,6 +967,7 @@
float irest_dae[4][4];
get_joint_rest_mat(irest_dae, root, node);
apply_matrix_curves_to_bone(ob, animcurves, root , node, transform ,joint_path , true , bone_name );
+ break;
}
else
add_bone_fcurve( ob, node , fcu );
@@ -990,8 +979,8 @@
if (is_rotation || is_matrix) {
if (is_joint)
{
- bPoseChannel *chan = get_pose_channel(ob->pose, bone_name);
- chan->rotmode = ROT_MODE_EUL;
+ /*bPoseChannel *chan = get_pose_channel(ob->pose, bone_name);
+ chan->rotmode = ROT_MODE_Quat;*/
}
else
{
@@ -1534,10 +1523,12 @@
float m[4][4];
unit_m4(m);
+ if ( type != COLLADAFW::Transformation::MATRIX )
+ continue;
std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
if (!evaluate_animation(tm, m, fra, nodename.c_str())) {
- switch (type) {
+ /*switch (type) {
case COLLADAFW::Transformation::ROTATE:
dae_rotate_to_mat4(tm, m);
break;
@@ -1552,7 +1543,9 @@
break;
default:
fprintf(stderr, "unsupported transformation type %d\n", type);
- }
+ }*/
+ dae_matrix_to_mat4(tm, m);
+
}
float temp[4][4];
@@ -1588,9 +1581,9 @@
bool is_scale = (type == COLLADAFW::Transformation::SCALE);
bool is_translate = (type == COLLADAFW::Transformation::TRANSLATE);
- if (type == COLLADAFW::Transformation::SCALE)
+ if (is_scale)
dae_scale_to_v3(tm, vec);
- else if (type == COLLADAFW::Transformation::TRANSLATE)
+ else if (is_translate)
dae_translate_to_v3(tm, vec);
for (unsigned int j = 0; j < bindings.getCount(); j++) {
@@ -1618,7 +1611,7 @@
if (animclass == COLLADAFW::AnimationList::UNKNOWN_CLASS) {
fprintf(stderr, "%s: UNKNOWN animation class\n", path);
- continue;
+ //continue;
}
if (type == COLLADAFW::Transformation::ROTATE) {
@@ -1858,11 +1851,12 @@
void AnimationImporter::add_bezt(FCurve *fcu, float fra, float value)
{
+ //float fps = (float)FPS;
BezTriple bez;
memset(&bez, 0, sizeof(BezTriple));
- bez.vec[1][0] = fra;
+ bez.vec[1][0] = fra ;
bez.vec[1][1] = value;
- bez.ipo = U.ipo_new; /* use default interpolation mode here... */
+ bez.ipo = BEZT_IPO_LIN ;/* use default interpolation mode here... */
bez.f1 = bez.f2 = bez.f3 = SELECT;
bez.h1 = bez.h2 = HD_AUTO;
insert_bezt_fcurve(fcu, &bez, 0);
Modified: branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp 2011-08-12 18:29:21 UTC (rev 39347)
+++ branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp 2011-08-12 20:38:29 UTC (rev 39348)
@@ -276,7 +276,8 @@
etit = uid_tags_map.find(node->getUniqueId().toAscii());
if(etit != uid_tags_map.end())
et = etit->second;
-
+ else return;
+
float x,y,z;
et->setData("tip_x",&x);
et->setData("tip_y",&y);
More information about the Bf-blender-cvs
mailing list