MD2 Loader Error

I am unable to load up an md2 model i end up getting a null pointer exception… here is the stack trace

java.lang.NullPointerException
at java.io.Reader.(Reader.java:61)
at java.io.InputStreamReader.(InputStreamReader.java:55)
at org.newdawn.xith3d.loaders.cio.ByteArrayBuilder.fromStream(ByteArrayBuilder.java:22)
at org.newdawn.xith3d.loaders.pcx.PCXLoader.(PCXLoader.java:35)
at org.newdawn.xith3d.loaders.md2.MD2Loader.load(MD2Loader.java:73)
at org.newdawn.xith3d.loaders.md2.MD2Loader.load(MD2Loader.java:52)
at ClientGraphics3D.GraphicCharacter.loadModel(GraphicCharacter.java:204)
at ClientGraphics3D.GraphicCharacter.(GraphicCharacter.java:97)
at MyClient.initCustomComponents(MyClient.java:180)
at MyClient.(MyClient.java:40)
at MyClient.main(MyClient.java:172)

ANy and all help will be appreciated.
-Mmontalvo

I apologise for the terrible exception being thrown, but I think its indicating that it can’t find the PCX file associated with the model.

Kev

Is there any other possibilities? The file is in the same place as the model and it can see the model. I also double checked the path to make sure that there were no spelling errors.

Don’t think so, the only thing that could cause that would appear to be a null stream being passed in…

Kev

I’m also seeing this exact exception. The working directory for the VM is the parent folder of the “model” folder. It has no problem getting an input stream to the tris.md2 just cant find the pcx file.

I modified your source code in MD2Loader.java line 73:

tex = new PCXLoader(MD2Loader.class.getClassLoader().getResourceAsStream(texture)).getTexture();

to

tex = new PCXLoader(new FileInputStream(texture)).getTexture();

and it works fine.

I’m sure it will, but then when you go to deploy it with webstart you’ll have to modify it right back again since you can’t access local filesystem.

Use the classpath luke.

Kev

Ok how are you passing the model name in “directory/modelName” ?, or just “modelName”. If the former, try adding “directory” to the classpath and just passing “modelName” in.

HTH

Endolf

Ok have it working the correct way now. First time using ResourceBundle. I read the docs and it all makes sense.

Thanks for your help.