Browse Source

Added support for emissive colors to Blender exporter

Alessandro Piva 11 years ago
parent
commit
004de80b2b

+ 10 - 0
utils/exporters/blender/2.65/scripts/addons/io_mesh_threejs/export_threejs.py

@@ -1216,6 +1216,10 @@ def extract_materials(mesh, scene, option_colors, option_copy_textures, filepath
                                         m.ambient * material['colorDiffuse'][1],
                                         m.ambient * material['colorDiffuse'][2]]
 
+            material['colorEmissive'] = [m.emit * material['colorDiffuse'][0],
+                                         m.emit * material['colorDiffuse'][1],
+                                         m.emit * material['colorDiffuse'][2]]
+
             material['transparency'] = m.alpha
 
             # not sure about mapping values to Blinn-Phong shader
@@ -1928,6 +1932,10 @@ def extract_material_data(m, option_colors):
                                 m.ambient * material['colorDiffuse'][1],
                                 m.ambient * material['colorDiffuse'][2]]
 
+    material['colorEmissive'] = [m.emit * material['colorDiffuse'][0],
+                                 m.emit * material['colorDiffuse'][1],
+                                 m.emit * material['colorDiffuse'][2]]
+
     material['transparency'] = m.alpha
 
     # not sure about mapping values to Blinn-Phong shader
@@ -2042,10 +2050,12 @@ def generate_material_string(material):
 
     parameters = '"color": %d' % rgb2int(material["colorDiffuse"])
     parameters += ', "ambient": %d' % rgb2int(material["colorDiffuse"])
+    parameters += ', "emissive": %d' % rgb2int(material["colorEmissive"])
     parameters += ', "opacity": %.2g' % material["transparency"]
 
     if shading == "Phong":
         parameters += ', "ambient": %d' % rgb2int(material["colorAmbient"])
+        parameters += ', "emissive": %d' % rgb2int(material["colorEmissive"])
         parameters += ', "specular": %d' % rgb2int(material["colorSpecular"])
         parameters += ', "shininess": %.1g' % material["specularCoef"]