Przeglądaj źródła

Fill in mParent for each node in Assbin Loader

aoowweenn 8 lat temu
rodzic
commit
845d206959
3 zmienionych plików z 12 dodań i 8 usunięć
  1. 7 3
      code/AssbinLoader.cpp
  2. 1 1
      code/AssbinLoader.h
  3. 4 4
      code/ColladaExporter.cpp

+ 7 - 3
code/AssbinLoader.cpp

@@ -196,7 +196,7 @@ template <typename T> 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<uint32_t>(stream);
     ai_assert(chunkID == ASSBIN_CHUNK_AINODE);
@@ -208,6 +208,10 @@ void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node )
     (*node)->mTransformation = Read<aiMatrix4x4>(stream);
     (*node)->mNumChildren = Read<unsigned int>(stream);
     (*node)->mNumMeshes = Read<unsigned int>(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)

+ 1 - 1
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);

+ 4 - 4
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 << "<skin source=\"#" << idstrEscaped \">" << endstr;
+    mOutput << startstr << "<skin source=\"#" << idstrEscaped << "\">" << 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 << "<Name_array id=\"" << idstrEscaped << "-skin-joints-array\" " << "count=\"" << mesh->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 << "</Name_array>" << endstr;