Преглед на файлове

STLImporter::LoadBinaryFile add one child node to produce same scene structure as in STLImporter::LoadASCIIFile

Власов Евгений преди 7 години
родител
ревизия
7d630e98da
променени са 1 файла, в които са добавени 13 реда и са изтрити 3 реда
  1. 13 3
      code/STLLoader.cpp

+ 13 - 3
code/STLLoader.cpp

@@ -535,11 +535,21 @@ bool STLImporter::LoadBinaryFile()
     // now copy faces
     // now copy faces
     addFacesToMesh(pMesh);
     addFacesToMesh(pMesh);
 
 
+    aiNode* root = pScene->mRootNode;
+
+    // allocate one node
+    aiNode* node = new aiNode();
+    node->mParent = root;
+
+    root->mNumChildren = 1u;
+    root->mChildren = new aiNode*[root->mNumChildren];
+    root->mChildren[0] = node;
+
     // add all created meshes to the single node
     // add all created meshes to the single node
-    pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
-    pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes];
+    node->mNumMeshes = pScene->mNumMeshes;
+    node->mMeshes = new unsigned int[pScene->mNumMeshes];
     for (unsigned int i = 0; i < pScene->mNumMeshes; i++)
     for (unsigned int i = 0; i < pScene->mNumMeshes; i++)
-        pScene->mRootNode->mMeshes[i] = i;
+        node->mMeshes[i] = i;
 
 
     if (bIsMaterialise && !pMesh->mColors[0])
     if (bIsMaterialise && !pMesh->mColors[0])
     {
     {