Fix [#28614] Collada Exporter does not export Ambient term
authorNathan Letwory <nathan@letworyinteractive.com>
Mon, 12 Sep 2011 13:20:24 +0000 (13:20 +0000)
committerNathan Letwory <nathan@letworyinteractive.com>
Mon, 12 Sep 2011 13:20:24 +0000 (13:20 +0000)
reported by Steiner Bernhard

ma->ambX is calculated only on a render, so instead of relying on those values compute them manually.

source/blender/collada/EffectExporter.cpp
source/blender/collada/EffectExporter.h

index ed37dada195a6d2a870b5ef87e271de71783743f..b4cc88ee3b87f78d81a4e0cb25c015dd6424fa49 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "DNA_mesh_types.h"
 #include "DNA_texture_types.h"
+#include "DNA_world_types.h"
 
 #include "BKE_customdata.h"
 
@@ -81,6 +82,7 @@ bool EffectsExporter::hasEffects(Scene *sce)
 void EffectsExporter::exportEffects(Scene *sce)
 {
        if(hasEffects(sce)) {
+               this->scene = sce;
                openLibrary();
                MaterialFunctor mf;
                mf.forEachMaterialInScene<EffectsExporter>(sce, *this, this->export_settings->selected);
@@ -175,7 +177,8 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
        ep.setDiffuse(cot, false , "diffuse");
 
        // ambient
-       cot = getcol(ma->ambr, ma->ambg, ma->ambb, 1.0f);
+       /* ma->ambX is calculated only on render, so lets do it here manually and not rely on ma->ambX. */
+       cot = getcol(this->scene->world->ambr*ma->amb, this->scene->world->ambg*ma->amb, this->scene->world->ambb*ma->amb, 1.0f);
        ep.setAmbient(cot, false , "ambient");
 
        // reflective, reflectivity
index dc1f4c4474b054c30f20b085cf7a2a4a4146384b..25d7ed15bc3f3ba762634a8ea3f58384962e0619 100644 (file)
@@ -70,6 +70,8 @@ private:
        bool hasEffects(Scene *sce);
        
        const ExportSettings *export_settings;
+       
+       Scene *scene;
 };
 
 #endif