first version of material handling for opengex
Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>pull/538/head
parent
223a5385af
commit
ead3e8d275
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -174,6 +174,8 @@ private:
|
|||
aiNode *m_currentNode;
|
||||
VertexContainer m_currentVertices;
|
||||
aiMesh *m_currentMesh;
|
||||
aiMaterial *m_currentMaterial;
|
||||
std::vector<aiMaterial*> m_materialCache;
|
||||
std::vector<aiNode*> m_nodeStack;
|
||||
std::vector<RefInfo*> m_unresolvedRefStack;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue