COLLADA branch: bone anim export works. Export-import roundtrip is possible.

Importer now takes mesh bind position into account.

TODO: read/write object-level anim on armatures and fix memleaks.
This commit is contained in:
2010-01-05 16:07:10 +00:00
parent 18eb6d9827
commit 06d548bd6f
2 changed files with 455 additions and 266 deletions

View File

@@ -43,6 +43,8 @@ extern "C"
#include "ED_armature.h"
#include "ED_mesh.h" // ED_vgroup_vert_add, ...
#include "ED_anim_api.h"
#include "ED_object.h"
#include "WM_types.h"
#include "WM_api.h"
@@ -82,6 +84,7 @@ extern "C"
#include "DNA_mesh_types.h"
#include "DNA_material_types.h"
#include "DNA_scene_types.h"
#include "DNA_modifier_types.h"
#include "MEM_guardedalloc.h"
@@ -497,20 +500,24 @@ private:
void link_armature(bContext *C, Object *ob, std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& joint_by_uid,
TransformReader *tm)
{
Object workob;
Scene *scene = CTX_data_scene(C);
ModifierData *md = ED_object_modifier_add(NULL, scene, ob, NULL, eModifierType_Armature);
((ArmatureModifierData *)md)->object = ob_arm;
tm->decompose(bind_shape_matrix, ob->loc, ob->rot, NULL, ob->size);
ob->parent = ob_arm;
ob->partype = PARSKEL;
ob->partype = PAROBJECT;
what_does_parent(scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA;
((bArmature*)ob_arm->data)->deformflag = ARM_DEF_VGROUP;
// we need armature matrix here... where do we get it from I wonder...
// root node/joint? or node with <instance_controller>?
float parmat[4][4];
unit_m4(parmat);
invert_m4_m4(ob->parentinv, parmat);
// create all vertex groups
std::vector<JointData>::iterator it;
int joint_index;
@@ -551,7 +558,7 @@ private:
}
}
DAG_scene_sort(CTX_data_scene(C));
DAG_scene_sort(scene);
DAG_ids_flush_update(0);
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
}