Introduce struct for export settings in COLLADA export code. This will make it easier to
authorNathan Letwory <nathan@letworyinteractive.com>
Wed, 7 Sep 2011 18:23:30 +0000 (18:23 +0000)
committerNathan Letwory <nathan@letworyinteractive.com>
Wed, 7 Sep 2011 18:23:30 +0000 (18:23 +0000)
add new options without having to change function signatures all over the place.

22 files changed:
source/blender/collada/ArmatureExporter.cpp
source/blender/collada/ArmatureExporter.h
source/blender/collada/CMakeLists.txt
source/blender/collada/CameraExporter.cpp
source/blender/collada/CameraExporter.h
source/blender/collada/DocumentExporter.cpp
source/blender/collada/DocumentExporter.h
source/blender/collada/EffectExporter.cpp
source/blender/collada/EffectExporter.h
source/blender/collada/ExportSettings.cpp [new file with mode: 0644]
source/blender/collada/ExportSettings.h [new file with mode: 0644]
source/blender/collada/GeometryExporter.cpp
source/blender/collada/GeometryExporter.h
source/blender/collada/ImageExporter.cpp
source/blender/collada/ImageExporter.h
source/blender/collada/LightExporter.cpp
source/blender/collada/LightExporter.h
source/blender/collada/MaterialExporter.cpp
source/blender/collada/MaterialExporter.h
source/blender/collada/SceneExporter.cpp
source/blender/collada/SceneExporter.h
source/blender/collada/collada.cpp

index de01c0003731511aa6aa9d3fa5ae768a1a33f4bd..431c67833f157eeb259afcbac676b2917c73bb1f 100644 (file)
@@ -49,7 +49,7 @@
 // XXX exporter writes wrong data for shared armatures.  A separate
 // controller should be written for each armature-mesh binding how do
 // we make controller ids then?
-ArmatureExporter::ArmatureExporter(COLLADASW::StreamWriter *sw) : COLLADASW::LibraryControllers(sw) {}
+ArmatureExporter::ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryControllers(sw), export_settings(export_settings) {}
 
 // write bone nodes
 void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene *sce)
@@ -90,14 +90,14 @@ void ArmatureExporter::add_instance_controller(Object *ob)
        ins.add();
 }
 
-void ArmatureExporter::export_controllers(Scene *sce, bool export_selected)
+void ArmatureExporter::export_controllers(Scene *sce)
 {
        scene = sce;
 
        openLibrary();
 
        GeometryFunctor gf;
-       gf.forEachMeshObjectInScene<ArmatureExporter>(sce, *this, export_selected);
+       gf.forEachMeshObjectInScene<ArmatureExporter>(sce, *this, this->export_settings->selected);
 
        closeLibrary();
 }
index b3441c797e8e9ec5f349c58e1812a772012885c8..554a8a7cfe675036e7ea6aafef3ec1f6544aaee5 100644 (file)
 #include "TransformWriter.h"
 #include "InstanceWriter.h"
 
+#include "ExportSettings.h"
+
 // XXX exporter writes wrong data for shared armatures.  A separate
 // controller should be written for each armature-mesh binding how do
 // we make controller ids then?
 class ArmatureExporter: public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
 {
-private:
-       Scene *scene;
-
 public:
-       ArmatureExporter(COLLADASW::StreamWriter *sw);
+       ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
 
        // write bone nodes
        void add_armature_bones(Object *ob_arm, Scene *sce);
@@ -65,13 +64,14 @@ public:
 
        void add_instance_controller(Object *ob);
 
-       void export_controllers(Scene *sce, bool export_selected);
+       void export_controllers(Scene *sce);
 
        void operator()(Object *ob);
 
 private:
-
+       Scene *scene;
        UnitConverter converter;
+       const ExportSettings *export_settings;
 
 #if 0
        std::vector<Object*> written_armatures;
@@ -119,25 +119,4 @@ private:
                                                                        Object *ob_arm, ListBase *defbase);
 };
 
-/*
-struct GeometryFunctor {
-       // f should have
-       // void operator()(Object* ob)
-       template<class Functor>
-       void forEachMeshObjectInScene(Scene *sce, Functor &f)
-       {
-               
-               Base *base= (Base*) sce->base.first;
-               while(base) {
-                       Object *ob = base->object;
-                       
-                       if (ob->type == OB_MESH && ob->data) {
-                               f(ob);
-                       }
-                       base= base->next;
-                       
-               }
-       }
-};*/
-
 #endif
index cc7229383e36cc495adb0401f87110d130d793c1..2ee34091fc9d5e621951b3a1e43cafc39f175679 100644 (file)
@@ -52,6 +52,7 @@ set(SRC
        DocumentImporter.cpp
        EffectExporter.cpp
        ErrorHandler.cpp
+       ExportSettings.cpp
        ExtraHandler.cpp
        ExtraTags.cpp
        GeometryExporter.cpp
@@ -77,6 +78,7 @@ set(SRC
        DocumentImporter.h
        EffectExporter.h
        ErrorHandler.h
+       ExportSettings.h
        ExtraHandler.h
        ExtraTags.h
        GeometryExporter.h
index a935f45c4031b0da32971ed98d3143bcf5f41320..542409072f15fa9e39409c2f804c42f90b28b335 100644 (file)
@@ -39,7 +39,7 @@
 
 #include "collada_internal.h"
 
-CamerasExporter::CamerasExporter(COLLADASW::StreamWriter *sw): COLLADASW::LibraryCameras(sw){}
+CamerasExporter::CamerasExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): COLLADASW::LibraryCameras(sw), export_settings(export_settings) {}
 
 template<class Functor>
 void forEachCameraObjectInScene(Scene *sce, Functor &f, bool export_selected)
@@ -56,11 +56,11 @@ void forEachCameraObjectInScene(Scene *sce, Functor &f, bool export_selected)
        }
 }
 
-void CamerasExporter::exportCameras(Scene *sce, bool export_selected)
+void CamerasExporter::exportCameras(Scene *sce)
 {
        openLibrary();
        
-       forEachCameraObjectInScene(sce, *this, export_selected);
+       forEachCameraObjectInScene(sce, *this, this->export_settings->selected);
        
        closeLibrary();
 }
index 999a6ddd3e5aab2593e64e5a34a43ae49f708fe0..8d08fe23f8009f1adffed65cbe3259aa0a9bc39d 100644 (file)
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
+#include "ExportSettings.h"
+
 class CamerasExporter: COLLADASW::LibraryCameras
 {
 public:
-       CamerasExporter(COLLADASW::StreamWriter *sw);
-       void exportCameras(Scene *sce, bool export_selected);
+       CamerasExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
+       void exportCameras(Scene *sce);
        void operator()(Object *ob, Scene *sce);
+private:
+       const ExportSettings *export_settings;
 };
 
 #endif
index 85f37d29f22ef5de1d9d3c3a25ea2d98ff9d4ac6..d562e51b9226e1f72b4b35cd5f68a0798219c66f 100644 (file)
@@ -110,6 +110,7 @@ extern char build_rev[];
 
 #include "collada_internal.h"
 #include "DocumentExporter.h"
+#include "ExportSettings.h"
 
 // can probably go after refactor is complete
 #include "InstanceWriter.h"
@@ -145,11 +146,13 @@ char *bc_CustomData_get_active_layer_name(const CustomData *data, int type)
        return data->layers[layer_index].name;
 }
 
+DocumentExporter::DocumentExporter(const ExportSettings *export_settings) : export_settings(export_settings) {}
+
 // TODO: it would be better to instantiate animations rather than create a new one per object
 // COLLADA allows this through multiple <channel>s in <animation>.
 // For this to work, we need to know objects that use a certain action.
 
-void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename, bool selected)
+void DocumentExporter::exportCurrentScene(Scene *sce)
 {
        PointerRNA sceneptr, unit_settings;
        PropertyRNA *system; /* unused , *scale; */
@@ -157,7 +160,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename, bool
        clear_global_id_map();
        
        COLLADABU::NativeString native_filename =
-               COLLADABU::NativeString(std::string(filename));
+               COLLADABU::NativeString(std::string(this->export_settings->filepath));
        COLLADASW::StreamWriter sw(native_filename);
 
        // open <collada>
@@ -227,32 +230,32 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename, bool
        
        // <library_cameras>
        if(has_object_type(sce, OB_CAMERA)) {
-               CamerasExporter ce(&sw);
-               ce.exportCameras(sce, selected);
+               CamerasExporter ce(&sw, this->export_settings);
+               ce.exportCameras(sce);
        }
        
        // <library_lights>
        if(has_object_type(sce, OB_LAMP)) {
-               LightsExporter le(&sw);
-               le.exportLights(sce, selected);
+               LightsExporter le(&sw, this->export_settings);
+               le.exportLights(sce);
        }
 
        // <library_images>
-       ImagesExporter ie(&sw, filename);
-       ie.exportImages(sce, selected);
+       ImagesExporter ie(&sw, this->export_settings);
+       ie.exportImages(sce);
        
        // <library_effects>
-       EffectsExporter ee(&sw);
-       ee.exportEffects(sce, selected);
+       EffectsExporter ee(&sw, this->export_settings);
+       ee.exportEffects(sce);
        
        // <library_materials>
-       MaterialsExporter me(&sw);
-       me.exportMaterials(sce, selected);
+       MaterialsExporter me(&sw, this->export_settings);
+       me.exportMaterials(sce);
 
        // <library_geometries>
        if(has_object_type(sce, OB_MESH)) {
-               GeometryExporter ge(&sw);
-               ge.exportGeom(sce, selected);
+               GeometryExporter ge(&sw, this->export_settings);
+               ge.exportGeom(sce);
        }
 
        // <library_animations>
@@ -260,14 +263,14 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename, bool
        ae.exportAnimations(sce);
 
        // <library_controllers>
-       ArmatureExporter arm_exporter(&sw);
+       ArmatureExporter arm_exporter(&sw, this->export_settings);
        if(has_object_type(sce, OB_ARMATURE)) {
-               arm_exporter.export_controllers(sce, selected);
+               arm_exporter.export_controllers(sce);
        }
 
        // <library_visual_scenes>
-       SceneExporter se(&sw, &arm_exporter);
-       se.exportScene(sce, selected);
+       SceneExporter se(&sw, &arm_exporter, this->export_settings);
+       se.exportScene(sce);
        
        // <scene>
        std::string scene_name(translate_id(id_name(sce)));
index 923313c4ed9c841edb93d9770a24a9466bd0de6e..83724505efa71d0c7af98f4858ce57f5f8edea9a 100644 (file)
 #ifndef __DOCUMENTEXPORTER_H__
 #define __DOCUMENTEXPORTER_H__
 
+#include "ExportSettings.h"
+
 struct Scene;
 
 class DocumentExporter
 {
  public:
-       void exportCurrentScene(Scene *sce, const char* filename, bool selected);
+       DocumentExporter(const ExportSettings *export_settings);
+       void exportCurrentScene(Scene *sce);
        void exportScenes(const char* filename);
+private:
+       const ExportSettings *export_settings;
 };
 
 #endif
index 355e384d0004a78fd0c892ba0317556be84a6c93..ed37dada195a6d2a870b5ef87e271de71783743f 100644 (file)
@@ -55,7 +55,7 @@ static std::string getActiveUVLayerName(Object *ob)
        return "";
 }
 
-EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw) : COLLADASW::LibraryEffects(sw){}
+EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryEffects(sw), export_settings(export_settings) {}
 
 bool EffectsExporter::hasEffects(Scene *sce)
 {
@@ -78,12 +78,12 @@ bool EffectsExporter::hasEffects(Scene *sce)
        return false;
 }
 
-void EffectsExporter::exportEffects(Scene *sce, bool export_selected)
+void EffectsExporter::exportEffects(Scene *sce)
 {
        if(hasEffects(sce)) {
                openLibrary();
                MaterialFunctor mf;
-               mf.forEachMaterialInScene<EffectsExporter>(sce, *this, export_selected);
+               mf.forEachMaterialInScene<EffectsExporter>(sce, *this, this->export_settings->selected);
 
                closeLibrary();
        }
index 86143ae4d07759dc2361ebe8452c43dc318c6de2..dc1f4c4474b054c30f20b085cf7a2a4a4146384b 100644 (file)
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
+#include "ExportSettings.h"
+
 class EffectsExporter: COLLADASW::LibraryEffects
 {
 public:
-       EffectsExporter(COLLADASW::StreamWriter *sw);
-       void exportEffects(Scene *sce, bool export_selected);
+       EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
+       void exportEffects(Scene *sce);
 
        void operator()(Material *ma, Object *ob);
        
@@ -66,6 +68,8 @@ private:
        void writePhong(COLLADASW::EffectProfile &ep, Material *ma);
        
        bool hasEffects(Scene *sce);
+       
+       const ExportSettings *export_settings;
 };
 
 #endif
diff --git a/source/blender/collada/ExportSettings.cpp b/source/blender/collada/ExportSettings.cpp
new file mode 100644 (file)
index 0000000..19f1c05
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/collada/ExportSettings.cpp
+ *  \ingroup collada
+ */
+
+#include "ExportSettings.h"
diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h
new file mode 100644 (file)
index 0000000..2636ca8
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ExportSettings.h
+ *  \ingroup collada
+ */
+
+#ifndef __EXPORTSETTINGS_H__
+#define __EXPORTSETTINGS_H__
+
+struct ExportSettings
+{
+ public:
+ bool selected;
+ char *filepath;
+};
+
+#endif
index b724844b1ec6f4536c50e9396fc994d811cc82c8..4da0a4c6e1fc7b8a672798efa181a5f2c56ae54c 100644 (file)
 #include "collada_internal.h"
 
 // TODO: optimize UV sets by making indexed list with duplicates removed
-GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw) : COLLADASW::LibraryGeometries(sw) {}
+GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryGeometries(sw), export_settings(export_settings) {}
 
 
-void GeometryExporter::exportGeom(Scene *sce, bool export_selected)
+void GeometryExporter::exportGeom(Scene *sce)
 {
        openLibrary();
 
        mScene = sce;
        GeometryFunctor gf;
-       gf.forEachMeshObjectInScene<GeometryExporter>(sce, *this, export_selected);
+       gf.forEachMeshObjectInScene<GeometryExporter>(sce, *this, this->export_settings->selected);
 
        closeLibrary();
 }
index d9d265a66fceb705186c801b20567d1db0c393ad..64c51b6324ee85296e0be635ff2472a6fc1e640d 100644 (file)
@@ -42,6 +42,8 @@
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
+#include "ExportSettings.h"
+
 // TODO: optimize UV sets by making indexed list with duplicates removed
 class GeometryExporter : COLLADASW::LibraryGeometries
 {
@@ -58,9 +60,9 @@ class GeometryExporter : COLLADASW::LibraryGeometries
        Scene *mScene;
 
 public:
-       GeometryExporter(COLLADASW::StreamWriter *sw);
+       GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
 
-       void exportGeom(Scene *sce, bool export_selected);
+       void exportGeom(Scene *sce);
 
        void operator()(Object *ob);
 
@@ -96,6 +98,8 @@ public:
        /* int getTriCount(MFace *faces, int totface);*/
 private:
        std::set<std::string> exportedGeometry;
+       
+       const ExportSettings *export_settings;
 };
 
 struct GeometryFunctor {
index 8e426e9dba86cfaf9efc6c35e23fe5112ad63f35..747f3c783d70bd09d0e321379b1a95a64338cfd9 100644 (file)
@@ -43,7 +43,7 @@
 #include "BLI_path_util.h"
 #include "BLI_string.h"
 
-ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, const char* filename) : COLLADASW::LibraryImages(sw), mfilename(filename)
+ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryImages(sw), export_settings(export_settings)
 {}
 
 bool ImagesExporter::hasImages(Scene *sce)
@@ -71,12 +71,12 @@ bool ImagesExporter::hasImages(Scene *sce)
        return false;
 }
 
-void ImagesExporter::exportImages(Scene *sce, bool export_selected)
+void ImagesExporter::exportImages(Scene *sce)
 {
        if(hasImages(sce)) {
                openLibrary();
                MaterialFunctor mf;
-               mf.forEachMaterialInScene<ImagesExporter>(sce, *this, export_selected);
+               mf.forEachMaterialInScene<ImagesExporter>(sce, *this, this->export_settings->selected);
 
                closeLibrary();
        }
@@ -97,7 +97,7 @@ void ImagesExporter::operator()(Material *ma, Object *ob)
                        char src[FILE_MAX];
                        char dir[FILE_MAX];
                        
-                       BLI_split_dirfile(mfilename, dir, NULL);
+                       BLI_split_dirfile(this->export_settings->filepath, dir, NULL);
 
                        BKE_rebase_path(abs, sizeof(abs), rel, sizeof(rel), G.main->name, image->name, dir);
 
index 6b81c099259bc9ecba588d5b6746da670d74246a..9e5767fd9d383ea3d083f3d19444d805099deb95 100644 (file)
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
+#include "ExportSettings.h"
+
 class ImagesExporter: COLLADASW::LibraryImages
 {
-       const char *mfilename;
-       std::vector<std::string> mImages; // contains list of written images, to avoid duplicates
 public:
-       ImagesExporter(COLLADASW::StreamWriter *sw, const char* filename);
+       ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
        
-       void exportImages(Scene *sce, bool export_selected);
+       void exportImages(Scene *sce);
        void operator()(Material *ma, Object *ob);
 private:
+       std::vector<std::string> mImages; // contains list of written images, to avoid duplicates
        bool hasImages(Scene *sce);
+       const ExportSettings *export_settings;
 };
 
 #endif
index 31ade5604a703ef459c22f74d44925c1ddb6a63f..3d5814cb6dbb12c203feb2b5f1028a5c47443e9d 100644 (file)
@@ -52,13 +52,13 @@ void forEachLampObjectInScene(Scene *sce, Functor &f, bool export_selected)
        }
 }
 
-LightsExporter::LightsExporter(COLLADASW::StreamWriter *sw): COLLADASW::LibraryLights(sw){}
+LightsExporter::LightsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): COLLADASW::LibraryLights(sw), export_settings(export_settings) {}
 
-void LightsExporter::exportLights(Scene *sce, bool export_selected)
+void LightsExporter::exportLights(Scene *sce)
 {
        openLibrary();
        
-       forEachLampObjectInScene(sce, *this, export_selected);
+       forEachLampObjectInScene(sce, *this, this->export_settings->selected);
        
        closeLibrary();
 }
index 2ae1a19fdb183e7e639d86225a68483749bb32d7..6c52ed2b76d00fba43d64b06df7a73c81bb8f2c6 100644 (file)
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
+#include "ExportSettings.h"
+
 class LightsExporter: COLLADASW::LibraryLights
 {
 public:
-       LightsExporter(COLLADASW::StreamWriter *sw);
-       void exportLights(Scene *sce, bool export_selected);
+       LightsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
+       void exportLights(Scene *sce);
        void operator()(Object *ob);
 private:
        bool exportBlenderProfile(COLLADASW::Light &cla, Lamp *la);
+       const ExportSettings *export_settings;
 };
 
 #endif
index 9d29177578dbedc9290aa9a598ee807426807a30..37c1a6f6b68ef043a03585f86aeb977eb747ee03 100644 (file)
 #include "COLLADABUUtils.h"
 #include "collada_internal.h"
 
-MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw): COLLADASW::LibraryMaterials(sw){}
+MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): COLLADASW::LibraryMaterials(sw), export_settings(export_settings) {}
 
-void MaterialsExporter::exportMaterials(Scene *sce, bool export_selected)
+void MaterialsExporter::exportMaterials(Scene *sce)
 {
        if(hasMaterials(sce)) {
                openLibrary();
 
                MaterialFunctor mf;
-               mf.forEachMaterialInScene<MaterialsExporter>(sce, *this, export_selected);
+               mf.forEachMaterialInScene<MaterialsExporter>(sce, *this, this->export_settings->selected);
 
                closeLibrary();
        }
index c080e4b05965fed78c68eb5b44a30053ec020bba..97a1e27358f38c660c81653ccbc4e087d0342062 100644 (file)
 
 #include "GeometryExporter.h"
 #include "collada_internal.h"
+#include "ExportSettings.h"
 
 class MaterialsExporter: COLLADASW::LibraryMaterials
 {
 public:
-       MaterialsExporter(COLLADASW::StreamWriter *sw);
-       void exportMaterials(Scene *sce, bool export_selected);
+       MaterialsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
+       void exportMaterials(Scene *sce);
        void operator()(Material *ma, Object *ob);
 
 private:
        bool hasMaterials(Scene *sce);
+       const ExportSettings *export_settings;
 };
 
 // used in forEachMaterialInScene
index 96f20ac21c3a8dbc40f6e09f9af60e81a0ccea72..5109df0bb6a4989ffca69246549212a7f144a06f 100644 (file)
 
 #include "SceneExporter.h"
 
-SceneExporter::SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm)
-       : COLLADASW::LibraryVisualScenes(sw), arm_exporter(arm)
+SceneExporter::SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings)
+       : COLLADASW::LibraryVisualScenes(sw), arm_exporter(arm), export_settings(export_settings)
 {}
        
-void SceneExporter::exportScene(Scene *sce, bool export_selected)
+void SceneExporter::exportScene(Scene *sce)
 {
        // <library_visual_scenes> <visual_scene>
        std::string id_naming = id_name(sce);
        openVisualScene(translate_id(id_naming), id_naming);
-       exportHierarchy(sce, export_selected);
+       exportHierarchy(sce);
        closeVisualScene();
        closeLibrary();
 }
 
-void SceneExporter::exportHierarchy(Scene *sce, bool export_selected)
+void SceneExporter::exportHierarchy(Scene *sce)
 {
        Base *base= (Base*) sce->base.first;
        while(base) {
@@ -56,7 +56,7 @@ void SceneExporter::exportHierarchy(Scene *sce, bool export_selected)
                                        case OB_LAMP:
                                        case OB_ARMATURE:
                                        case OB_EMPTY:
-                                               if (export_selected && !(ob->flag & SELECT)) {
+                                               if (this->export_settings->selected && !(ob->flag & SELECT)) {
                                                        break;
                                                }
                                                // write nodes....
index 65dbd616b204a7af7b8252141a1458a2d2993926..919cba61ec049d309600ddb08e006f0529489927 100644 (file)
@@ -90,16 +90,20 @@ extern "C" {
 
 #include "ArmatureExporter.h"
 
+#include "ExportSettings.h"
+
 class SceneExporter: COLLADASW::LibraryVisualScenes, protected TransformWriter, protected InstanceWriter
 {
-       ArmatureExporter *arm_exporter;
 public:
-       SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm);
-       void exportScene(Scene *sce, bool export_selected);
+       SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings);
+       void exportScene(Scene *sce);
 
 private:
-       void exportHierarchy(Scene *sce, bool export_selected);
+       void exportHierarchy(Scene *sce);
        void writeNodes(Object *ob, Scene *sce);
+       
+       ArmatureExporter *arm_exporter;
+       const ExportSettings *export_settings;
 };
 
 #endif
index 4caca20531f9073f2af4c481bbcdbe77a5476eb4..8059b1cf3ffa126084d48dff83ad7413fc2f58d8 100644 (file)
@@ -30,6 +30,7 @@
 /* COLLADABU_ASSERT, may be able to remove later */
 #include "COLLADABUPlatform.h"
 
+#include "ExportSettings.h"
 #include "DocumentExporter.h"
 #include "DocumentImporter.h"
 
@@ -53,7 +54,10 @@ extern "C"
 
        int collada_export(Scene *sce, const char *filepath, int selected)
        {
-               DocumentExporter exp;
+               ExportSettings export_settings;
+               
+               export_settings.selected = selected != 0;
+               export_settings.filepath = (char *)filepath;
 
                /* annoying, collada crashes if file cant be created! [#27162] */
                if(!BLI_exist(filepath)) {
@@ -64,7 +68,8 @@ extern "C"
                }
                /* end! */
 
-               exp.exportCurrentScene(sce, filepath, selected);
+               DocumentExporter exporter(&export_settings);
+               exporter.exportCurrentScene(sce);
 
                return 1;
        }