Add an InputStream constructor to WavefrontObject

It is said that Resource Packs will return InputStreams. And I like putting my models into texture packs which, obviously, give InputStreams rather than URLs.
This commit is contained in:
James 2013-06-19 15:57:44 -06:00
parent dac97174ff
commit af2b5eb6f6
1 changed files with 16 additions and 4 deletions

View File

@ -49,20 +49,32 @@ public class WavefrontObject implements IModelCustom
public WavefrontObject(String fileName, URL resource) throws ModelFormatException
{
this.fileName = fileName;
loadObjModel(resource);
try
{
loadObjModel(resource.openStream());
}
catch (IOException e)
{
throw new ModelFormatException("IO Exception reading model format", e);
}
}
public WavefrontObject(String filename, InputStream inputStream) throws ModelFormatException
{
this.fileName = filename;
loadObjModel(inputStream);
}
private void loadObjModel(URL fileURL) throws ModelFormatException
private void loadObjModel(InputStream inputStream) throws ModelFormatException
{
BufferedReader reader = null;
InputStream inputStream = null;
String currentLine = null;
int lineCount = 0;
try
{
inputStream = fileURL.openStream();
reader = new BufferedReader(new InputStreamReader(inputStream));
while ((currentLine = reader.readLine()) != null)