[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39400] branches/soc-2011-pepper/source/ blender/collada: Matrix transformation animation import for other objects under the new system .
Sukhitha Jayathilake
pr.jayathilake at gmail.com
Sun Aug 14 18:14:32 CEST 2011
Revision: 39400
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39400
Author: phabtar
Date: 2011-08-14 16:14:32 +0000 (Sun, 14 Aug 2011)
Log Message:
-----------
Matrix transformation animation import for other objects under the new system.
Modified Paths:
--------------
branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h
Modified: branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp 2011-08-14 16:13:35 UTC (rev 39399)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp 2011-08-14 16:14:32 UTC (rev 39400)
@@ -90,7 +90,8 @@
COLLADAFW::FloatOrDoubleArray& input = curve->getInputValues();
COLLADAFW::FloatOrDoubleArray& output = curve->getOutputValues();
- if( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ) {
+ if( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ||
+ curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP ) {
COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues();
COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues();
}
@@ -126,7 +127,8 @@
bez.vec[1][1] = bc_get_float_value(output, j * dim + i);
- if( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER )
+ if( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ||
+ curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP)
{
COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues();
COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues();
@@ -138,7 +140,10 @@
// outtangent
bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim ) + (2 * i)) * fps;
bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim )+ (2 * i) + 1);
- bez.ipo = BEZT_IPO_BEZ;
+ if(curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER)
+ bez.ipo = BEZT_IPO_BEZ;
+ else
+ bez.ipo = BEZT_IPO_CONST;
//bez.h1 = bez.h2 = HD_AUTO;
}
else
@@ -276,11 +281,12 @@
switch (interp) {
case COLLADAFW::AnimationCurve::INTERPOLATION_LINEAR:
case COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER:
+ case COLLADAFW::AnimationCurve::INTERPOLATION_STEP:
animation_to_fcurves(curve);
break;
default:
// TODO there're also CARDINAL, HERMITE, BSPLINE and STEP types
- fprintf(stderr, "CARDINAL, HERMITE, BSPLINE and STEP anim interpolation types not supported yet.\n");
+ fprintf(stderr, "CARDINAL, HERMITE and BSPLINE anim interpolation types not supported yet.\n");
break;
}
}
@@ -749,9 +755,15 @@
}
-void AnimationImporter::apply_matrix_curves_to_bone( Object * ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root ,COLLADAFW::Node* node,
- COLLADAFW::Transformation * tm , char * joint_path, bool is_joint,const char * bone_name)
+void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root ,COLLADAFW::Node* node,
+ COLLADAFW::Transformation * tm )
{
+ bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
+ const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
+ char joint_path[200];
+ if ( is_joint )
+ armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
+
std::vector<float> frames;
find_frames(&frames, &animcurves);
@@ -878,11 +890,6 @@
add_bone_fcurve(ob, node, newcu[i]);
else
BLI_addtail(curves, newcu[i]);
-
-#ifdef ARMATURE_TEST
- if (is_joint)
- BLI_addtail(&job->adt->action->curves, job_curves[i]);
-#endif
}
if (is_joint) {
@@ -955,25 +962,22 @@
std::vector<FCurve*> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
- //calculate rnapaths and array index of fcurves according to transformation and animation class
- Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path );
-
- std::vector<FCurve*>::iterator iter;
- //Add the curves of the current animation to the object
- for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
- FCurve * fcu = *iter;
- if ((ob->type == OB_ARMATURE)){
- if ( is_matrix){
- 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
+ if ( is_matrix )
+ apply_matrix_curves(ob, animcurves, root , node, transform );
+ else {
+ //calculate rnapaths and array index of fcurves according to transformation and animation class
+ Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path );
+
+ std::vector<FCurve*>::iterator iter;
+ //Add the curves of the current animation to the object
+ for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
+ FCurve * fcu = *iter;
+ if ((ob->type == OB_ARMATURE))
add_bone_fcurve( ob, node , fcu );
- } else
- BLI_addtail(AnimCurves, fcu);
- }
+ else
+ BLI_addtail(AnimCurves, fcu);
+ }
+ }
}
}
if (is_rotation) {
@@ -1862,3 +1866,8 @@
insert_bezt_fcurve(fcu, &bez, 0);
calchandles_fcurve(fcu);
}
+
+void AnimationImporter::extra_data_importer(std::string elementName )
+{
+
+}
Modified: branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h 2011-08-14 16:13:35 UTC (rev 39399)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h 2011-08-14 16:14:32 UTC (rev 39400)
@@ -152,8 +152,8 @@
AnimMix* get_animation_type( const COLLADAFW::Node * node , std::map<COLLADAFW::UniqueId,const COLLADAFW::Object*> FW_object_map ) ;
- void apply_matrix_curves_to_bone( Object * ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root ,COLLADAFW::Node* node,
- COLLADAFW::Transformation * tm , char * joint_path, bool is_joint,const char * bone_name);
+ void apply_matrix_curves( Object * ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root ,COLLADAFW::Node* node,
+ COLLADAFW::Transformation * tm );
void Assign_transform_animations(COLLADAFW::Transformation* transform ,
const COLLADAFW::AnimationList::AnimationBinding * binding,
@@ -203,6 +203,8 @@
void add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurve *fcu);
void add_bezt(FCurve *fcu, float fra, float value);
+
+ void extra_data_importer(std::string elementName);
};
#endif
More information about the Bf-blender-cvs
mailing list