Merge -c 29280 from COLLADA branch into trunk.
authorArystanbek Dyussenov <arystan.d@gmail.com>
Sun, 6 Jun 2010 19:32:12 +0000 (19:32 +0000)
committerArystanbek Dyussenov <arystan.d@gmail.com>
Sun, 6 Jun 2010 19:32:12 +0000 (19:32 +0000)
source/blender/collada/DocumentExporter.cpp

index 8cc8e7455c9df0bbf44ad2edd8bb0d74a1ed9f0a..b474f65ac0d250e16ea812d55ad0f1ddf87a0093 100644 (file)
@@ -1578,18 +1578,27 @@ public:
                else {
                        ep.setIndexOfRefraction(1.0f);
                }
+       
+               COLLADASW::ColorOrTexture cot;
+
                // transparency
-               ep.setTransparency(ma->alpha);
+               // Tod: because we are in A_ONE mode transparency is calculated like this:
+               ep.setTransparency(1.0f);
+               cot = getcol(0.0f, 0.0f, 0.0f, ma->alpha);
+               ep.setTransparent(cot);
+
                // emission
-               COLLADASW::ColorOrTexture cot = getcol(0.0f, 0.0f, 0.0f, 1.0f);
+               cot=getcol(ma->emit, ma->emit, ma->emit, 1.0f);
                ep.setEmission(cot);
-               ep.setTransparent(cot);
+
                // diffuse 
                cot = getcol(ma->r, ma->g, ma->b, 1.0f);
                ep.setDiffuse(cot);
+
                // ambient
                cot = getcol(ma->ambr, ma->ambg, ma->ambb, 1.0f);
                ep.setAmbient(cot);
+
                // reflective, reflectivity
                if (ma->mode & MA_RAYMIRROR) {
                        cot = getcol(ma->mirr, ma->mirg, ma->mirb, 1.0f);
@@ -1597,15 +1606,16 @@ public:
                        ep.setReflectivity(ma->ray_mirror);
                }
                else {
-                       cot = getcol(0.0f, 0.0f, 0.0f, 1.0f);
+                       cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
                        ep.setReflective(cot);
-                       ep.setReflectivity(0.0f);
+                       ep.setReflectivity(ma->spec);
                }
+
                // specular
                if (ep.getShaderType() != COLLADASW::EffectProfile::LAMBERT) {
                        cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
                        ep.setSpecular(cot);
-               }
+               }       
 
                // XXX make this more readable if possible
 
@@ -1714,7 +1724,19 @@ public:
                }
                // performs the actual writing
                ep.addProfileElements();
+               bool twoSided = false;
+               if (ob->type == OB_MESH && ob->data) {
+                       Mesh *me = (Mesh*)ob->data;
+                       if (me->flag & ME_TWOSIDED)
+                               twoSided = true;
+               }
+               if (twoSided)
+                       ep.addExtraTechniqueParameter("GOOGLEEARTH", "double_sided", 1);
+               ep.addExtraTechniques(mSW);
+
                ep.closeProfile();
+               if (twoSided)
+                       mSW->appendTextBlock("<extra><technique profile=\"MAX3D\"><double_sided>1</double_sided></technique></extra>");
                closeEffect();  
        }