From 845d206959993392a08ab756a78246cbae96c9c0 Mon Sep 17 00:00:00 2001 From: aoowweenn Date: Wed, 22 Mar 2017 21:11:17 +0800 Subject: [PATCH] Fill in mParent for each node in Assbin Loader --- code/AssbinLoader.cpp | 10 +++++++--- code/AssbinLoader.h | 2 +- code/ColladaExporter.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/code/AssbinLoader.cpp b/code/AssbinLoader.cpp index 7a17d5ad5..5686d45b9 100644 --- a/code/AssbinLoader.cpp +++ b/code/AssbinLoader.cpp @@ -196,7 +196,7 @@ template void ReadBounds( IOStream * stream, T* /*p*/, unsigned int stream->Seek( sizeof(T) * n, aiOrigin_CUR ); } -void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node ) +void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* parent ) { uint32_t chunkID = Read(stream); ai_assert(chunkID == ASSBIN_CHUNK_AINODE); @@ -208,6 +208,10 @@ void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node ) (*node)->mTransformation = Read(stream); (*node)->mNumChildren = Read(stream); (*node)->mNumMeshes = Read(stream); + if(parent) + { + (*node)->mParent = parent; + } if ((*node)->mNumMeshes) { @@ -221,7 +225,7 @@ void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node ) { (*node)->mChildren = new aiNode*[(*node)->mNumChildren]; for (unsigned int i = 0; i < (*node)->mNumChildren; ++i) { - ReadBinaryNode( stream, &(*node)->mChildren[i] ); + ReadBinaryNode( stream, &(*node)->mChildren[i], *node ); } } @@ -569,7 +573,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) // Read node graph scene->mRootNode = new aiNode[1]; - ReadBinaryNode( stream, &scene->mRootNode ); + ReadBinaryNode( stream, &scene->mRootNode, (aiNode*)NULL ); // Read all meshes if (scene->mNumMeshes) diff --git a/code/AssbinLoader.h b/code/AssbinLoader.h index e8c8dd0cb..7e098caec 100644 --- a/code/AssbinLoader.h +++ b/code/AssbinLoader.h @@ -86,7 +86,7 @@ public: IOSystem* pIOHandler ); void ReadBinaryScene( IOStream * stream, aiScene* pScene ); - void ReadBinaryNode( IOStream * stream, aiNode** mRootNode ); + void ReadBinaryNode( IOStream * stream, aiNode** mRootNode, aiNode* parent ); void ReadBinaryMesh( IOStream * stream, aiMesh* mesh ); void ReadBinaryBone( IOStream * stream, aiBone* bone ); void ReadBinaryMaterial(IOStream * stream, aiMaterial* mat); diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 278ded66a..e373d8cf7 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -804,7 +804,7 @@ void ColladaExporter::WriteControllerLibrary() // ------------------------------------------------------------------------------------------------ // Writes a skin controller of the given mesh -void WriteController( size_t pIndex) +void ColladaExporter::WriteController( size_t pIndex) { const aiMesh* mesh = mScene->mMeshes[pIndex]; const std::string idstr = GetMeshId( pIndex); @@ -820,7 +820,7 @@ void WriteController( size_t pIndex) mOutput << "name=\"skinCluster" << pIndex << "\">"<< endstr; PushTag(); - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); // bind pose matrix @@ -828,7 +828,7 @@ void WriteController( size_t pIndex) PushTag(); // I think it is identity in general cases. - aiMatrix4x4 mat(); + aiMatrix4x4 mat; mOutput << startstr; mOutput << mat.a1 << " " << mat.a2 << " " << mat.a3 << " " << mat.a4; mOutput << mat.b1 << " " << mat.b2 << " " << mat.b3 << " " << mat.b4; @@ -842,7 +842,7 @@ void WriteController( size_t pIndex) mOutput << startstr << "mNumBones << "\">"; for( size_t i = 0; i < mesh->mNumBones; ++i ) - mOutput << XMLEscape(mesh->mBones[i].mName) << " "; + mOutput << XMLEscape(mesh->mBones[i]->mName.C_Str()) << " "; mOutput << "" << endstr;