Blender  V2.93
ArmatureExporter.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #pragma once
22 
23 #include <list>
24 #include <string>
25 // #include <vector>
26 
27 #include "COLLADASWInputList.h"
28 #include "COLLADASWLibraryControllers.h"
29 #include "COLLADASWNode.h"
30 #include "COLLADASWStreamWriter.h"
31 
32 #include "DNA_armature_types.h"
33 #include "DNA_constraint_types.h"
34 #include "DNA_listBase.h"
35 #include "DNA_mesh_types.h"
36 #include "DNA_object_types.h"
37 #include "DNA_scene_types.h"
38 
39 #include "InstanceWriter.h"
40 #include "TransformWriter.h"
41 
42 #include "ExportSettings.h"
43 
44 class SceneExporter;
45 
46 /* XXX exporter writes wrong data for shared armatures. A separate
47  * controller should be written for each armature-mesh binding how do
48  * we make controller ids then? */
49 class ArmatureExporter : public COLLADASW::LibraryControllers,
50  protected TransformWriter,
51  protected InstanceWriter {
52  public:
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  ArmatureExporter(BlenderContext &blender_context,
57  COLLADASW::StreamWriter *sw,
58  BCExportSettings &export_settings)
59  : COLLADASW::LibraryControllers(sw),
60  blender_context(blender_context),
61  export_settings(export_settings)
62  {
63  }
64 
65  void add_armature_bones(Object *ob_arm,
66  ViewLayer *view_layer,
67  SceneExporter *se,
68  std::vector<Object *> &child_objects);
69 
71 
72  private:
73  BlenderContext &blender_context;
74  BCExportSettings &export_settings;
75 
76 #if 0
77  std::vector<Object *> written_armatures;
78 
79  bool already_written(Object *ob_arm);
80 
81  void wrote(Object *ob_arm);
82 
83  void find_objects_using_armature(Object *ob_arm, std::vector<Object *> &objects, Scene *sce);
84 #endif
85 
86  /* Scene, SceneExporter and the list of child_objects
87  * are required for writing bone parented objects */
88  void add_bone_node(Bone *bone,
89  Object *ob_arm,
90  SceneExporter *se,
91  std::vector<Object *> &child_objects);
92 
93  inline bool can_export(Bone *bone)
94  {
95  return !(export_settings.get_deform_bones_only() && bone->flag & BONE_NO_DEFORM);
96  }
97 
98  bool is_export_root(Bone *bone);
99  void add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node &node);
100 
101  std::string get_controller_id(Object *ob_arm, Object *ob);
102 
103  void write_bone_URLs(COLLADASW::InstanceController &ins, Object *ob_arm, Bone *bone);
104 };
@ BONE_NO_DEFORM
These structs are the foundation for all linked lists in the library system.
Object is a sort of wrapper for general info.
ArmatureExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, BCExportSettings &export_settings)
bool add_instance_controller(Object *ob)
void add_armature_bones(Object *ob_arm, ViewLayer *view_layer, SceneExporter *se, std::vector< Object * > &child_objects)
OperationNode * node