Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>2012-08-11 22:07:01 +0400
committerSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>2012-08-11 22:07:01 +0400
commit534d106cfa35e9ad05dea7b7aed76402711aa068 (patch)
tree5cd7932060e2fb96a9c3fc64983b9dc2a856edce /source/blender/collada
parent30d31089db66a7b7266dd71c1ebb7c748e58beda (diff)
[COLLADA]Morph Controller Import.
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/ArmatureImporter.cpp44
-rw-r--r--source/blender/collada/ArmatureImporter.h3
2 files changed, 44 insertions, 3 deletions
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index 79f61de3573..ad4e9b70e2b 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -649,9 +649,47 @@ bool ArmatureImporter::write_controller(const COLLADAFW::Controller *controller)
skin_by_data_uid[data_uid].set_controller(co);
}
// morph controller
- else {
- // shape keys? :)
- fprintf(stderr, "Morph controller is not supported yet.\n");
+ else if (controller->getControllerType() == COLLADAFW::Controller::CONTROLLER_TYPE_MORPH) {
+ COLLADAFW::MorphController *co = (COLLADAFW::MorphController *)controller;
+ // to be able to find geom id by controller id
+ geom_uid_by_controller_uid[skin_id] = co->getSource();
+
+ COLLADAFW::UniqueIdArray& morphTargetIds = co->getMorphTargets();
+ COLLADAFW::FloatOrDoubleArray& morphWeights = co->getMorphWeights();
+
+ //Prereq: all the geometries must be imported and mesh objects must be made
+ Object *source_ob = this->mesh_importer->get_object_by_geom_uid(co->getSource());
+ Mesh *source_me = (Mesh*) source_ob->data;
+ float *weight;
+
+ for ( int i = 0 ; i < morphTargetIds.getCount() ; i++ ){
+ //better to have a seperate map of morph objects,
+ //This'll do for now since only mesh morphing is imported
+ Object *ob = this->mesh_importer->get_object_by_geom_uid(morphTargetIds[i]);
+ if(ob){
+ Mesh *me = (Mesh*)ob->data;
+ Key *key = ob_get_key(source_ob);
+ KeyBlock *kb;
+ int newkey = 0;
+
+ if (key == NULL) {
+ key = source_me->key = add_key((ID *)me);
+ key->type = KEY_RELATIVE;
+ newkey = 1;
+ }
+
+ kb = add_keyblock_ctime(key, morphTargetIds[i].toAscii().c_str(), FALSE);
+ mesh_to_key(me, kb);
+ weight = morphWeights.getFloatValues()[i].getData();
+ kb->curval = *weight;
+
+ //free object since it is added as shape key
+ BKE_object_free(ob);
+ }
+ else
+ fprintf(stderr, "Morph target geometry not found.\n");
+ }
+// fprintf(stderr, "Morph controller is not supported yet.\n");
}
return true;
diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h
index 5ac363bf2e8..f6f2f53d18b 100644
--- a/source/blender/collada/ArmatureImporter.h
+++ b/source/blender/collada/ArmatureImporter.h
@@ -29,13 +29,16 @@
#include "COLLADAFWNode.h"
#include "COLLADAFWUniqueId.h"
+#include "COLLADAFWMorphController.h"
extern "C" {
#include "BKE_context.h"
+#include "BKE_key.h"
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_key_types.h"
#include "ED_armature.h"
}