Introduce struct for export settings in COLLADA export code. This will make it easier to
add new options without having to change function signatures all over the place.
This commit is contained in:
parent
a1277508cc
commit
3dc0ee19c4
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -47,16 +47,15 @@
|
|||
#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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -36,12 +36,16 @@
|
|||
#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
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -29,13 +29,18 @@
|
|||
#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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -43,11 +43,13 @@
|
|||
#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
|
||||
|
|
|
@ -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"
|
|
@ -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
|
|
@ -44,16 +44,16 @@
|
|||
#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();
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -40,17 +40,19 @@
|
|||
#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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -37,14 +37,17 @@
|
|||
#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
|
||||
|
|
|
@ -33,15 +33,15 @@
|
|||
#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();
|
||||
}
|
||||
|
|
|
@ -44,16 +44,18 @@
|
|||
|
||||
#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
|
||||
|
|
|
@ -28,21 +28,21 @@
|
|||
|
||||
#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....
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue