Blender V2.61 - r43446

ArmatureExporter.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed,
00019  *                 Nathan Letwory
00020  *
00021  * ***** END GPL LICENSE BLOCK *****
00022  */
00023 
00028 #ifndef __ARMATUREEXPORTER_H__
00029 #define __ARMATUREEXPORTER_H__
00030 
00031 #include <string>
00032 //#include <vector>
00033 
00034 #include "COLLADASWStreamWriter.h"
00035 #include "COLLADASWLibraryControllers.h"
00036 #include "COLLADASWInputList.h"
00037 #include "COLLADASWNode.h"
00038 
00039 #include "DNA_armature_types.h"
00040 #include "DNA_listBase.h"
00041 #include "DNA_mesh_types.h"
00042 #include "DNA_object_types.h"
00043 #include "DNA_scene_types.h"
00044 
00045 #include "TransformWriter.h"
00046 #include "InstanceWriter.h"
00047 
00048 #include "ExportSettings.h"
00049 
00050 // XXX exporter writes wrong data for shared armatures.  A separate
00051 // controller should be written for each armature-mesh binding how do
00052 // we make controller ids then?
00053 class ArmatureExporter: public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
00054 {
00055 public:
00056     ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
00057 
00058     // write bone nodes
00059     void add_armature_bones(Object *ob_arm, Scene *sce);
00060 
00061     bool is_skinned_mesh(Object *ob);
00062 
00063     void add_instance_controller(Object *ob);
00064 
00065     void export_controllers(Scene *sce);
00066 
00067     void operator()(Object *ob);
00068 
00069 private:
00070     Scene *scene;
00071     UnitConverter converter;
00072     const ExportSettings *export_settings;
00073 
00074 #if 0
00075     std::vector<Object*> written_armatures;
00076 
00077     bool already_written(Object *ob_arm);
00078 
00079     void wrote(Object *ob_arm);
00080 
00081     void find_objects_using_armature(Object *ob_arm, std::vector<Object *>& objects, Scene *sce);
00082 #endif
00083 
00084     Object *get_assigned_armature(Object *ob);
00085 
00086     std::string get_joint_sid(Bone *bone, Object *ob_arm);
00087 
00088     // parent_mat is armature-space
00089     void add_bone_node(Bone *bone, Object *ob_arm);
00090 
00091     void add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node);
00092 
00093     void add_blender_leaf_bone(Bone *bone, Object *ob_arm, COLLADASW::Node& node);
00094 
00095     std::string get_controller_id(Object *ob_arm, Object *ob);
00096 
00097     // ob should be of type OB_MESH
00098     // both args are required
00099     void export_controller(Object* ob, Object *ob_arm);
00100 
00101     void add_joints_element(ListBase *defbase,
00102                             const std::string& joints_source_id, const std::string& inv_bind_mat_source_id);
00103 
00104     void add_bind_shape_mat(Object *ob);
00105 
00106     std::string add_joints_source(Object *ob_arm, ListBase *defbase, const std::string& controller_id);
00107 
00108     std::string add_inv_bind_mats_source(Object *ob_arm, ListBase *defbase, const std::string& controller_id);
00109 
00110     Bone *get_bone_from_defgroup(Object *ob_arm, bDeformGroup* def);
00111 
00112     bool is_bone_defgroup(Object *ob_arm, bDeformGroup* def);
00113 
00114     std::string add_weights_source(Mesh *me, const std::string& controller_id);
00115 
00116     void add_vertex_weights_element(const std::string& weights_source_id, const std::string& joints_source_id, Mesh *me,
00117                                     Object *ob_arm, ListBase *defbase);
00118 };
00119 
00120 #endif