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:
@@ -49,7 +49,7 @@
|
|||||||
// XXX exporter writes wrong data for shared armatures. A separate
|
// XXX exporter writes wrong data for shared armatures. A separate
|
||||||
// controller should be written for each armature-mesh binding how do
|
// controller should be written for each armature-mesh binding how do
|
||||||
// we make controller ids then?
|
// 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
|
// write bone nodes
|
||||||
void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene *sce)
|
void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene *sce)
|
||||||
@@ -90,14 +90,14 @@ void ArmatureExporter::add_instance_controller(Object *ob)
|
|||||||
ins.add();
|
ins.add();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArmatureExporter::export_controllers(Scene *sce, bool export_selected)
|
void ArmatureExporter::export_controllers(Scene *sce)
|
||||||
{
|
{
|
||||||
scene = sce;
|
scene = sce;
|
||||||
|
|
||||||
openLibrary();
|
openLibrary();
|
||||||
|
|
||||||
GeometryFunctor gf;
|
GeometryFunctor gf;
|
||||||
gf.forEachMeshObjectInScene<ArmatureExporter>(sce, *this, export_selected);
|
gf.forEachMeshObjectInScene<ArmatureExporter>(sce, *this, this->export_settings->selected);
|
||||||
|
|
||||||
closeLibrary();
|
closeLibrary();
|
||||||
}
|
}
|
||||||
|
@@ -47,16 +47,15 @@
|
|||||||
#include "TransformWriter.h"
|
#include "TransformWriter.h"
|
||||||
#include "InstanceWriter.h"
|
#include "InstanceWriter.h"
|
||||||
|
|
||||||
|
#include "ExportSettings.h"
|
||||||
|
|
||||||
// XXX exporter writes wrong data for shared armatures. A separate
|
// XXX exporter writes wrong data for shared armatures. A separate
|
||||||
// controller should be written for each armature-mesh binding how do
|
// controller should be written for each armature-mesh binding how do
|
||||||
// we make controller ids then?
|
// we make controller ids then?
|
||||||
class ArmatureExporter: public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
|
class ArmatureExporter: public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
Scene *scene;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ArmatureExporter(COLLADASW::StreamWriter *sw);
|
ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
|
||||||
|
|
||||||
// write bone nodes
|
// write bone nodes
|
||||||
void add_armature_bones(Object *ob_arm, Scene *sce);
|
void add_armature_bones(Object *ob_arm, Scene *sce);
|
||||||
@@ -65,13 +64,14 @@ public:
|
|||||||
|
|
||||||
void add_instance_controller(Object *ob);
|
void add_instance_controller(Object *ob);
|
||||||
|
|
||||||
void export_controllers(Scene *sce, bool export_selected);
|
void export_controllers(Scene *sce);
|
||||||
|
|
||||||
void operator()(Object *ob);
|
void operator()(Object *ob);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Scene *scene;
|
||||||
UnitConverter converter;
|
UnitConverter converter;
|
||||||
|
const ExportSettings *export_settings;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
std::vector<Object*> written_armatures;
|
std::vector<Object*> written_armatures;
|
||||||
@@ -119,25 +119,4 @@ private:
|
|||||||
Object *ob_arm, ListBase *defbase);
|
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
|
#endif
|
||||||
|
@@ -52,6 +52,7 @@ set(SRC
|
|||||||
DocumentImporter.cpp
|
DocumentImporter.cpp
|
||||||
EffectExporter.cpp
|
EffectExporter.cpp
|
||||||
ErrorHandler.cpp
|
ErrorHandler.cpp
|
||||||
|
ExportSettings.cpp
|
||||||
ExtraHandler.cpp
|
ExtraHandler.cpp
|
||||||
ExtraTags.cpp
|
ExtraTags.cpp
|
||||||
GeometryExporter.cpp
|
GeometryExporter.cpp
|
||||||
@@ -77,6 +78,7 @@ set(SRC
|
|||||||
DocumentImporter.h
|
DocumentImporter.h
|
||||||
EffectExporter.h
|
EffectExporter.h
|
||||||
ErrorHandler.h
|
ErrorHandler.h
|
||||||
|
ExportSettings.h
|
||||||
ExtraHandler.h
|
ExtraHandler.h
|
||||||
ExtraTags.h
|
ExtraTags.h
|
||||||
GeometryExporter.h
|
GeometryExporter.h
|
||||||
|
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
#include "collada_internal.h"
|
#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>
|
template<class Functor>
|
||||||
void forEachCameraObjectInScene(Scene *sce, Functor &f, bool export_selected)
|
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();
|
openLibrary();
|
||||||
|
|
||||||
forEachCameraObjectInScene(sce, *this, export_selected);
|
forEachCameraObjectInScene(sce, *this, this->export_settings->selected);
|
||||||
|
|
||||||
closeLibrary();
|
closeLibrary();
|
||||||
}
|
}
|
||||||
|
@@ -36,12 +36,16 @@
|
|||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
|
|
||||||
|
#include "ExportSettings.h"
|
||||||
|
|
||||||
class CamerasExporter: COLLADASW::LibraryCameras
|
class CamerasExporter: COLLADASW::LibraryCameras
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CamerasExporter(COLLADASW::StreamWriter *sw);
|
CamerasExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
|
||||||
void exportCameras(Scene *sce, bool export_selected);
|
void exportCameras(Scene *sce);
|
||||||
void operator()(Object *ob, Scene *sce);
|
void operator()(Object *ob, Scene *sce);
|
||||||
|
private:
|
||||||
|
const ExportSettings *export_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -110,6 +110,7 @@ extern char build_rev[];
|
|||||||
|
|
||||||
#include "collada_internal.h"
|
#include "collada_internal.h"
|
||||||
#include "DocumentExporter.h"
|
#include "DocumentExporter.h"
|
||||||
|
#include "ExportSettings.h"
|
||||||
|
|
||||||
// can probably go after refactor is complete
|
// can probably go after refactor is complete
|
||||||
#include "InstanceWriter.h"
|
#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;
|
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
|
// 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>.
|
// COLLADA allows this through multiple <channel>s in <animation>.
|
||||||
// For this to work, we need to know objects that use a certain action.
|
// 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;
|
PointerRNA sceneptr, unit_settings;
|
||||||
PropertyRNA *system; /* unused , *scale; */
|
PropertyRNA *system; /* unused , *scale; */
|
||||||
@@ -157,7 +160,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename, bool
|
|||||||
clear_global_id_map();
|
clear_global_id_map();
|
||||||
|
|
||||||
COLLADABU::NativeString native_filename =
|
COLLADABU::NativeString native_filename =
|
||||||
COLLADABU::NativeString(std::string(filename));
|
COLLADABU::NativeString(std::string(this->export_settings->filepath));
|
||||||
COLLADASW::StreamWriter sw(native_filename);
|
COLLADASW::StreamWriter sw(native_filename);
|
||||||
|
|
||||||
// open <collada>
|
// open <collada>
|
||||||
@@ -227,32 +230,32 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename, bool
|
|||||||
|
|
||||||
// <library_cameras>
|
// <library_cameras>
|
||||||
if(has_object_type(sce, OB_CAMERA)) {
|
if(has_object_type(sce, OB_CAMERA)) {
|
||||||
CamerasExporter ce(&sw);
|
CamerasExporter ce(&sw, this->export_settings);
|
||||||
ce.exportCameras(sce, selected);
|
ce.exportCameras(sce);
|
||||||
}
|
}
|
||||||
|
|
||||||
// <library_lights>
|
// <library_lights>
|
||||||
if(has_object_type(sce, OB_LAMP)) {
|
if(has_object_type(sce, OB_LAMP)) {
|
||||||
LightsExporter le(&sw);
|
LightsExporter le(&sw, this->export_settings);
|
||||||
le.exportLights(sce, selected);
|
le.exportLights(sce);
|
||||||
}
|
}
|
||||||
|
|
||||||
// <library_images>
|
// <library_images>
|
||||||
ImagesExporter ie(&sw, filename);
|
ImagesExporter ie(&sw, this->export_settings);
|
||||||
ie.exportImages(sce, selected);
|
ie.exportImages(sce);
|
||||||
|
|
||||||
// <library_effects>
|
// <library_effects>
|
||||||
EffectsExporter ee(&sw);
|
EffectsExporter ee(&sw, this->export_settings);
|
||||||
ee.exportEffects(sce, selected);
|
ee.exportEffects(sce);
|
||||||
|
|
||||||
// <library_materials>
|
// <library_materials>
|
||||||
MaterialsExporter me(&sw);
|
MaterialsExporter me(&sw, this->export_settings);
|
||||||
me.exportMaterials(sce, selected);
|
me.exportMaterials(sce);
|
||||||
|
|
||||||
// <library_geometries>
|
// <library_geometries>
|
||||||
if(has_object_type(sce, OB_MESH)) {
|
if(has_object_type(sce, OB_MESH)) {
|
||||||
GeometryExporter ge(&sw);
|
GeometryExporter ge(&sw, this->export_settings);
|
||||||
ge.exportGeom(sce, selected);
|
ge.exportGeom(sce);
|
||||||
}
|
}
|
||||||
|
|
||||||
// <library_animations>
|
// <library_animations>
|
||||||
@@ -260,14 +263,14 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename, bool
|
|||||||
ae.exportAnimations(sce);
|
ae.exportAnimations(sce);
|
||||||
|
|
||||||
// <library_controllers>
|
// <library_controllers>
|
||||||
ArmatureExporter arm_exporter(&sw);
|
ArmatureExporter arm_exporter(&sw, this->export_settings);
|
||||||
if(has_object_type(sce, OB_ARMATURE)) {
|
if(has_object_type(sce, OB_ARMATURE)) {
|
||||||
arm_exporter.export_controllers(sce, selected);
|
arm_exporter.export_controllers(sce);
|
||||||
}
|
}
|
||||||
|
|
||||||
// <library_visual_scenes>
|
// <library_visual_scenes>
|
||||||
SceneExporter se(&sw, &arm_exporter);
|
SceneExporter se(&sw, &arm_exporter, this->export_settings);
|
||||||
se.exportScene(sce, selected);
|
se.exportScene(sce);
|
||||||
|
|
||||||
// <scene>
|
// <scene>
|
||||||
std::string scene_name(translate_id(id_name(sce)));
|
std::string scene_name(translate_id(id_name(sce)));
|
||||||
|
@@ -29,13 +29,18 @@
|
|||||||
#ifndef __DOCUMENTEXPORTER_H__
|
#ifndef __DOCUMENTEXPORTER_H__
|
||||||
#define __DOCUMENTEXPORTER_H__
|
#define __DOCUMENTEXPORTER_H__
|
||||||
|
|
||||||
|
#include "ExportSettings.h"
|
||||||
|
|
||||||
struct Scene;
|
struct Scene;
|
||||||
|
|
||||||
class DocumentExporter
|
class DocumentExporter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void exportCurrentScene(Scene *sce, const char* filename, bool selected);
|
DocumentExporter(const ExportSettings *export_settings);
|
||||||
|
void exportCurrentScene(Scene *sce);
|
||||||
void exportScenes(const char* filename);
|
void exportScenes(const char* filename);
|
||||||
|
private:
|
||||||
|
const ExportSettings *export_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -55,7 +55,7 @@ static std::string getActiveUVLayerName(Object *ob)
|
|||||||
return "";
|
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)
|
bool EffectsExporter::hasEffects(Scene *sce)
|
||||||
{
|
{
|
||||||
@@ -78,12 +78,12 @@ bool EffectsExporter::hasEffects(Scene *sce)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectsExporter::exportEffects(Scene *sce, bool export_selected)
|
void EffectsExporter::exportEffects(Scene *sce)
|
||||||
{
|
{
|
||||||
if(hasEffects(sce)) {
|
if(hasEffects(sce)) {
|
||||||
openLibrary();
|
openLibrary();
|
||||||
MaterialFunctor mf;
|
MaterialFunctor mf;
|
||||||
mf.forEachMaterialInScene<EffectsExporter>(sce, *this, export_selected);
|
mf.forEachMaterialInScene<EffectsExporter>(sce, *this, this->export_settings->selected);
|
||||||
|
|
||||||
closeLibrary();
|
closeLibrary();
|
||||||
}
|
}
|
||||||
|
@@ -43,11 +43,13 @@
|
|||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
|
|
||||||
|
#include "ExportSettings.h"
|
||||||
|
|
||||||
class EffectsExporter: COLLADASW::LibraryEffects
|
class EffectsExporter: COLLADASW::LibraryEffects
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EffectsExporter(COLLADASW::StreamWriter *sw);
|
EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
|
||||||
void exportEffects(Scene *sce, bool export_selected);
|
void exportEffects(Scene *sce);
|
||||||
|
|
||||||
void operator()(Material *ma, Object *ob);
|
void operator()(Material *ma, Object *ob);
|
||||||
|
|
||||||
@@ -66,6 +68,8 @@ private:
|
|||||||
void writePhong(COLLADASW::EffectProfile &ep, Material *ma);
|
void writePhong(COLLADASW::EffectProfile &ep, Material *ma);
|
||||||
|
|
||||||
bool hasEffects(Scene *sce);
|
bool hasEffects(Scene *sce);
|
||||||
|
|
||||||
|
const ExportSettings *export_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
29
source/blender/collada/ExportSettings.cpp
Normal file
29
source/blender/collada/ExportSettings.cpp
Normal file
@@ -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"
|
39
source/blender/collada/ExportSettings.h
Normal file
39
source/blender/collada/ExportSettings.h
Normal file
@@ -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"
|
#include "collada_internal.h"
|
||||||
|
|
||||||
// TODO: optimize UV sets by making indexed list with duplicates removed
|
// 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();
|
openLibrary();
|
||||||
|
|
||||||
mScene = sce;
|
mScene = sce;
|
||||||
GeometryFunctor gf;
|
GeometryFunctor gf;
|
||||||
gf.forEachMeshObjectInScene<GeometryExporter>(sce, *this, export_selected);
|
gf.forEachMeshObjectInScene<GeometryExporter>(sce, *this, this->export_settings->selected);
|
||||||
|
|
||||||
closeLibrary();
|
closeLibrary();
|
||||||
}
|
}
|
||||||
|
@@ -42,6 +42,8 @@
|
|||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
|
|
||||||
|
#include "ExportSettings.h"
|
||||||
|
|
||||||
// TODO: optimize UV sets by making indexed list with duplicates removed
|
// TODO: optimize UV sets by making indexed list with duplicates removed
|
||||||
class GeometryExporter : COLLADASW::LibraryGeometries
|
class GeometryExporter : COLLADASW::LibraryGeometries
|
||||||
{
|
{
|
||||||
@@ -58,9 +60,9 @@ class GeometryExporter : COLLADASW::LibraryGeometries
|
|||||||
Scene *mScene;
|
Scene *mScene;
|
||||||
|
|
||||||
public:
|
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);
|
void operator()(Object *ob);
|
||||||
|
|
||||||
@@ -96,6 +98,8 @@ public:
|
|||||||
/* int getTriCount(MFace *faces, int totface);*/
|
/* int getTriCount(MFace *faces, int totface);*/
|
||||||
private:
|
private:
|
||||||
std::set<std::string> exportedGeometry;
|
std::set<std::string> exportedGeometry;
|
||||||
|
|
||||||
|
const ExportSettings *export_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GeometryFunctor {
|
struct GeometryFunctor {
|
||||||
|
@@ -43,7 +43,7 @@
|
|||||||
#include "BLI_path_util.h"
|
#include "BLI_path_util.h"
|
||||||
#include "BLI_string.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)
|
bool ImagesExporter::hasImages(Scene *sce)
|
||||||
@@ -71,12 +71,12 @@ bool ImagesExporter::hasImages(Scene *sce)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImagesExporter::exportImages(Scene *sce, bool export_selected)
|
void ImagesExporter::exportImages(Scene *sce)
|
||||||
{
|
{
|
||||||
if(hasImages(sce)) {
|
if(hasImages(sce)) {
|
||||||
openLibrary();
|
openLibrary();
|
||||||
MaterialFunctor mf;
|
MaterialFunctor mf;
|
||||||
mf.forEachMaterialInScene<ImagesExporter>(sce, *this, export_selected);
|
mf.forEachMaterialInScene<ImagesExporter>(sce, *this, this->export_settings->selected);
|
||||||
|
|
||||||
closeLibrary();
|
closeLibrary();
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ void ImagesExporter::operator()(Material *ma, Object *ob)
|
|||||||
char src[FILE_MAX];
|
char src[FILE_MAX];
|
||||||
char dir[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);
|
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_object_types.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
|
|
||||||
|
#include "ExportSettings.h"
|
||||||
|
|
||||||
class ImagesExporter: COLLADASW::LibraryImages
|
class ImagesExporter: COLLADASW::LibraryImages
|
||||||
{
|
{
|
||||||
const char *mfilename;
|
|
||||||
std::vector<std::string> mImages; // contains list of written images, to avoid duplicates
|
|
||||||
public:
|
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);
|
void operator()(Material *ma, Object *ob);
|
||||||
private:
|
private:
|
||||||
|
std::vector<std::string> mImages; // contains list of written images, to avoid duplicates
|
||||||
bool hasImages(Scene *sce);
|
bool hasImages(Scene *sce);
|
||||||
|
const ExportSettings *export_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#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();
|
openLibrary();
|
||||||
|
|
||||||
forEachLampObjectInScene(sce, *this, export_selected);
|
forEachLampObjectInScene(sce, *this, this->export_settings->selected);
|
||||||
|
|
||||||
closeLibrary();
|
closeLibrary();
|
||||||
}
|
}
|
||||||
|
@@ -37,14 +37,17 @@
|
|||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
|
|
||||||
|
#include "ExportSettings.h"
|
||||||
|
|
||||||
class LightsExporter: COLLADASW::LibraryLights
|
class LightsExporter: COLLADASW::LibraryLights
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LightsExporter(COLLADASW::StreamWriter *sw);
|
LightsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
|
||||||
void exportLights(Scene *sce, bool export_selected);
|
void exportLights(Scene *sce);
|
||||||
void operator()(Object *ob);
|
void operator()(Object *ob);
|
||||||
private:
|
private:
|
||||||
bool exportBlenderProfile(COLLADASW::Light &cla, Lamp *la);
|
bool exportBlenderProfile(COLLADASW::Light &cla, Lamp *la);
|
||||||
|
const ExportSettings *export_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -33,15 +33,15 @@
|
|||||||
#include "COLLADABUUtils.h"
|
#include "COLLADABUUtils.h"
|
||||||
#include "collada_internal.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)) {
|
if(hasMaterials(sce)) {
|
||||||
openLibrary();
|
openLibrary();
|
||||||
|
|
||||||
MaterialFunctor mf;
|
MaterialFunctor mf;
|
||||||
mf.forEachMaterialInScene<MaterialsExporter>(sce, *this, export_selected);
|
mf.forEachMaterialInScene<MaterialsExporter>(sce, *this, this->export_settings->selected);
|
||||||
|
|
||||||
closeLibrary();
|
closeLibrary();
|
||||||
}
|
}
|
||||||
|
@@ -44,16 +44,18 @@
|
|||||||
|
|
||||||
#include "GeometryExporter.h"
|
#include "GeometryExporter.h"
|
||||||
#include "collada_internal.h"
|
#include "collada_internal.h"
|
||||||
|
#include "ExportSettings.h"
|
||||||
|
|
||||||
class MaterialsExporter: COLLADASW::LibraryMaterials
|
class MaterialsExporter: COLLADASW::LibraryMaterials
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MaterialsExporter(COLLADASW::StreamWriter *sw);
|
MaterialsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
|
||||||
void exportMaterials(Scene *sce, bool export_selected);
|
void exportMaterials(Scene *sce);
|
||||||
void operator()(Material *ma, Object *ob);
|
void operator()(Material *ma, Object *ob);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool hasMaterials(Scene *sce);
|
bool hasMaterials(Scene *sce);
|
||||||
|
const ExportSettings *export_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
// used in forEachMaterialInScene
|
// used in forEachMaterialInScene
|
||||||
|
@@ -28,21 +28,21 @@
|
|||||||
|
|
||||||
#include "SceneExporter.h"
|
#include "SceneExporter.h"
|
||||||
|
|
||||||
SceneExporter::SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm)
|
SceneExporter::SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings)
|
||||||
: COLLADASW::LibraryVisualScenes(sw), arm_exporter(arm)
|
: 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>
|
// <library_visual_scenes> <visual_scene>
|
||||||
std::string id_naming = id_name(sce);
|
std::string id_naming = id_name(sce);
|
||||||
openVisualScene(translate_id(id_naming), id_naming);
|
openVisualScene(translate_id(id_naming), id_naming);
|
||||||
exportHierarchy(sce, export_selected);
|
exportHierarchy(sce);
|
||||||
closeVisualScene();
|
closeVisualScene();
|
||||||
closeLibrary();
|
closeLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneExporter::exportHierarchy(Scene *sce, bool export_selected)
|
void SceneExporter::exportHierarchy(Scene *sce)
|
||||||
{
|
{
|
||||||
Base *base= (Base*) sce->base.first;
|
Base *base= (Base*) sce->base.first;
|
||||||
while(base) {
|
while(base) {
|
||||||
@@ -56,7 +56,7 @@ void SceneExporter::exportHierarchy(Scene *sce, bool export_selected)
|
|||||||
case OB_LAMP:
|
case OB_LAMP:
|
||||||
case OB_ARMATURE:
|
case OB_ARMATURE:
|
||||||
case OB_EMPTY:
|
case OB_EMPTY:
|
||||||
if (export_selected && !(ob->flag & SELECT)) {
|
if (this->export_settings->selected && !(ob->flag & SELECT)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// write nodes....
|
// write nodes....
|
||||||
|
@@ -90,16 +90,20 @@ extern "C" {
|
|||||||
|
|
||||||
#include "ArmatureExporter.h"
|
#include "ArmatureExporter.h"
|
||||||
|
|
||||||
|
#include "ExportSettings.h"
|
||||||
|
|
||||||
class SceneExporter: COLLADASW::LibraryVisualScenes, protected TransformWriter, protected InstanceWriter
|
class SceneExporter: COLLADASW::LibraryVisualScenes, protected TransformWriter, protected InstanceWriter
|
||||||
{
|
{
|
||||||
ArmatureExporter *arm_exporter;
|
|
||||||
public:
|
public:
|
||||||
SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm);
|
SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings);
|
||||||
void exportScene(Scene *sce, bool export_selected);
|
void exportScene(Scene *sce);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void exportHierarchy(Scene *sce, bool export_selected);
|
void exportHierarchy(Scene *sce);
|
||||||
void writeNodes(Object *ob, Scene *sce);
|
void writeNodes(Object *ob, Scene *sce);
|
||||||
|
|
||||||
|
ArmatureExporter *arm_exporter;
|
||||||
|
const ExportSettings *export_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
/* COLLADABU_ASSERT, may be able to remove later */
|
/* COLLADABU_ASSERT, may be able to remove later */
|
||||||
#include "COLLADABUPlatform.h"
|
#include "COLLADABUPlatform.h"
|
||||||
|
|
||||||
|
#include "ExportSettings.h"
|
||||||
#include "DocumentExporter.h"
|
#include "DocumentExporter.h"
|
||||||
#include "DocumentImporter.h"
|
#include "DocumentImporter.h"
|
||||||
|
|
||||||
@@ -53,7 +54,10 @@ extern "C"
|
|||||||
|
|
||||||
int collada_export(Scene *sce, const char *filepath, int selected)
|
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] */
|
/* annoying, collada crashes if file cant be created! [#27162] */
|
||||||
if(!BLI_exist(filepath)) {
|
if(!BLI_exist(filepath)) {
|
||||||
@@ -64,7 +68,8 @@ extern "C"
|
|||||||
}
|
}
|
||||||
/* end! */
|
/* end! */
|
||||||
|
|
||||||
exp.exportCurrentScene(sce, filepath, selected);
|
DocumentExporter exporter(&export_settings);
|
||||||
|
exporter.exportCurrentScene(sce);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user