Merge pull request #2154 from shadekiller666/OBJ_Loader

OBJLoader Update: Fix for normal generation, whitespace handling, and UVs outside 0-1 range
This commit is contained in:
Fry committed 2015-10-29 13:53:09 +03:00
commit 887f3bf31d
4 files changed
+464 -423

No files matched your search

@@ -28,11 +28,10 @@ public class OBJLoader implements ICustomModelLoader {
private final Set<String> enabledDomains = new HashSet<String>();
private final Map<ResourceLocation, OBJModel> cache = new HashMap<ResourceLocation, OBJModel>();
public OBJLoader() {}
public void addDomain(String domain)
{
enabledDomains.add(domain.toLowerCase());
FMLLog.log(Level.INFO, "OBJLoader: Domain %s has been added.", domain.toLowerCase());
}
public void onResourceManagerReload(IResourceManager resourceManager)
@@ -46,8 +45,7 @@ public class OBJLoader implements ICustomModelLoader {
return enabledDomains.contains(modelLocation.getResourceDomain()) && modelLocation.getResourcePath().endsWith(".obj");
}
@SuppressWarnings("unchecked")
public IModel loadModel(ResourceLocation modelLocation)
public IModel loadModel(ResourceLocation modelLocation) throws IOException
{
ResourceLocation file = new ResourceLocation(modelLocation.getResourceDomain(), modelLocation.getResourcePath());
if (!cache.containsKey(file))
@@ -68,13 +66,20 @@ public class OBJLoader implements ICustomModelLoader {
else throw e;
}
OBJModel.Parser parser = new OBJModel.Parser(resource, manager);
OBJModel model = parser.parse();
cache.put(modelLocation, model);
OBJModel model = null;
try
{
model = parser.parse();
}
finally
{
cache.put(modelLocation, model);
}
}
catch (IOException e)
{
FMLLog.log(Level.ERROR, e, "Exception loading model %s with OBJ loader, skipping", modelLocation);
cache.put(modelLocation, null);
// FMLLog.log(Level.ERROR, e, "Exception loading model '%s' with OBJ loader, skipping", modelLocation);
throw e;
}
}
OBJModel model = cache.get(file);
File diff suppressed because it is too large. Load diff