create node tree
Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>pull/531/head
parent
e5a6cd087d
commit
ed57fac879
|
@ -211,6 +211,8 @@ OpenGEXImporter::RefInfo::~RefInfo() {
|
|||
//------------------------------------------------------------------------------------------------
|
||||
OpenGEXImporter::OpenGEXImporter()
|
||||
: m_meshCache()
|
||||
, m_root( NULL )
|
||||
, m_nodeChildMap()
|
||||
, m_mesh2refMap()
|
||||
, m_ctx( NULL )
|
||||
, m_currentNode( NULL )
|
||||
|
@ -261,6 +263,7 @@ void OpenGEXImporter::InternReadFile( const std::string &filename, aiScene *pSce
|
|||
|
||||
copyMeshes( pScene );
|
||||
resolveReferences();
|
||||
createNodeTree( pScene );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
@ -724,6 +727,16 @@ void OpenGEXImporter::handleMaterialNode( ODDLParser::DDLNode *node, aiScene *pS
|
|||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void OpenGEXImporter::handleTextureNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void OpenGEXImporter::copyMeshes( aiScene *pScene ) {
|
||||
if( m_meshCache.empty() ) {
|
||||
|
@ -756,7 +769,7 @@ void OpenGEXImporter::resolveReferences() {
|
|||
if( m_mesh2refMap.end() != it ) {
|
||||
unsigned int meshIdx = m_mesh2refMap[ name ];
|
||||
node->mMeshes[ i ] = meshIdx;
|
||||
node->mNumMeshes++;
|
||||
//node->mNumMeshes++;
|
||||
}
|
||||
}
|
||||
} else if( RefInfo::MaterialRef == currentRefInfo->m_type ) {
|
||||
|
@ -769,13 +782,21 @@ void OpenGEXImporter::resolveReferences() {
|
|||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void OpenGEXImporter::handleTextureNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
||||
void OpenGEXImporter::createNodeTree( aiScene *pScene ) {
|
||||
if( NULL == m_root ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( m_root->m_children.empty() ) {
|
||||
return;
|
||||
}
|
||||
size_t i( 0 );
|
||||
pScene->mRootNode->mNumChildren = m_root->m_children.size();
|
||||
pScene->mRootNode->mChildren = new C_STRUCT aiNode*[ pScene->mRootNode->mNumChildren ];
|
||||
for( ChildInfo::NodeList::iterator it = m_root->m_children.begin(); it != m_root->m_children.end(); it++ ) {
|
||||
pScene->mRootNode->mChildren[ i ] = *it;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
@ -783,12 +804,30 @@ void OpenGEXImporter::pushNode( aiNode *node, aiScene *pScene ) {
|
|||
ai_assert( NULL != pScene );
|
||||
|
||||
if( NULL != node ) {
|
||||
ChildInfo *info( NULL );
|
||||
if( m_nodeStack.empty() ) {
|
||||
node->mParent = pScene->mRootNode;
|
||||
NodeChildMap::iterator it( m_nodeChildMap.find( node->mParent ) );
|
||||
if( m_nodeChildMap.end() == it ) {
|
||||
info = new ChildInfo;
|
||||
m_root = info;
|
||||
m_nodeChildMap[ node->mParent ] = info;
|
||||
} else {
|
||||
info = it->second;
|
||||
}
|
||||
info->m_children.push_back( node );
|
||||
} else {
|
||||
aiNode *parent( m_nodeStack.back() );
|
||||
ai_assert( NULL != parent );
|
||||
node->mParent = parent;
|
||||
NodeChildMap::iterator it( m_nodeChildMap.find( node->mParent ) );
|
||||
if( m_nodeChildMap.end() == it ) {
|
||||
info = new ChildInfo;
|
||||
m_nodeChildMap[ node->mParent ] = info;
|
||||
} else {
|
||||
info = it->second;
|
||||
}
|
||||
info->m_children.push_back( node );
|
||||
}
|
||||
m_nodeStack.push_back( node );
|
||||
}
|
||||
|
|
|
@ -120,6 +120,7 @@ protected:
|
|||
aiNode *popNode();
|
||||
aiNode *top() const;
|
||||
void clearNodeStack();
|
||||
void createNodeTree( aiScene *pScene );
|
||||
|
||||
private:
|
||||
struct VertexContainer {
|
||||
|
@ -156,6 +157,14 @@ private:
|
|||
RefInfo &operator = ( const RefInfo & );
|
||||
};
|
||||
|
||||
struct ChildInfo {
|
||||
typedef std::list<aiNode*> NodeList;
|
||||
std::list<aiNode*> m_children;
|
||||
};
|
||||
ChildInfo *m_root;
|
||||
typedef std::map<aiNode*, ChildInfo*> NodeChildMap;
|
||||
NodeChildMap m_nodeChildMap;
|
||||
|
||||
std::vector<aiMesh*> m_meshCache;
|
||||
typedef std::map<std::string, size_t> ReferenceMap;
|
||||
std::map<std::string, size_t> m_mesh2refMap;
|
||||
|
|
Loading…
Reference in New Issue