Load gltf .bin files from correct directory
authorDaniel Hritzkiv <daniel.hritzkiv@gmail.com>
Thu, 7 Sep 2017 18:55:44 +0000 (14:55 -0400)
committerDaniel Hritzkiv <daniel.hritzkiv@gmail.com>
Mon, 11 Sep 2017 15:02:15 +0000 (11:02 -0400)
code/glTF2Asset.inl
code/glTFAsset.inl

index 3d4a4ee..03c2279 100644 (file)
@@ -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;
index bb4bb50..9284ccb 100644 (file)
@@ -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;