From 7d4ee98350f05ec428ec5be4384da18572f33ab9 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Mon, 12 Nov 2012 12:33:51 -0600 Subject: [PATCH] Adjusting the Collada Color Parser The collada parser parses the RGB descriptor out of the xml file, but does not use this information when constructing the actual mColors array. If you export a collada file with RGB colors, and then import it, it used to create color values in the form RGBR, taking the R component from the next color tuple instead of filling in sensible defaults for the alpha channel. This patch uses the information to fill each color. --- code/ColladaParser.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index 195d0d7ca..d8d9e5f10 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -2231,7 +2231,12 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si pMesh->mColors[pInput.mIndex].insert( pMesh->mColors[pInput.mIndex].end(), pMesh->mPositions.size() - pMesh->mColors[pInput.mIndex].size() - 1, aiColor4D( 0, 0, 0, 1)); - pMesh->mColors[pInput.mIndex].push_back( aiColor4D( obj[0], obj[1], obj[2], obj[3])); + aiColor4D result(0, 0, 0, 1); + for (size_t i = 0; i < pInput.mResolved->mSize; ++i) + { + result[i] = obj[pInput.mResolved->mSubOffset[i]]; + } + pMesh->mColors[pInput.mIndex].push_back(result); } else { DefaultLogger::get()->error("Collada: too many vertex color sets. Skipping.");