Blender V4.3
collada.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9/* COLLADABU_ASSERT, may be able to remove later */
10#include "COLLADABUPlatform.h"
11
12#include "DocumentExporter.h"
13#include "DocumentImporter.h"
14#include "ExportSettings.h"
15#include "ImportSettings.h"
16#include "collada.h"
17
18#include "BKE_context.hh"
19#include "BKE_scene.hh"
20#include "DEG_depsgraph.hh"
22
23/* make dummy file */
24#include "BLI_fileops.h"
25#include "BLI_linklist.h"
26
27extern "C" {
28
29static void print_import_header(ImportSettings &import_settings)
30{
31 fprintf(stderr, "+-- Collada Import parameters------\n");
32 fprintf(stderr, "| input file : %s\n", import_settings.filepath);
33 fprintf(stderr, "| use units : %s\n", (import_settings.import_units) ? "yes" : "no");
34 fprintf(stderr, "| custom normals : %s\n", (import_settings.custom_normals) ? "yes" : "no");
35 fprintf(stderr, "| autoconnect : %s\n", (import_settings.auto_connect) ? "yes" : "no");
36 fprintf(stderr, "+-- Armature Import parameters ----\n");
37 fprintf(stderr, "| find bone chains: %s\n", (import_settings.find_chains) ? "yes" : "no");
38 fprintf(stderr, "| min chain len : %d\n", import_settings.min_chain_length);
39 fprintf(stderr, "| fix orientation : %s\n", (import_settings.fix_orientation) ? "yes" : "no");
40 fprintf(stderr, "| keep bind info : %s\n", (import_settings.keep_bind_info) ? "yes" : "no");
41}
42
43static void print_import_footer(int status)
44{
45 fprintf(stderr, "+----------------------------------\n");
46 fprintf(stderr, "| Collada Import : %s\n", (status) ? "OK" : "FAIL");
47 fprintf(stderr, "+----------------------------------\n");
48}
49
50int collada_import(bContext *C, ImportSettings *import_settings)
51{
52 print_import_header(*import_settings);
53 DocumentImporter imp(C, import_settings);
54 int status = imp.import() ? 1 : 0;
55 print_import_footer(status);
56
57 return status;
58}
59
60int collada_export(bContext *C, ExportSettings *export_settings)
61{
62 BlenderContext blender_context(C);
63 const Scene *scene = blender_context.get_scene();
64 ViewLayer *view_layer = blender_context.get_view_layer();
65
66 int includeFilter = OB_REL_NONE;
67 if (export_settings->include_armatures) {
68 includeFilter |= OB_REL_MOD_ARMATURE;
69 }
70 if (export_settings->include_children) {
71 includeFilter |= OB_REL_CHILDREN_RECURSIVE;
72 }
73
74 /* Fetch the complete set of exported objects
75 * ATTENTION: Invisible objects will not be exported
76 */
77 eObjectSet objectSet = (export_settings->selected) ? OB_SET_SELECTED : OB_SET_ALL;
79 scene, view_layer, objectSet, (eObRelationTypes)includeFilter);
80
81 int export_count = BLI_linklist_count(export_settings->export_set);
82
83 if (export_count == 0) {
84 if (export_settings->selected) {
85 fprintf(stderr,
86 "Collada: Found no objects to export.\nPlease ensure that all objects which shall "
87 "be exported are also visible in the 3D Viewport.\n");
88 }
89 else {
90 fprintf(stderr, "Collada: Your scene seems to be empty. No Objects will be exported.\n");
91 }
92 }
93 else {
94 if (export_settings->sort_by_name) {
96 }
97 }
98
99 DocumentExporter exporter(blender_context, export_settings);
100 int status = exporter.exportCurrentScene();
101
102 BLI_linklist_free(export_settings->export_set, nullptr);
103
104 return (status) ? -1 : export_count;
105}
106
107/* end extern C */
108}
eObRelationTypes
@ OB_REL_MOD_ARMATURE
@ OB_REL_CHILDREN_RECURSIVE
@ OB_REL_NONE
LinkNode * BKE_object_relational_superset(const Scene *scene, ViewLayer *view_layer, eObjectSet objectSet, eObRelationTypes includeFilter)
eObjectSet
@ OB_SET_SELECTED
@ OB_SET_ALL
File and directory operations.
int collada_import(bContext *C, ImportSettings *import_settings)
Definition collada.cpp:50
static void print_import_footer(int status)
Definition collada.cpp:43
static void print_import_header(ImportSettings &import_settings)
Definition collada.cpp:29
int collada_export(bContext *C, ExportSettings *export_settings)
Definition collada.cpp:60
void bc_bubble_sort_by_Object_name(LinkNode *export_set)
LinkNode * export_set