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:
parent
dac97174ff
commit
af2b5eb6f6
1 changed files with 16 additions and 4 deletions
|
@ -49,20 +49,32 @@ public class WavefrontObject implements IModelCustom
|
||||||
public WavefrontObject(String fileName, URL resource) throws ModelFormatException
|
public WavefrontObject(String fileName, URL resource) throws ModelFormatException
|
||||||
{
|
{
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
loadObjModel(resource);
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
loadObjModel(resource.openStream());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
throw new ModelFormatException("IO Exception reading model format", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadObjModel(URL fileURL) throws ModelFormatException
|
public WavefrontObject(String filename, InputStream inputStream) throws ModelFormatException
|
||||||
|
{
|
||||||
|
this.fileName = filename;
|
||||||
|
loadObjModel(inputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadObjModel(InputStream inputStream) throws ModelFormatException
|
||||||
{
|
{
|
||||||
BufferedReader reader = null;
|
BufferedReader reader = null;
|
||||||
InputStream inputStream = null;
|
|
||||||
|
|
||||||
String currentLine = null;
|
String currentLine = null;
|
||||||
int lineCount = 0;
|
int lineCount = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
inputStream = fileURL.openStream();
|
|
||||||
reader = new BufferedReader(new InputStreamReader(inputStream));
|
reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
|
|
||||||
while ((currentLine = reader.readLine()) != null)
|
while ((currentLine = reader.readLine()) != null)
|
||||||
|
|
Loading…
Reference in a new issue