From 25bddf547bec786d806952f3535e4ecad28a70b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Thu, 9 Apr 2009 07:11:30 +0000 Subject: [PATCH] Fixed obj writer working on wrong material blocks, double definition of variable git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@91 fdac6126-5c0c-442c-9429-916003d36597 --- Core/IO/writer/OBJWriter.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Core/IO/writer/OBJWriter.cc b/Core/IO/writer/OBJWriter.cc index 09cfa512..7a0f0e5a 100644 --- a/Core/IO/writer/OBJWriter.cc +++ b/Core/IO/writer/OBJWriter.cc @@ -256,19 +256,22 @@ write(std::fstream& _out, BaseExporter& _be, Options _opt) const { if (useMatrial && _opt.check(Options::FaceColor) ){ - int i; + int material = -1; + //color with alpha if ( _opt.color_has_alpha() ){ cA = color_cast (_be.colorA( FaceHandle(i) )); - i = getMaterial(cA); - }else{ + material = getMaterial(cA); + } else{ //and without alpha c = color_cast (_be.color( FaceHandle(i) )); - i = getMaterial(c); + material = getMaterial(c); } - if(lastMat != i) - _out << "usemtl mat" << i << std::endl; + if(lastMat != material) { + _out << "usemtl mat" << material << std::endl; + lastMat = material; + } } _out << "f";