Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Letwory <nathan@letworyinteractive.com>2011-03-18 17:06:13 +0300
committerNathan Letwory <nathan@letworyinteractive.com>2011-03-18 17:06:13 +0300
commit7e53769d09863b59beae4155ea0ad13c6ab2fac2 (patch)
treecb5ef0f99fa4c171fb1ce1128db19db42b14b0be /source/blender/collada
parentb4743ccd8fdb577670d16ffdd6b3ad2132fa3fea (diff)
COLLADA conformance: don't write empty libraries for effect, image and animation
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/DocumentExporter.cpp34
-rw-r--r--source/blender/collada/EffectExporter.cpp33
-rw-r--r--source/blender/collada/EffectExporter.h7
-rw-r--r--source/blender/collada/ImageExporter.cpp35
-rw-r--r--source/blender/collada/ImageExporter.h2
5 files changed, 93 insertions, 18 deletions
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index f481add98ff..00daac60281 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -307,15 +307,19 @@ public:
AnimationExporter(COLLADASW::StreamWriter *sw): COLLADASW::LibraryAnimations(sw) { this->sw = sw; }
+
+
void exportAnimations(Scene *sce)
{
- this->scene = sce;
+ if(hasAnimations(sce)) {
+ this->scene = sce;
- openLibrary();
-
- forEachObjectInScene(sce, *this);
-
- closeLibrary();
+ openLibrary();
+
+ forEachObjectInScene(sce, *this);
+
+ closeLibrary();
+ }
}
// called for each exported object
@@ -905,6 +909,24 @@ protected:
}
}
}
+
+ bool hasAnimations(Scene *sce)
+ {
+ Base *base= (Base*) sce->base.first;
+ while(base) {
+ Object *ob = base->object;
+
+ FCurve *fcu = 0;
+ if(ob->adt && ob->adt->action)
+ fcu = (FCurve*)ob->adt->action->curves.first;
+
+ if ((ob->type == OB_ARMATURE && ob->data) || fcu) {
+ return true;
+ }
+ base= base->next;
+ }
+ return false;
+ }
};
void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename)
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
index ee0ade53e99..323b90fe1cc 100644
--- a/source/blender/collada/EffectExporter.cpp
+++ b/source/blender/collada/EffectExporter.cpp
@@ -55,15 +55,38 @@ static std::string getActiveUVLayerName(Object *ob)
return "";
}
-
EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw) : COLLADASW::LibraryEffects(sw){}
+
+bool EffectsExporter::hasEffects(Scene *sce)
+{
+ Base *base = (Base *)sce->base.first;
+
+ while(base) {
+ Object *ob= base->object;
+ int a;
+ for(a = 0; a < ob->totcol; a++)
+ {
+ Material *ma = give_current_material(ob, a+1);
+
+ // no material, but check all of the slots
+ if (!ma) continue;
+
+ return true;
+ }
+ base= base->next;
+ }
+ return false;
+}
+
void EffectsExporter::exportEffects(Scene *sce)
{
- openLibrary();
- MaterialFunctor mf;
- mf.forEachMaterialInScene<EffectsExporter>(sce, *this);
+ if(hasEffects(sce)) {
+ openLibrary();
+ MaterialFunctor mf;
+ mf.forEachMaterialInScene<EffectsExporter>(sce, *this);
- closeLibrary();
+ closeLibrary();
+ }
}
void EffectsExporter::operator()(Material *ma, Object *ob)
diff --git a/source/blender/collada/EffectExporter.h b/source/blender/collada/EffectExporter.h
index 3a3de95458b..8fe7ef31da4 100644
--- a/source/blender/collada/EffectExporter.h
+++ b/source/blender/collada/EffectExporter.h
@@ -57,10 +57,11 @@ public:
/*COLLADASW::Surface *surface*/);
COLLADASW::ColorOrTexture getcol(float r, float g, float b, float a);
-
- //returns the array of mtex indices which have image
- //need this for exporting textures
+private:
+ /** Fills the array of mtex indices which have image. Used for exporting images. */
void createTextureIndices(Material *ma, std::vector<int> &indices);
+
+ bool hasEffects(Scene *sce);
};
#endif
diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp
index a2d9cb15ab1..b7a5ef4c4e4 100644
--- a/source/blender/collada/ImageExporter.cpp
+++ b/source/blender/collada/ImageExporter.cpp
@@ -46,13 +46,40 @@
ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, const char* filename) : COLLADASW::LibraryImages(sw), mfilename(filename)
{}
+bool ImagesExporter::hasImages(Scene *sce)
+{
+ Base *base = (Base *)sce->base.first;
+
+ while(base) {
+ Object *ob= base->object;
+ int a;
+ for(a = 0; a < ob->totcol; a++)
+ {
+ Material *ma = give_current_material(ob, a+1);
+
+ // no material, but check all of the slots
+ if (!ma) continue;
+ int b;
+ for (b = 0; b < MAX_MTEX; b++) {
+ MTex *mtex = ma->mtex[b];
+ if (mtex && mtex->tex && mtex->tex->ima) return true;
+ }
+
+ }
+ base= base->next;
+ }
+ return false;
+}
+
void ImagesExporter::exportImages(Scene *sce)
{
- openLibrary();
- MaterialFunctor mf;
- mf.forEachMaterialInScene<ImagesExporter>(sce, *this);
+ if(hasImages(sce)) {
+ openLibrary();
+ MaterialFunctor mf;
+ mf.forEachMaterialInScene<ImagesExporter>(sce, *this);
- closeLibrary();
+ closeLibrary();
+ }
}
void ImagesExporter::operator()(Material *ma, Object *ob)
diff --git a/source/blender/collada/ImageExporter.h b/source/blender/collada/ImageExporter.h
index 901e6be3ecb..04e3010dc7a 100644
--- a/source/blender/collada/ImageExporter.h
+++ b/source/blender/collada/ImageExporter.h
@@ -49,6 +49,8 @@ public:
void exportImages(Scene *sce);
void operator()(Material *ma, Object *ob);
+private:
+ bool hasImages(Scene *sce);
};
#endif