diff options
author | Juha Mäki-Kanto <ih5235252@gmail.com> | 2012-02-18 20:55:41 +0400 |
---|---|---|
committer | Juha Mäki-Kanto <ih5235252@gmail.com> | 2012-02-18 20:55:41 +0400 |
commit | f75bf20c817d9e09b23513d007bc8cc69ff00d48 (patch) | |
tree | 7fc3a9ea0327a0ab22c9a65d3d77d2f8cf0e095d /source/blender/collada/SceneExporter.cpp | |
parent | 7beddb750610982ebccfd64d87759baa91e011a5 (diff) |
Fix rest of #27022, collada export: add bone parenting of objects
- SceneExporter collects a list of child-objects for armature-object and passes it onto ArmatureExporter
- SceneExporter's writeNodes is then called from ArmatureExporter for matching child-objects for bone.
- ArmatureExporter removes written child-objects from list, objects not exported as being bone parented are exported as direct children of the armature-node.
- Should play nice with current Second Life-compatibility.
A nicer implementation would require some design changes, will have to wait.
Diffstat (limited to 'source/blender/collada/SceneExporter.cpp')
-rw-r--r-- | source/blender/collada/SceneExporter.cpp | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp index 5dd452faa41..b6be8a57f7a 100644 --- a/source/blender/collada/SceneExporter.cpp +++ b/source/blender/collada/SceneExporter.cpp @@ -77,6 +77,29 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) node.start(); bool is_skinned_mesh = arm_exporter->is_skinned_mesh(ob); + std::list<Object*> child_objects; + + // list child objects + Base *b = (Base*) sce->base.first; + while(b) { + // cob - child object + Object *cob = b->object; + + if (cob->parent == ob) { + switch(cob->type) { + case OB_MESH: + case OB_CAMERA: + case OB_LAMP: + case OB_EMPTY: + case OB_ARMATURE: + child_objects.push_back(cob); + break; + } + } + + b = b->next; + } + if (ob->type == OB_MESH && is_skinned_mesh) // for skinned mesh we write obmat in <bind_shape_matrix> @@ -101,7 +124,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) // <instance_controller> else if (ob->type == OB_ARMATURE) { - arm_exporter->add_armature_bones(ob, sce); + arm_exporter->add_armature_bones(ob, sce, this, child_objects); // XXX this looks unstable... node.end(); @@ -131,28 +154,12 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) } } - // write nodes for child objects - Base *b = (Base*) sce->base.first; - while(b) { - // cob - child object - Object *cob = b->object; - - if (cob->parent == ob) { - switch(cob->type) { - case OB_MESH: - case OB_CAMERA: - case OB_LAMP: - case OB_EMPTY: - case OB_ARMATURE: - // write node... - writeNodes(cob, sce); - break; - } - } - - b = b->next; + for(std::list<Object*>::iterator i= child_objects.begin(); i != child_objects.end(); ++i) + { + writeNodes(*i, sce); } + if (ob->type != OB_ARMATURE) node.end(); } |