www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Tornado7 on June 08, 2004, 11:32:42 am

Title: Loading generic texture in an Applet
Post by: Tornado7 on June 08, 2004, 11:32:42 am
Hi Egon,

as you know I’m loading texture in this way:

Code: [Select]
texMan.addTexture("car1.jpg",new Texture(getDocumentBase(),"textures/car1.jpg"));

in my applet context. Considering that I’m using now a certificate, so I can access to the local filesystem, I’d like to load texture in a generic way using a for cycle (as you do in fps) :

Code: [Select]

File dir=new File("textures");
       String[] files=dir.list();
        for (int i=0; i<files.length; i++) {
         String name=files[i];
         if (name.endsWith(".jpg")) {
            texMan.addTexture(name, new Texture("textures"+File.separator+name));
         }
       }


but, when I run the applet the Java console says:

Code: [Select]

java.lang.NullPointerException
at ThreeDSimApplet.init(ThreeDSimApplet.java:238)
at sun.applet.AppletPanel.run(AppletPanel.java:348)
at java.lang.Thread.run(Thread.java:536)


there’s another way to load texture in a generic way in my context? Bye and thanks
Title: Loading generic texture in an Applet
Post by: EgonOlsen on June 08, 2004, 04:44:11 pm
The exception happens somewhere in your code. What exactly is in line 238?
Title: Loading generic texture in an Applet
Post by: Tornado7 on June 08, 2004, 05:17:15 pm
Line 238 is:

Code: [Select]
for (int i=0; i<files.length; i++) {
Title: Loading generic texture in an Applet
Post by: EgonOlsen on June 08, 2004, 10:10:46 pm
That means that files is null, which means that dir.list() returns null, which means that your "textures"-directory doesn't exist. At least not there where you expect it to be. Try the complete path (i.e. "c:\blah\blubb\...\textures" or similar) and see if that works.
Title: Loading generic texture in an Applet
Post by: Tornado7 on June 09, 2004, 02:42:26 pm
Ok, it works using slash. Bye and thanks  :D