first version of material handling for opengex
Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>
This commit is contained in:
@@ -217,6 +217,7 @@ OpenGEXImporter::OpenGEXImporter()
|
||||
, m_ctx( NULL )
|
||||
, m_currentNode( NULL )
|
||||
, m_currentMesh( NULL )
|
||||
, m_currentMaterial( NULL )
|
||||
, m_nodeStack()
|
||||
, m_unresolvedRefStack() {
|
||||
// empty
|
||||
@@ -722,14 +723,62 @@ void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene *
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
static void getColorRGBA( aiColor3D *pColor, Value *data ) {
|
||||
if( NULL == pColor || NULL == data ) {
|
||||
return;
|
||||
}
|
||||
|
||||
pColor->r = data->getFloat();
|
||||
data = data->getNext();
|
||||
pColor->g = data->getFloat();
|
||||
data = data->getNext();
|
||||
pColor->b = data->getFloat();
|
||||
data = data->getNext();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
enum ColorType {
|
||||
NoneColor = 0,
|
||||
DiffuseColor
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
static ColorType getColorType( Identifier *id ) {
|
||||
const int res(strncmp("diffuse", id->m_buffer, id->m_len ) );
|
||||
if( 0 == res ) {
|
||||
return DiffuseColor;
|
||||
}
|
||||
|
||||
return NoneColor;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void OpenGEXImporter::handleMaterialNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
||||
m_currentMaterial = new aiMaterial;
|
||||
m_materialCache.push_back( m_currentMaterial );
|
||||
|
||||
handleNodes( node, pScene );
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
||||
if( NULL == node ) {
|
||||
return;
|
||||
}
|
||||
|
||||
Property *colorProp = node->getProperties();
|
||||
if( NULL != colorProp ) {
|
||||
if( NULL != colorProp->m_id ) {
|
||||
ColorType type( getColorType( colorProp->m_primData ) );
|
||||
if( type == DiffuseColor ) {
|
||||
aiColor3D *col = new aiColor3D;
|
||||
getColorRGBA( col, node->getValue() );
|
||||
m_currentMaterial->AddProperty( col, 1, AI_MATKEY_COLOR_DIFFUSE );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user