From 78493b833cde6b307c90ec5fdf3c3db614042315 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Sat, 27 Aug 2011 23:32:53 +0000 Subject: [PATCH] + Obj: implement exporting of p and l entities. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1074 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/ObjExporter.cpp | 34 ++++++++++++++++++++++++++-------- code/ObjExporter.h | 1 + 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index e9eb201ed..a34f635af 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -220,15 +220,23 @@ void ObjExporter :: WriteGeometryFile() mOutput << "usemtl " << m.matname << endl; BOOST_FOREACH(const Face& f, m.faces) { - mOutput << "f "; + mOutput << f.kind << ' '; BOOST_FOREACH(const FaceVertex& fv, f.indices) { - mOutput << " " << fv.vp << "/"; - if (fv.vt) { - mOutput << fv.vt; - } - mOutput << "/"; - if (fv.vn) { - mOutput << fv.vn; + mOutput << ' ' << fv.vp; + + if (f.kind != 'p') { + if (fv.vt || f.kind == 'f') { + mOutput << '/'; + } + if (fv.vt) { + mOutput << fv.vt; + } + if (f.kind == 'f') { + mOutput << '/'; + if (fv.vn) { + mOutput << fv.vn; + } + } } } @@ -252,6 +260,16 @@ void ObjExporter :: AddMesh(const aiString& name, const aiMesh* m, const aiMatri const aiFace& f = m->mFaces[i]; Face& face = mesh.faces[i]; + switch (f.mNumIndices) { + case 1: + face.kind = 'p'; + break; + case 2: + face.kind = 'l'; + break; + default: + face.kind = 'f'; + } face.indices.resize(f.mNumIndices); for(unsigned int a = 0; a < f.mNumIndices; ++a) { diff --git a/code/ObjExporter.h b/code/ObjExporter.h index c56a23d42..2c5ec4258 100644 --- a/code/ObjExporter.h +++ b/code/ObjExporter.h @@ -86,6 +86,7 @@ private: }; struct Face { + char kind; std::vector indices; };