Bladeren bron

Load gltf .bin files from correct directory

Daniel Hritzkiv 8 jaren geleden
bovenliggende
commit
5cb13aa4b3
2 gewijzigde bestanden met toevoegingen van 6 en 2 verwijderingen
  1. 3 1
      code/glTF2Asset.inl
  2. 3 1
      code/glTFAsset.inl

+ 3 - 1
code/glTF2Asset.inl

@@ -337,7 +337,9 @@ inline void Buffer::Read(Value& obj, Asset& r)
     }
     else { // Local file
         if (byteLength > 0) {
-            IOStream* file = r.OpenFile(uri, "rb");
+            std::string dir = !r.mCurrentAssetDir.empty() ? (r.mCurrentAssetDir + "/") : "";
+
+            IOStream* file = r.OpenFile(dir + uri, "rb");
             if (file) {
                 bool ok = LoadFromStream(*file, byteLength);
                 delete file;

+ 3 - 1
code/glTFAsset.inl

@@ -316,7 +316,9 @@ inline void Buffer::Read(Value& obj, Asset& r)
     }
     else { // Local file
         if (byteLength > 0) {
-            IOStream* file = r.OpenFile(uri, "rb");
+            std::string dir = !r.mCurrentAssetDir.empty() ? (r.mCurrentAssetDir + "/") : "";
+
+            IOStream* file = r.OpenFile(dir + uri, "rb");
             if (file) {
                 bool ok = LoadFromStream(*file, byteLength);
                 delete file;