Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.jme3.util.IntMap;
import com.jme3.util.mikktspace.MikktspaceTangentGenerator;
import java.io.*;
import java.net.URLDecoder;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.util.*;
Expand Down Expand Up @@ -589,11 +590,12 @@ protected byte[] getBytes(int bufferIndex, String uri, Integer bufferLength) thr
data = Base64.getDecoder().decode(uri.substring(uri.indexOf(",") + 1));
} else {
//external file let's load it
if (!uri.endsWith(".bin")) {
throw new AssetLoadException("Cannot load " + uri + ", a .bin extension is required.");
String decoded = decodeUri(uri);
if (!decoded.endsWith(".bin")) {
throw new AssetLoadException("Cannot load " + decoded + ", a .bin extension is required.");
}

BinDataKey key = new BinDataKey(info.getKey().getFolder() + uri);
BinDataKey key = new BinDataKey(info.getKey().getFolder() + decoded);
InputStream input = (InputStream) info.getManager().loadAsset(key);
data = new byte[bufferLength];
DataInputStream dataStream = new DataInputStream(input);
Expand Down Expand Up @@ -764,7 +766,8 @@ public Texture2D readImage(int sourceIndex, boolean flip) throws IOException {
result = (Texture2D) info.getManager().loadAssetFromStream(key, new ByteArrayInputStream(data));
} else {
//external file image
TextureKey key = new TextureKey(info.getKey().getFolder() + uri, flip);
String decoded = decodeUri(uri);
TextureKey key = new TextureKey(info.getKey().getFolder() + decoded, flip);
Texture tex = info.getManager().loadTexture(key);
result = (Texture2D) tex;
}
Expand Down Expand Up @@ -1186,6 +1189,14 @@ public Node getRootNode() {
return rootNode;
}

private String decodeUri(String uri) {
try {
return URLDecoder.decode(uri, "UTF-8");
} catch (UnsupportedEncodingException e) {
return uri; //This would mean that UTF-8 is unsupported on the platform.
}
}

public static class WeightData {
float value;
short index;
Expand Down Expand Up @@ -1417,4 +1428,3 @@ public SkinBuffers populate(Integer bufferViewIndex, int componentType, String t
}

}