소스 검색

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.
Albert Wang 13 년 전
부모
커밋
7d4ee98350
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      code/ColladaParser.cpp

+ 6 - 1
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.");