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