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