From 101e0c9ec6db92a842a8ca8fc7b4e475a6f2f477 Mon Sep 17 00:00:00 2001 From: Pawel Kowal Date: Tue, 7 Jun 2016 22:07:48 +0200 Subject: [PATCH] Improved Blender/Collada shadeless->unshaded import --- tools/collada/collada.cpp | 3 +++ tools/collada/collada.h | 3 ++- tools/editor/io_plugins/editor_import_collada.cpp | 1 + tools/export/blender25/io_scene_dae/export_dae.py | 6 ++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/collada/collada.cpp b/tools/collada/collada.cpp index f0fde20dfce..11a0e1726b6 100644 --- a/tools/collada/collada.cpp +++ b/tools/collada/collada.cpp @@ -736,6 +736,9 @@ void Collada::_parse_effect_material(XMLParser& parser,Effect &effect,String &id effect.found_double_sided=true; effect.double_sided=parser.get_node_data().to_int(); COLLADA_PRINT("double sided: "+itos(parser.get_node_data().to_int())); + } else if (parser.get_node_name()=="unshaded") { + parser.read(); + effect.unshaded=parser.get_node_data().to_int(); } else if (parser.get_node_name()=="bump") { // color or texture types diff --git a/tools/collada/collada.h b/tools/collada/collada.h index 01934a1e765..9340cdd3f3a 100644 --- a/tools/collada/collada.h +++ b/tools/collada/collada.h @@ -75,6 +75,7 @@ public: float shininess; bool found_double_sided; bool double_sided; + bool unshaded; String get_texture_path(const String& p_source,Collada& state) const; @@ -83,7 +84,7 @@ public: double_sided=true; found_double_sided=false; shininess=40; - + unshaded=false; } }; diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp index f0aec113d1d..80cd54756ef 100644 --- a/tools/editor/io_plugins/editor_import_collada.cpp +++ b/tools/editor/io_plugins/editor_import_collada.cpp @@ -467,6 +467,7 @@ Error ColladaImport::_create_material(const String& p_target) { material->set_parameter(FixedMaterial::PARAM_SPECULAR_EXP,effect.shininess); material->set_flag(Material::FLAG_DOUBLE_SIDED,effect.double_sided); + material->set_flag(Material::FLAG_UNSHADED,effect.unshaded); diff --git a/tools/export/blender25/io_scene_dae/export_dae.py b/tools/export/blender25/io_scene_dae/export_dae.py index 3bb440ffe57..2f7d1ddd865 100644 --- a/tools/export/blender25/io_scene_dae/export_dae.py +++ b/tools/export/blender25/io_scene_dae/export_dae.py @@ -351,6 +351,12 @@ class DaeExporter: self.writel(S_FX,5,'') self.writel(S_FX,6,''+["0","1"][double_sided_hint]+"") self.writel(S_FX,5,'') + + if (material.use_shadeless): + self.writel(S_FX,5,'') + self.writel(S_FX,6,'1') + self.writel(S_FX,5,'') + self.writel(S_FX,4,'') self.writel(S_FX,3,'')