Merge pull request #1922 from kwuerl/issue-1167

Fix ply exporter to be conformant to spec respecting vertex colors.
pull/1939/head
Kim Kulling 2018-05-02 16:33:43 +02:00 committed by GitHub
commit 6ef9e8848d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 13 deletions

View File

@ -194,16 +194,16 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina
for (unsigned int n = PLY_EXPORT_HAS_COLORS, c = 0; (components & n) && c != AI_MAX_NUMBER_OF_COLOR_SETS; n <<= 1, ++c) {
if (!c) {
mOutput << "property " << typeName << " r" << endl;
mOutput << "property " << typeName << " g" << endl;
mOutput << "property " << typeName << " b" << endl;
mOutput << "property " << typeName << " a" << endl;
mOutput << "property " << "uchar" << " red" << endl;
mOutput << "property " << "uchar" << " green" << endl;
mOutput << "property " << "uchar" << " blue" << endl;
mOutput << "property " << "uchar" << " alpha" << endl;
}
else {
mOutput << "property " << typeName << " r" << c << endl;
mOutput << "property " << typeName << " g" << c << endl;
mOutput << "property " << typeName << " b" << c << endl;
mOutput << "property " << typeName << " a" << c << endl;
mOutput << "property " << "uchar" << " red" << c << endl;
mOutput << "property " << "uchar" << " green" << c << endl;
mOutput << "property " << "uchar" << " blue" << c << endl;
mOutput << "property " << "uchar" << " alpha" << c << endl;
}
}
@ -288,13 +288,13 @@ void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components)
for (unsigned int n = PLY_EXPORT_HAS_COLORS, c = 0; (components & n) && c != AI_MAX_NUMBER_OF_COLOR_SETS; n <<= 1, ++c) {
if (m->HasVertexColors(c)) {
mOutput <<
" " << m->mColors[c][i].r <<
" " << m->mColors[c][i].g <<
" " << m->mColors[c][i].b <<
" " << m->mColors[c][i].a;
" " << (int)(m->mColors[c][i].r * 255) <<
" " << (int)(m->mColors[c][i].g * 255) <<
" " << (int)(m->mColors[c][i].b * 255) <<
" " << (int)(m->mColors[c][i].a * 255);
}
else {
mOutput << " -1.0 -1.0 -1.0 -1.0";
mOutput << " 0 0 0";
}
}