Author Topic: error loading 3ds file in a jar  (Read 4415 times)

Offline reddragon

  • byte
  • *
  • Posts: 2
    • View Profile
error loading 3ds file in a jar
« 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));
    }

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
error loading 3ds file in a jar
« Reply #1 on: March 17, 2006, 03:16:35 am »
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:

Code: [Select]


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
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
error loading 3ds file in a jar
« Reply #2 on: March 17, 2006, 04:59:29 pm »
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.

Offline reddragon

  • byte
  • *
  • Posts: 2
    • View Profile
cool
« Reply #3 on: March 18, 2006, 12:54:35 am »
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