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 17 /** \file 18 * \ingroup collada 19 */ 20 21 #pragma once 22 23 #include "BLI_linklist.h" 24 #include "BlenderContext.h" 25 26 #ifdef __cplusplus 27 # include "BCMath.h" 28 # include <vector> 29 30 extern "C" { 31 #endif 32 33 typedef enum BC_export_mesh_type { 34 BC_MESH_TYPE_VIEW, 35 BC_MESH_TYPE_RENDER, 36 } BC_export_mesh_type; 37 38 typedef enum BC_export_transformation_type { 39 BC_TRANSFORMATION_TYPE_MATRIX, 40 BC_TRANSFORMATION_TYPE_DECOMPOSED, 41 } BC_export_transformation_type; 42 43 typedef enum BC_export_animation_type { 44 BC_ANIMATION_EXPORT_SAMPLES, 45 BC_ANIMATION_EXPORT_KEYS, 46 } BC_export_animation_type; 47 48 typedef enum BC_ui_export_section { 49 BC_UI_SECTION_MAIN, 50 BC_UI_SECTION_GEOMETRY, 51 BC_UI_SECTION_ARMATURE, 52 BC_UI_SECTION_ANIMATION, 53 BC_UI_SECTION_COLLADA, 54 } BC_ui_export_section; 55 56 typedef struct ExportSettings { 57 bool apply_modifiers; 58 BC_global_forward_axis global_forward; 59 BC_global_up_axis global_up; 60 bool apply_global_orientation; 61 62 BC_export_mesh_type export_mesh_type; 63 64 bool selected; 65 bool include_children; 66 bool include_armatures; 67 bool include_shapekeys; 68 bool deform_bones_only; 69 bool include_animations; 70 bool include_all_actions; 71 int sampling_rate; 72 bool keep_smooth_curves; 73 bool keep_keyframes; 74 bool keep_flat_curves; 75 76 bool active_uv_only; 77 BC_export_animation_type export_animation_type; 78 bool use_texture_copies; 79 80 bool triangulate; 81 bool use_object_instantiation; 82 bool use_blender_profile; 83 bool sort_by_name; 84 BC_export_transformation_type object_transformation_type; 85 BC_export_transformation_type animation_transformation_type; 86 87 bool open_sim; 88 bool limit_precision; 89 bool keep_bind_info; 90 91 char *filepath; 92 LinkNode *export_set; 93 } ExportSettings; 94 95 #ifdef __cplusplus 96 } 97 98 void bc_get_children(std::vector<Object *> &child_set, Object *ob, ViewLayer *view_layer); 99 100 class BCExportSettings { 101 102 private: 103 const ExportSettings &export_settings; 104 BlenderContext &blender_context; 105 const BCMatrix global_transform; 106 107 public: BCExportSettings(ExportSettings * exportSettings,BlenderContext & blenderContext)108 BCExportSettings(ExportSettings *exportSettings, BlenderContext &blenderContext) 109 : export_settings(*exportSettings), 110 blender_context(blenderContext), 111 global_transform(BCMatrix(exportSettings->global_forward, exportSettings->global_up)) 112 113 { 114 } 115 get_global_transform()116 const BCMatrix &get_global_transform() 117 { 118 return global_transform; 119 } 120 get_apply_modifiers()121 bool get_apply_modifiers() 122 { 123 return export_settings.apply_modifiers; 124 } 125 get_global_forward()126 BC_global_forward_axis get_global_forward() 127 { 128 return export_settings.global_forward; 129 } 130 get_global_up()131 BC_global_up_axis get_global_up() 132 { 133 return export_settings.global_up; 134 } 135 get_apply_global_orientation()136 bool get_apply_global_orientation() 137 { 138 return export_settings.apply_global_orientation; 139 } 140 get_export_mesh_type()141 BC_export_mesh_type get_export_mesh_type() 142 { 143 return export_settings.export_mesh_type; 144 } 145 get_selected()146 bool get_selected() 147 { 148 return export_settings.selected; 149 } 150 get_include_children()151 bool get_include_children() 152 { 153 return export_settings.include_children; 154 } 155 get_include_armatures()156 bool get_include_armatures() 157 { 158 return export_settings.include_armatures; 159 } 160 get_include_shapekeys()161 bool get_include_shapekeys() 162 { 163 return export_settings.include_shapekeys; 164 } 165 get_deform_bones_only()166 bool get_deform_bones_only() 167 { 168 return export_settings.deform_bones_only; 169 } 170 get_include_animations()171 bool get_include_animations() 172 { 173 return export_settings.include_animations; 174 } 175 get_include_all_actions()176 bool get_include_all_actions() 177 { 178 return export_settings.include_all_actions; 179 } 180 get_sampling_rate()181 int get_sampling_rate() 182 { 183 return export_settings.sampling_rate; 184 } 185 get_keep_smooth_curves()186 bool get_keep_smooth_curves() 187 { 188 return export_settings.keep_smooth_curves; 189 } 190 get_keep_keyframes()191 bool get_keep_keyframes() 192 { 193 return export_settings.keep_keyframes; 194 } 195 get_keep_flat_curves()196 bool get_keep_flat_curves() 197 { 198 return export_settings.keep_flat_curves; 199 } 200 get_active_uv_only()201 bool get_active_uv_only() 202 { 203 return export_settings.active_uv_only; 204 } 205 get_export_animation_type()206 BC_export_animation_type get_export_animation_type() 207 { 208 return export_settings.export_animation_type; 209 } 210 get_use_texture_copies()211 bool get_use_texture_copies() 212 { 213 return export_settings.use_texture_copies; 214 } 215 get_triangulate()216 bool get_triangulate() 217 { 218 return export_settings.triangulate; 219 } 220 get_use_object_instantiation()221 bool get_use_object_instantiation() 222 { 223 return export_settings.use_object_instantiation; 224 } 225 get_use_blender_profile()226 bool get_use_blender_profile() 227 { 228 return export_settings.use_blender_profile; 229 } 230 get_sort_by_name()231 bool get_sort_by_name() 232 { 233 return export_settings.sort_by_name; 234 } 235 get_object_transformation_type()236 BC_export_transformation_type get_object_transformation_type() 237 { 238 return export_settings.object_transformation_type; 239 } 240 get_animation_transformation_type()241 BC_export_transformation_type get_animation_transformation_type() 242 { 243 return export_settings.animation_transformation_type; 244 } 245 get_open_sim()246 bool get_open_sim() 247 { 248 return export_settings.open_sim; 249 } 250 get_limit_precision()251 bool get_limit_precision() 252 { 253 return export_settings.limit_precision; 254 } 255 get_keep_bind_info()256 bool get_keep_bind_info() 257 { 258 return export_settings.keep_bind_info; 259 } 260 get_filepath()261 char *get_filepath() 262 { 263 return export_settings.filepath; 264 } 265 get_export_set()266 LinkNode *get_export_set() 267 { 268 return export_settings.export_set; 269 } 270 get_blender_context()271 BlenderContext &get_blender_context() 272 { 273 return blender_context; 274 } 275 get_scene()276 Scene *get_scene() 277 { 278 return blender_context.get_scene(); 279 } 280 get_view_layer()281 ViewLayer *get_view_layer() 282 { 283 return blender_context.get_view_layer(); 284 } 285 is_export_root(Object * ob)286 bool is_export_root(Object *ob) 287 { 288 return bc_is_base_node(get_export_set(), ob, get_view_layer()); 289 } 290 }; 291 292 #endif 293