Blender  V3.3
ControllerExporter.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #pragma once
8 
9 #include <list>
10 #include <string>
11 //#include <vector>
12 
13 #include "COLLADASWExtraTechnique.h"
14 #include "COLLADASWInputList.h"
15 #include "COLLADASWInstanceController.h"
16 #include "COLLADASWLibraryControllers.h"
17 #include "COLLADASWNode.h"
18 #include "COLLADASWStreamWriter.h"
19 
20 #include "DNA_armature_types.h"
21 #include "DNA_constraint_types.h"
22 #include "DNA_key_types.h"
23 #include "DNA_listBase.h"
24 #include "DNA_mesh_types.h"
25 #include "DNA_object_types.h"
26 #include "DNA_scene_types.h"
27 
28 #include "InstanceWriter.h"
29 #include "TransformWriter.h"
30 
31 #include "ExportSettings.h"
32 
33 #include "BKE_key.h"
34 
35 class SceneExporter;
36 
37 class ControllerExporter : public COLLADASW::LibraryControllers,
38  protected TransformWriter,
39  protected InstanceWriter {
40  private:
41  BlenderContext &blender_context;
42  BCExportSettings export_settings;
43 
44  public:
45  /* XXX exporter writes wrong data for shared armatures. A separate
46  * controller should be written for each armature-mesh binding how do
47  * we make controller ids then? */
48  ControllerExporter(BlenderContext &blender_context,
49  COLLADASW::StreamWriter *sw,
50  BCExportSettings &export_settings)
51  : COLLADASW::LibraryControllers(sw),
52  blender_context(blender_context),
53  export_settings(export_settings)
54  {
55  }
56 
57  bool is_skinned_mesh(Object *ob);
58 
60 
61  void export_controllers();
62 
63  void operator()(Object *ob);
64 
65  private:
66 #if 0
67  std::vector<Object *> written_armatures;
68 
69  bool already_written(Object *ob_arm);
70 
71  void wrote(Object *ob_arm);
72 
73  void find_objects_using_armature(Object *ob_arm, std::vector<Object *> &objects, Scene *sce);
74 #endif
75 
76  std::string get_controller_id(Object *ob_arm, Object *ob);
77 
78  std::string get_controller_id(Key *key, Object *ob);
79 
81  void export_skin_controller(Object *ob, Object *ob_arm);
82 
83  void export_morph_controller(Object *ob, Key *key);
84 
85  void add_joints_element(const ListBase *defbase,
86  const std::string &joints_source_id,
87  const std::string &inv_bind_mat_source_id);
88 
89  void add_bind_shape_mat(Object *ob);
90 
91  std::string add_morph_targets(Key *key, Object *ob);
92 
93  std::string add_morph_weights(Key *key, Object *ob);
94 
98  void add_weight_extras(Key *key);
99 
100  std::string add_joints_source(Object *ob_arm,
101  const ListBase *defbase,
102  const std::string &controller_id);
103 
104  std::string add_inv_bind_mats_source(Object *ob_arm,
105  const ListBase *defbase,
106  const std::string &controller_id);
107 
108  Bone *get_bone_from_defgroup(Object *ob_arm, const bDeformGroup *def);
109 
110  bool is_bone_defgroup(Object *ob_arm, const bDeformGroup *def);
111 
112  std::string add_weights_source(Mesh *me,
113  const std::string &controller_id,
114  const std::list<float> &weights);
115 
116  void add_vertex_weights_element(const std::string &weights_source_id,
117  const std::string &joints_source_id,
118  const std::list<int> &vcount,
119  const std::list<int> &joints);
120 
121  void write_bone_URLs(COLLADASW::InstanceController &ins, Object *ob_arm, Bone *bone);
122 };
These structs are the foundation for all linked lists in the library system.
Object is a sort of wrapper for general info.
ControllerExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, BCExportSettings &export_settings)
bool add_instance_controller(Object *ob)
void operator()(Object *ob)
bool is_skinned_mesh(Object *ob)
ccl_gpu_kernel_postfix ccl_global float int int int sw