OpenGEX: fix invalid handling with color4 token.

pull/1272/head
Kim Kulling 2017-05-16 21:45:23 +02:00
parent 542fe31a94
commit a45b5cdfb5
3 changed files with 52 additions and 2 deletions

View File

@ -927,7 +927,7 @@ void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene *
} }
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
static void getColorRGB( aiColor3D *pColor, DataArrayList *colList ) { static void getColorRGB3( aiColor3D *pColor, DataArrayList *colList ) {
if( nullptr == pColor || nullptr == colList ) { if( nullptr == pColor || nullptr == colList ) {
return; return;
} }
@ -941,6 +941,23 @@ static void getColorRGB( aiColor3D *pColor, DataArrayList *colList ) {
pColor->b = val->getFloat(); pColor->b = val->getFloat();
} }
//------------------------------------------------------------------------------------------------
static void getColorRGB4( aiColor4D *pColor, DataArrayList *colList ) {
if ( nullptr == pColor || nullptr == colList ) {
return;
}
ai_assert( 4 == colList->m_numItems );
Value *val( colList->m_dataList );
pColor->r = val->getFloat();
val = val->getNext();
pColor->g = val->getFloat();
val = val->getNext();
pColor->b = val->getFloat();
val = val->getNext();
pColor->a = val->getFloat();
}
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
enum ColorType { enum ColorType {
NoneColor = 0, NoneColor = 0,
@ -991,7 +1008,17 @@ void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScen
return; return;
} }
aiColor3D col; aiColor3D col;
getColorRGB( &col, colList ); if ( 3 == colList->m_numItems ) {
aiColor3D col3;
getColorRGB3( &col3, colList );
col = col3;
} else {
aiColor4D col4;
getColorRGB4( &col4, colList );
col.r = col4.r;
col.g = col4.g;
col.b = col4.b;
}
const ColorType colType( getColorType( prop->m_key ) ); const ColorType colType( getColorType( prop->m_key ) );
if( DiffuseColor == colType ) { if( DiffuseColor == colType ) {
m_currentMaterial->AddProperty( &col, 1, AI_MATKEY_COLOR_DIFFUSE ); m_currentMaterial->AddProperty( &col, 1, AI_MATKEY_COLOR_DIFFUSE );

View File

@ -106,11 +106,13 @@ SET( TEST_SRCS
unit/SceneDiffer.cpp unit/SceneDiffer.cpp
unit/utSIBImporter.cpp unit/utSIBImporter.cpp
unit/utObjImportExport.cpp unit/utObjImportExport.cpp
unit/utOpenGEXImportExport.cpp
unit/utPretransformVertices.cpp unit/utPretransformVertices.cpp
unit/utPLYImportExport.cpp unit/utPLYImportExport.cpp
unit/utRemoveComments.cpp unit/utRemoveComments.cpp
unit/utRemoveComponent.cpp unit/utRemoveComponent.cpp
unit/utRemoveRedundantMaterials.cpp unit/utRemoveRedundantMaterials.cpp
unit/utRemoveVCProcess.cpp
unit/utScenePreprocessor.cpp unit/utScenePreprocessor.cpp
unit/utSharedPPData.cpp unit/utSharedPPData.cpp
unit/utStringUtils.cpp unit/utStringUtils.cpp

View File

@ -0,0 +1,21 @@
LightObject (type = "infinite") {
Param (attrib = "intensity") {
float { 3.0 }
}
Color (attrib = "light") {
float[3] { { 0.7, 1.0, 0.1 } }
}
}
LightObject (type = "point") {
Param (attrib = "intensity") {
float { 0.5 }
}
}
LightObject (type = "spot") {
Color (attrib = "light") {
float[4] { { 0.1, 0.0, 0.1, 1.0 } }
}
}