fix color handling in opengex importer.
Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>pull/548/head
parent
880cb473b0
commit
31cce98680
|
@ -728,17 +728,18 @@ void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene *
|
|||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
static void getColorRGB( aiColor3D *pColor, Value *data ) {
|
||||
if( NULL == pColor || NULL == data ) {
|
||||
static void getColorRGB( aiColor3D *pColor, DataArrayList *colList ) {
|
||||
if( NULL == pColor || NULL == colList ) {
|
||||
return;
|
||||
}
|
||||
|
||||
pColor->r = data->getFloat();
|
||||
data = data->getNext();
|
||||
pColor->g = data->getFloat();
|
||||
data = data->getNext();
|
||||
pColor->b = data->getFloat();
|
||||
data = data->getNext();
|
||||
ai_assert( 3, 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();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
@ -780,8 +781,12 @@ void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScen
|
|||
Property *prop = node->findPropertyByName( "attrib" );
|
||||
if( NULL != prop ) {
|
||||
if( NULL != prop->m_value ) {
|
||||
DataArrayList *colList( node->getDataArrayList() );
|
||||
if( NULL == colList ) {
|
||||
return;
|
||||
}
|
||||
aiColor3D col;
|
||||
getColorRGB( &col, prop->m_value );
|
||||
getColorRGB( &col, colList );
|
||||
const ColorType colType( getColorType( prop->m_key ) );
|
||||
if( DiffuseColor == colType ) {
|
||||
m_currentMaterial->AddProperty( &col, 1, AI_MATKEY_COLOR_DIFFUSE );
|
||||
|
|
|
@ -107,6 +107,12 @@ bool isNumeric( const T in ) {
|
|||
return false;*/
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
bool isNotEndOfToken( T *in, T *end ) {
|
||||
return ( '}' != *in && ',' != *in && !isSpace( *in ) && in != end );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
bool isInteger( T *in, T *end ) {
|
||||
|
@ -117,7 +123,8 @@ bool isInteger( T *in, T *end ) {
|
|||
}
|
||||
|
||||
bool result( false );
|
||||
while( '}' != *in && ',' != *in && !isSpace( *in ) && in != end ) {
|
||||
while( isNotEndOfToken( in, end ) ) {
|
||||
//while( '}' != *in && ',' != *in && !isSpace( *in ) && in != end ) {
|
||||
result = isNumeric( *in );
|
||||
if( !result ) {
|
||||
break;
|
||||
|
@ -139,7 +146,9 @@ bool isFloat( T *in, T *end ) {
|
|||
|
||||
// check for <1>.0f
|
||||
bool result( false );
|
||||
while( !isSpace( *in ) && in != end ) {
|
||||
while( isNotEndOfToken( in, end ) ) {
|
||||
|
||||
// while( !isSpace( *in ) && in != end ) {
|
||||
if( *in == '.' ) {
|
||||
result = true;
|
||||
break;
|
||||
|
@ -159,7 +168,9 @@ bool isFloat( T *in, T *end ) {
|
|||
}
|
||||
|
||||
// check for 1.<0>f
|
||||
while( !isSpace( *in ) && in != end && *in != ',' ) {
|
||||
while( isNotEndOfToken( in, end ) ) {
|
||||
|
||||
// while( !isSpace( *in ) && in != end && *in != ',' && *in != '}' ) {
|
||||
result = isNumeric( *in );
|
||||
if( !result ) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue