} catch (IOException ex2) {
return null;
}
// If content couldn't be loaded, try to load model as a zipped file
ZipInputStream zipIn = null;
try {
URLContent urlContent = (URLContent)modelContent;
// Open zipped stream
zipIn = new ZipInputStream(urlContent.openStream());
// Parse entries to see if a obj file is readable
for (ZipEntry entry; (entry = zipIn.getNextEntry()) != null; ) {
try {
String entryName = entry.getName();
// Ignore directory entries and entries starting by a dot
if (!entryName.endsWith("/")) {
int slashIndex = entryName.lastIndexOf('/');
String entryFileName = entryName.substring(slashIndex + 1);
if (!entryFileName.startsWith(".")) {
int dotIndex = entryFileName.lastIndexOf(".");
if (dotIndex != -1) {
modelName = entryFileName.substring(0, dotIndex);
} else {
modelName = entryFileName;
}
URL entryUrl = new URL("jar:" + urlContent.getURL() + "!/"
+ URLEncoder.encode(entryName, "UTF-8").replace("+", "%20").replace("%2F", "/"));
modelContent = new TemporaryURLContent(entryUrl);
model = ModelManager.getInstance().loadModel(modelContent);
if (!entryFileName.toLowerCase().endsWith(".obj")
&& (this.preferences.isModelContentAlwaysConvertedToOBJFormat()
|| slashIndex > 0)) {
// Convert models in subdirectories at format different from OBJ
modelContent = copyToTemporaryOBJContent(model, modelContent);
}
break;
}
}
} catch (IOException ex2) {
// Ignore exception and try next entry
}
}
if (model == null) {
return null;
}
} catch (IOException ex2) {
return null;
} finally {
try {
if (zipIn != null) {
zipIn.close();
}
} catch (IOException ex2) {
// Ignore close exception
}
}