2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
* Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed,
21
* ***** END GPL LICENSE BLOCK *****
24
/** \file ArmatureExporter.h
28
#ifndef __ARMATUREEXPORTER_H__
29
#define __ARMATUREEXPORTER_H__
35
#include "COLLADASWStreamWriter.h"
36
#include "COLLADASWLibraryControllers.h"
37
#include "COLLADASWInputList.h"
38
#include "COLLADASWNode.h"
40
#include "DNA_armature_types.h"
41
#include "DNA_listBase.h"
42
#include "DNA_mesh_types.h"
43
#include "DNA_object_types.h"
44
#include "DNA_scene_types.h"
46
#include "TransformWriter.h"
47
#include "InstanceWriter.h"
49
#include "ExportSettings.h"
53
// XXX exporter writes wrong data for shared armatures. A separate
54
// controller should be written for each armature-mesh binding how do
55
// we make controller ids then?
56
class ArmatureExporter: public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
59
ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
62
void add_armature_bones(Object *ob_arm, Scene* sce, SceneExporter* se,
63
std::list<Object*>& child_objects);
65
bool is_skinned_mesh(Object *ob);
67
void add_instance_controller(Object *ob);
69
void export_controllers(Scene *sce);
71
void operator()(Object *ob);
75
UnitConverter converter;
76
const ExportSettings *export_settings;
79
std::vector<Object*> written_armatures;
81
bool already_written(Object *ob_arm);
83
void wrote(Object *ob_arm);
85
void find_objects_using_armature(Object *ob_arm, std::vector<Object *>& objects, Scene *sce);
88
Object *get_assigned_armature(Object *ob);
90
std::string get_joint_sid(Bone *bone, Object *ob_arm);
92
// Scene, SceneExporter and the list of child_objects
93
// are required for writing bone parented objects
94
void add_bone_node(Bone *bone, Object *ob_arm, Scene* sce, SceneExporter* se,
95
std::list<Object*>& child_objects);
97
void add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node);
99
void add_blender_leaf_bone(Bone *bone, Object *ob_arm, COLLADASW::Node& node);
101
std::string get_controller_id(Object *ob_arm, Object *ob);
103
// ob should be of type OB_MESH
104
// both args are required
105
void export_controller(Object* ob, Object *ob_arm);
107
void add_joints_element(ListBase *defbase,
108
const std::string& joints_source_id, const std::string& inv_bind_mat_source_id);
110
void add_bind_shape_mat(Object *ob);
112
std::string add_joints_source(Object *ob_arm, ListBase *defbase, const std::string& controller_id);
114
std::string add_inv_bind_mats_source(Object *ob_arm, ListBase *defbase, const std::string& controller_id);
116
Bone *get_bone_from_defgroup(Object *ob_arm, bDeformGroup* def);
118
bool is_bone_defgroup(Object *ob_arm, bDeformGroup* def);
120
std::string add_weights_source(Mesh *me, const std::string& controller_id,
121
const std::list<float>& weights);
123
void add_vertex_weights_element(const std::string& weights_source_id, const std::string& joints_source_id,
124
const std::list<int>& vcount, const std::list<int>& joints);