From 7f3b044b834f7e5f74b20861728f6ccab3c3cafa Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 30 Mar 2015 11:55:57 +0200 Subject: [PATCH] add import of index array data. Signed-off-by: Kim Kulling --- code/OpenGEXImporter.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/code/OpenGEXImporter.cpp b/code/OpenGEXImporter.cpp index cf637f22d..21c55b3b7 100644 --- a/code/OpenGEXImporter.cpp +++ b/code/OpenGEXImporter.cpp @@ -645,7 +645,30 @@ void OpenGEXImporter::handleVertexArrayNode( ODDLParser::DDLNode *node, aiScene //------------------------------------------------------------------------------------------------ void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene *pScene ) { + if( NULL == node ) { + throw DeadlyImportError( "No parent node for name." ); + return; + } + DataArrayList *vaList = node->getDataArrayList(); + if( NULL == vaList ) { + return; + } + + const size_t numItems( countDataArrayListItems( vaList ) ); + m_currentMesh->mNumFaces = numItems; + m_currentMesh->mFaces = new aiFace[ numItems ]; + for( size_t i = 0; i < numItems; i++ ) { + aiFace *current( & ( m_currentMesh->mFaces[ i ] ) ); + current->mNumIndices = 3; + current->mIndices = new unsigned int[ 3 ]; + Value *next( vaList->m_dataList ); + for( size_t i = 0; i < 3; i++ ) { + current->mIndices[ i ] = next->getInt32(); + next = next->m_next; + } + vaList = vaList->m_next; + } } //------------------------------------------------------------------------------------------------