OpenGEX: fix invalid handling with color4 token.
parent
542fe31a94
commit
a45b5cdfb5
|
@ -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 ) {
|
||||
return;
|
||||
}
|
||||
|
@ -941,6 +941,23 @@ static void getColorRGB( aiColor3D *pColor, DataArrayList *colList ) {
|
|||
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 {
|
||||
NoneColor = 0,
|
||||
|
@ -991,7 +1008,17 @@ void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScen
|
|||
return;
|
||||
}
|
||||
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 ) );
|
||||
if( DiffuseColor == colType ) {
|
||||
m_currentMaterial->AddProperty( &col, 1, AI_MATKEY_COLOR_DIFFUSE );
|
||||
|
|
|
@ -106,11 +106,13 @@ SET( TEST_SRCS
|
|||
unit/SceneDiffer.cpp
|
||||
unit/utSIBImporter.cpp
|
||||
unit/utObjImportExport.cpp
|
||||
unit/utOpenGEXImportExport.cpp
|
||||
unit/utPretransformVertices.cpp
|
||||
unit/utPLYImportExport.cpp
|
||||
unit/utRemoveComments.cpp
|
||||
unit/utRemoveComponent.cpp
|
||||
unit/utRemoveRedundantMaterials.cpp
|
||||
unit/utRemoveVCProcess.cpp
|
||||
unit/utScenePreprocessor.cpp
|
||||
unit/utSharedPPData.cpp
|
||||
unit/utStringUtils.cpp
|
||||
|
|
|
@ -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 } }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue