www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: reddragon on March 16, 2006, 06:31:30 pm
-
when i try to load a 3ds file in a jar i see this error
Adding Lightsource: 0
Adding Lightsource: 1
Adding Lightsource: 2
Adding Lightsource: 3
Adding Lightsource: 4
Adding Lightsource: 5
Adding Lightsource: 6
Adding Lightsource: 7
Adding Lightsource: 8
Adding Lightsource: 9
Adding Lightsource: 10
Adding Lightsource: 11
Loading Texture...from InputStream
Loading Texture...from InputStream
Loading file from InputStream
[ Thu Mar 16 13:22:32 VET 2006 ] - ERROR: Couldn't read file from InputStream
[ Thu Mar 16 13:22:32 VET 2006 ] - ERROR: Not a valid 3DS file!
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at JPCTDemo.<init>(JPCTDemo.java:271)
at JPCTDemo.main(JPCTDemo.java:151)
i use this code
Object3D[] miss=Loader.load3DS(getFile("3ds"+c+"weapon.3ds"), 2);
public java.io.InputStream getFile(String File)
{
return (RMain.class.getClassLoader().getResourceAsStream(File));
}
-
The load3DS method takes 2 parameters, a string with the 3ds file path and a scale, you are not passing a path as String but a inputStram turned as String
your new code should be:
Object3D[] miss=Loader.load3DS (getFile, 2);
public String getFile (String File) {
return File;
}
the error mesage is clear enough: ERROR: Couldn't read file from InputStream
-
No, InputStream is fine. The Loader supports it. Try to load it from "3ds/weapon.3ds" instead of using the separatorChar in the path name. If it doesn't work, double check your jar to see if the file is really where it's supposed to be.
-
yes it works.I use the following :arrow:
InputStream inputstream = getFile("3ds/weapon.3ds");
Object3D[] miss = Loader.load3DS(inputstream, 2.0F);
private InputStream getFile(String File)
{
return getClass().getClassLoader().getResourceAsStream(File);
}
Thanks for the help :D